summaryrefslogtreecommitdiffstats
path: root/pcilib/pci.c
diff options
context:
space:
mode:
authorzilio nicolas <nicolas.zilio@kit.edu>2015-08-27 12:13:38 +0200
committerzilio nicolas <nicolas.zilio@kit.edu>2015-08-27 12:13:38 +0200
commit1d3cffac722081aa8b74821a832d8cc9c58715e6 (patch)
tree1d03fc8e2c0486fec203bf3f0bd2c0b0de820986 /pcilib/pci.c
parentd3678e0fcb489eba625347d1209bd8a179153ae0 (diff)
downloadpcitool-1d3cffac722081aa8b74821a832d8cc9c58715e6.tar.gz
pcitool-1d3cffac722081aa8b74821a832d8cc9c58715e6.tar.bz2
pcitool-1d3cffac722081aa8b74821a832d8cc9c58715e6.tar.xz
pcitool-1d3cffac722081aa8b74821a832d8cc9c58715e6.zip
better public API and no more use of locals within pcilib_open
Diffstat (limited to 'pcilib/pci.c')
-rw-r--r--pcilib/pci.c24
1 files changed, 2 insertions, 22 deletions
diff --git a/pcilib/pci.c b/pcilib/pci.c
index fa3175d..5d9fedb 100644
--- a/pcilib/pci.c
+++ b/pcilib/pci.c
@@ -109,10 +109,6 @@ pcilib_t *pcilib_open(const char *device, const char *model) {
size_t i;
pcilib_t *ctx = malloc(sizeof(pcilib_t));
- pcilib_register_description_t *registers=NULL;
- pcilib_register_bank_description_t *banks=NULL;
- int number_registers, number_banks;
-
char *xmlfile;
pcilib_xml_read_config(&xmlfile,3);
xmlDocPtr doc;
@@ -121,14 +117,6 @@ pcilib_t *pcilib_open(const char *device, const char *model) {
xmlXPathContextPtr context;
context=pcilib_xml_getcontext(doc);
- number_registers=pcilib_xml_getnumberregisters(context);
- number_banks=pcilib_xml_getnumberbanks(context);
-
- if(number_registers)registers=calloc((number_registers),sizeof(pcilib_register_description_t));
- else pcilib_error("no registers in the xml file");
- if(number_banks)banks=calloc((number_banks),sizeof(pcilib_register_bank_description_t));
- else pcilib_error("no banks in the xml file");
-
if (!model)
model = getenv("PCILIB_MODEL");
@@ -192,16 +180,8 @@ pcilib_t *pcilib_open(const char *device, const char *model) {
if (!ctx->model)
ctx->model = strdup(model?model:"pci");
- if(banks){
- pcilib_xml_initialize_banks(ctx,doc,banks);
- pcilib_add_register_banks(ctx,number_banks,banks);
- }else pcilib_error("no memory for banks");
-
- if(registers){
- pcilib_xml_initialize_registers(ctx,doc,registers);
- pcilib_xml_arrange_registers(registers,number_registers);
- pcilib_add_registers(ctx,number_registers,registers);
- }else pcilib_error("no memory for registers");
+ pcilib_xml_initialize_banks(ctx,doc);
+ pcilib_xml_initialize_registers(ctx,doc);
ctx->model_info.registers = ctx->registers;
ctx->model_info.banks = ctx->banks;