From 4f4d155d5555997a966aefe2aa1d91fc96765d2a Mon Sep 17 00:00:00 2001 From: "Suren A. Chilingaryan" Date: Tue, 28 Apr 2015 06:16:36 +0200 Subject: Report selected model --- pcilib/pci.c | 5 ++++- pcitool/cli.c | 2 +- 2 files changed, 5 insertions(+), 2 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; diff --git a/pcitool/cli.c b/pcitool/cli.c index e4ba0df..77d754b 100644 --- a/pcitool/cli.c +++ b/pcitool/cli.c @@ -522,7 +522,7 @@ void Info(pcilib_t *handle, const pcilib_model_description_t *model_info) { path = getenv("PCILIB_PLUGIN_DIR"); if (!path) path = PCILIB_PLUGIN_DIR; - printf("Vendor: %x, Device: %x, Bus: %x, Slot: %x, Function: %x\n", board_info->vendor_id, board_info->device_id, board_info->bus, board_info->slot, board_info->func); + printf("Vendor: %x, Device: %x, Bus: %x, Slot: %x, Function: %x, Model: %s\n", board_info->vendor_id, board_info->device_id, board_info->bus, board_info->slot, board_info->func, handle->model); printf(" Interrupt - Pin: %i, Line: %i\n", board_info->interrupt_pin, board_info->interrupt_line); List(handle, model_info, (char*)-1, 0); -- cgit v1.2.3