summaryrefslogtreecommitdiffstats
path: root/pcitool/cli.c
diff options
context:
space:
mode:
authorVasilii Chernov <vchernov@inr.ru>2016-02-24 18:24:22 +0100
committerVasilii Chernov <vchernov@inr.ru>2016-02-24 18:24:22 +0100
commitb0a034e6ef4a958235a56ebde0831c0f30a84d30 (patch)
treea1f46d2d536c692edd6b17efc61ac9fefef2796b /pcitool/cli.c
parentda842568b94b0e00c1709ae01f441a7424c15b87 (diff)
parent3ea1907f3169e0233d3a32a7d470af3c34b6f967 (diff)
downloadpcitool-b0a034e6ef4a958235a56ebde0831c0f30a84d30.tar.gz
pcitool-b0a034e6ef4a958235a56ebde0831c0f30a84d30.tar.bz2
pcitool-b0a034e6ef4a958235a56ebde0831c0f30a84d30.tar.xz
pcitool-b0a034e6ef4a958235a56ebde0831c0f30a84d30.zip
Merge with Suren branch. Fix memory leaks.
Diffstat (limited to 'pcitool/cli.c')
-rw-r--r--pcitool/cli.c49
1 files changed, 24 insertions, 25 deletions
diff --git a/pcitool/cli.c b/pcitool/cli.c
index 0b0c98d..3f1af74 100644
--- a/pcitool/cli.c
+++ b/pcitool/cli.c
@@ -31,18 +31,19 @@
#include "pcitool/sysinfo.h"
#include "pcitool/formaters.h"
+#include "pcitool/buildinfo.h"
#include "views/transform.h"
#include "views/enum.h"
-#include "pci.h"
-#include "plugin.h"
-#include "config.h"
-#include "tools.h"
-#include "kmem.h"
-#include "error.h"
-#include "debug.h"
-#include "model.h"
-#include "locking.h"
+#include "pcilib/pci.h"
+#include "pcilib/plugin.h"
+#include "pcilib/config.h"
+#include "pcilib/tools.h"
+#include "pcilib/kmem.h"
+#include "pcilib/error.h"
+#include "pcilib/debug.h"
+#include "pcilib/model.h"
+#include "pcilib/locking.h"
/* defines */
#define MAX_KBUF 14
@@ -895,6 +896,8 @@ void Version(pcilib_t *handle, const pcilib_model_description_t *model_info) {
PCILIB_VERSION_GET_MICRO(version)
);
}
+
+ BuildInfo();
}
void Info(pcilib_t *handle, const pcilib_model_description_t *model_info, const char *target) {
@@ -1385,7 +1388,7 @@ int ReadData(pcilib_t *handle, ACCESS_MODE mode, FLAGS flags, pcilib_dma_engine_
int ReadRegister(pcilib_t *handle, const pcilib_model_description_t *model_info, const char *bank, const char *reg, const char *view, const char *unit, const char *attr) {
int i;
int err;
- const char *format;
+ const char *format;
pcilib_register_bank_t bank_id;
pcilib_register_bank_addr_t bank_addr = 0;
@@ -1699,23 +1702,19 @@ int WriteRegister(pcilib_t *handle, const pcilib_model_description_t *model_info
err = pcilib_write_register(handle, bank, reg, value);
if (err) Error("Error writting register %s\n", reg);
- if ((model_info->registers[regid].mode&PCILIB_REGISTER_RW) == PCILIB_REGISTER_RW) {
+ if ((model_info->registers[regid].mode&(PCILIB_REGISTER_RW|PCILIB_REGISTER_INCONSISTENT)) == PCILIB_REGISTER_RW) {
const char *format = (val.format?val.format:"%u");
-
- if(!((model_info->registers[regid].mode&PCILIB_REGISTER_INCONSISTENT) == PCILIB_REGISTER_INCONSISTENT))
- {
- err = pcilib_read_register(handle, bank, reg, &verify);
- if (err) Error("Error reading back register %s for verification\n", reg);
-
- if ( verify != value) {
- Error("Failed to write register %s: %lu is written and %lu is read back", reg, value, verify);
- } else {
- printf("%s = ", reg);
- printf(format, verify);
- printf("\n");
- }
- }
+ err = pcilib_read_register(handle, bank, reg, &verify);
+ if (err) Error("Error reading back register %s for verification\n", reg);
+
+ if (verify != value) {
+ Error("Failed to write register %s: %lu is written and %lu is read back", reg, value, verify);
+ } else {
+ printf("%s = ", reg);
+ printf(format, verify);
+ printf("\n");
+ }
} else {
printf("%s is written\n ", reg);
}