summaryrefslogtreecommitdiffstats
path: root/pcilib
diff options
context:
space:
mode:
authorSuren A. Chilingaryan <csa@suren.me>2015-04-28 06:16:36 +0200
committerSuren A. Chilingaryan <csa@suren.me>2015-04-28 06:16:36 +0200
commit4f4d155d5555997a966aefe2aa1d91fc96765d2a (patch)
treeecfaea9a0dcf963711010fe871d737a20019e1ec /pcilib
parent7356cb9627e941e66dbd90b6cc670a8427c88c5e (diff)
downloadpcitool-4f4d155d5555997a966aefe2aa1d91fc96765d2a.tar.gz
pcitool-4f4d155d5555997a966aefe2aa1d91fc96765d2a.tar.bz2
pcitool-4f4d155d5555997a966aefe2aa1d91fc96765d2a.tar.xz
pcitool-4f4d155d5555997a966aefe2aa1d91fc96765d2a.zip
Report selected model
Diffstat (limited to 'pcilib')
-rw-r--r--pcilib/pci.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/pcilib/pci.c b/pcilib/pci.c
index 6eedbfe..253c439 100644
--- a/pcilib/pci.c
+++ b/pcilib/pci.c
@@ -32,6 +32,7 @@ static int pcilib_detect_model(pcilib_t *ctx, const char *model) {
if (model_info) {
memcpy(&ctx->model_info, model_info, sizeof(pcilib_model_description_t));
memcpy(&ctx->dma, model_info->dma, sizeof(pcilib_dma_description_t));
+ ctx->model = strdup(model_info->name);
} else if (model) {
// If not found, check for DMA models
for (i = 0; pcilib_dma[i].name; i++) {
@@ -109,7 +110,6 @@ pcilib_t *pcilib_open(const char *device, const char *model) {
}
ctx->page_mask = (uintptr_t)-1;
- ctx->model = model?strdup(model):NULL;
ctx->alloc_reg = PCILIB_DEFAULT_REGISTER_SPACE;
ctx->registers = (pcilib_register_description_t *)malloc(PCILIB_DEFAULT_REGISTER_SPACE * sizeof(pcilib_register_description_t));
@@ -145,6 +145,9 @@ pcilib_t *pcilib_open(const char *device, const char *model) {
return NULL;
}
+ if (!ctx->model)
+ ctx->model = strdup(model?model:"pci");
+
ctx->model_info.registers = ctx->registers;
ctx->model_info.banks = ctx->banks;
ctx->model_info.protocols = ctx->protocols;