diff options
Diffstat (limited to 'pcilib/pci.c')
-rw-r--r-- | pcilib/pci.c | 34 |
1 files changed, 20 insertions, 14 deletions
diff --git a/pcilib/pci.c b/pcilib/pci.c index 5f3c8aa..b7dcbcd 100644 --- a/pcilib/pci.c +++ b/pcilib/pci.c @@ -1,6 +1,7 @@ //#define PCILIB_FILE_IO #define _XOPEN_SOURCE 700 #define _BSD_SOURCE +#define _DEFAULT_SOURCE #define _POSIX_C_SOURCE 200809L #include <stdio.h> @@ -59,10 +60,10 @@ static int pcilib_detect_model(pcilib_t *ctx, const char *model) { if (dma) { if (dma->banks) - pcilib_add_register_banks(ctx, 0, dma->banks); + pcilib_add_register_banks(ctx, PCILIB_MODEL_MODIFICATON_FLAGS_DEFAULT, 0, dma->banks, NULL); if (dma->registers) - pcilib_add_registers(ctx, 0, dma->registers); + pcilib_add_registers(ctx, PCILIB_MODEL_MODIFICATON_FLAGS_DEFAULT, 0, dma->registers, NULL); if (dma->engines) { for (j = 0; dma->engines[j].addr_bits; j++); @@ -73,16 +74,16 @@ static int pcilib_detect_model(pcilib_t *ctx, const char *model) { } if (model_info->protocols) - pcilib_add_register_protocols(ctx, 0, model_info->protocols); + pcilib_add_register_protocols(ctx, PCILIB_MODEL_MODIFICATON_FLAGS_DEFAULT, 0, model_info->protocols, NULL); if (model_info->banks) - pcilib_add_register_banks(ctx, 0, model_info->banks); + pcilib_add_register_banks(ctx, PCILIB_MODEL_MODIFICATON_FLAGS_DEFAULT, 0, model_info->banks, NULL); if (model_info->registers) - pcilib_add_registers(ctx, 0, model_info->registers); + pcilib_add_registers(ctx, PCILIB_MODEL_MODIFICATON_FLAGS_DEFAULT, 0, model_info->registers, NULL); if (model_info->ranges) - pcilib_add_register_ranges(ctx, 0, model_info->ranges); + pcilib_add_register_ranges(ctx, PCILIB_MODEL_MODIFICATON_FLAGS_DEFAULT, 0, model_info->ranges); } // Load XML registers @@ -105,7 +106,7 @@ static int pcilib_detect_model(pcilib_t *ctx, const char *model) { pcilib_t *pcilib_open(const char *device, const char *model) { - int err; + int err, xmlerr; size_t i; pcilib_t *ctx = malloc(sizeof(pcilib_t)); @@ -159,7 +160,7 @@ pcilib_t *pcilib_open(const char *device, const char *model) { ctx->num_protocols = i; err = pcilib_detect_model(ctx, model); - if (err) { + if ((err)&&(err != PCILIB_ERROR_NOTFOUND)) { const pcilib_board_info_t *board_info = pcilib_get_board_info(ctx); if (board_info) pcilib_error("Error (%i) configuring model %s (%x:%x)", err, (model?model:""), board_info->vendor_id, board_info->device_id); @@ -172,9 +173,16 @@ pcilib_t *pcilib_open(const char *device, const char *model) { if (!ctx->model) ctx->model = strdup(model?model:"pci"); - err = pcilib_init_xml(ctx, ctx->model); - if (err) { - pcilib_error("Error (%i) initializing xml part\n", err); + xmlerr = pcilib_init_xml(ctx, ctx->model); + if ((xmlerr)&&(xmlerr != PCILIB_ERROR_NOTFOUND)) { + pcilib_error("Error (%i) initializing XML subsystem for model %s", xmlerr, ctx->model); + pcilib_close(ctx); + return NULL; + } + + // We have found neither standard model nor XML + if ((err)&&(xmlerr)) { + pcilib_error("The specified model (%s) is not available", model); pcilib_close(ctx); return NULL; } @@ -190,7 +198,6 @@ pcilib_t *pcilib_open(const char *device, const char *model) { pcilib_close(ctx); return NULL; } - err = pcilib_init_event_engine(ctx); if (err) { @@ -363,8 +370,7 @@ void pcilib_close(pcilib_t *ctx) { pcilib_free_register_banks(ctx); - if(ctx->xml_ctx) - pcilib_free_xml(ctx); + pcilib_free_xml(ctx); if (ctx->register_ctx) free(ctx->register_ctx); |