Changes in uspace/drv/bus/isa/isa.c [3e6a98c5:e882e3a] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/isa/isa.c
r3e6a98c5 re882e3a 42 42 #include <stdio.h> 43 43 #include <errno.h> 44 #include < stdbool.h>44 #include <bool.h> 45 45 #include <fibril_synch.h> 46 46 #include <stdlib.h> … … 73 73 #define CHILD_FUN_CONF_PATH "/drv/isa/isa.dev" 74 74 75 /** Obtain soft-state from device node */ 76 #define ISA_BUS(dev) ((isa_bus_t *) ((dev)->driver_data)) 77 78 /** Obtain soft-state from function node */ 79 #define ISA_FUN(fun) ((isa_fun_t *) ((fun)->driver_data)) 80 75 81 #define ISA_MAX_HW_RES 5 76 82 … … 89 95 } isa_fun_t; 90 96 91 /** Obtain soft-state from device node */92 static isa_bus_t *isa_bus(ddf_dev_t *dev)93 {94 return ddf_dev_data_get(dev);95 }96 97 /** Obtain soft-state from function node */98 static isa_fun_t *isa_fun(ddf_fun_t *fun)99 {100 return ddf_fun_data_get(fun);101 }102 103 97 static hw_resource_list_t *isa_get_fun_resources(ddf_fun_t *fnode) 104 98 { 105 isa_fun_t *fun = isa_fun(fnode);99 isa_fun_t *fun = ISA_FUN(fnode); 106 100 assert(fun != NULL); 107 101 … … 113 107 /* This is an old ugly way, copied from pci driver */ 114 108 assert(fnode); 115 isa_fun_t * fun = isa_fun(fnode);109 isa_fun_t *isa_fun = fnode->driver_data; 116 110 117 111 sysarg_t apic; … … 129 123 return false; 130 124 131 const hw_resource_list_t *res = &fun->hw_resources; 125 assert(isa_fun); 126 const hw_resource_list_t *res = &isa_fun->hw_resources; 132 127 assert(res); 133 128 for (size_t i = 0; i < res->count; ++i) { … … 155 150 { 156 151 assert(fnode); 157 isa_fun_t * fun = isa_fun(fnode);158 const hw_resource_list_t *res = & fun->hw_resources;152 isa_fun_t *isa_fun = fnode->driver_data; 153 const hw_resource_list_t *res = &isa_fun->hw_resources; 159 154 assert(res); 160 155 … … 206 201 207 202 isa_fun_t *fun = ddf_fun_data_alloc(fnode, sizeof(isa_fun_t)); 208 if (fun == NULL) { 209 ddf_fun_destroy(fnode); 203 if (fun == NULL) 210 204 return NULL; 211 }212 205 213 206 fibril_mutex_initialize(&fun->mutex); … … 344 337 345 338 ddf_msg(LVL_NOTE, "Added irq 0x%x to function %s", irq, 346 ddf_fun_get_name(fun->fnode));339 fun->fnode->name); 347 340 } 348 341 } … … 360 353 fun->hw_resources.count++; 361 354 ddf_msg(LVL_NOTE, "Added dma 0x%x to function %s", dma, 362 ddf_fun_get_name(fun->fnode));355 fun->fnode->name); 363 356 364 357 return; … … 371 364 fun->hw_resources.count++; 372 365 ddf_msg(LVL_NOTE, "Added dma 0x%x to function %s", dma, 373 ddf_fun_get_name(fun->fnode));366 fun->fnode->name); 374 367 375 368 return; … … 377 370 378 371 ddf_msg(LVL_WARN, "Skipped dma 0x%x for function %s", dma, 379 ddf_fun_get_name(fun->fnode));372 fun->fnode->name); 380 373 } 381 374 } … … 396 389 ddf_msg(LVL_NOTE, "Added io range (addr=0x%x, size=0x%x) to " 397 390 "function %s", (unsigned int) addr, (unsigned int) len, 398 ddf_fun_get_name(fun->fnode));391 fun->fnode->name); 399 392 } 400 393 } … … 468 461 if (val == end) { 469 462 ddf_msg(LVL_ERROR, "Cannot read match score for function " 470 "%s.", ddf_fun_get_name(fun->fnode));463 "%s.", fun->fnode->name); 471 464 return; 472 465 } … … 476 469 if (id == NULL) { 477 470 ddf_msg(LVL_ERROR, "Cannot read match ID for function %s.", 478 ddf_fun_get_name(fun->fnode));471 fun->fnode->name); 479 472 return; 480 473 } 481 474 482 475 ddf_msg(LVL_DEBUG, "Adding match id '%s' with score %d to " 483 "function %s", id, score, ddf_fun_get_name(fun->fnode));476 "function %s", id, score, fun->fnode->name); 484 477 485 478 rc = ddf_fun_add_match_id(fun->fnode, id, score); … … 559 552 560 553 isa_fun_t *fun = isa_fun_create(isa, fun_name); 561 free(fun_name);562 554 if (fun == NULL) { 555 free(fun_name); 563 556 return NULL; 564 557 } … … 584 577 585 578 /* Set device operations to the device. */ 586 ddf_fun_set_ops(fun->fnode, &isa_fun_ops);587 588 ddf_msg(LVL_DEBUG, "Binding function %s.", ddf_fun_get_name(fun->fnode));579 fun->fnode->ops = &isa_fun_ops; 580 581 ddf_msg(LVL_DEBUG, "Binding function %s.", fun->fnode->name); 589 582 590 583 /* XXX Handle error */ … … 619 612 620 613 ddf_msg(LVL_DEBUG, "isa_dev_add, device handle = %d", 621 (int) d df_dev_get_handle(dev));614 (int) dev->handle); 622 615 623 616 isa = ddf_dev_data_alloc(dev, sizeof(isa_bus_t)); … … 657 650 static int isa_dev_remove(ddf_dev_t *dev) 658 651 { 659 isa_bus_t *isa = isa_bus(dev);652 isa_bus_t *isa = ISA_BUS(dev); 660 653 int rc; 661 654 … … 669 662 if (rc != EOK) { 670 663 fibril_mutex_unlock(&isa->mutex); 671 ddf_msg(LVL_ERROR, "Failed offlining %s", ddf_fun_get_name(fun->fnode));664 ddf_msg(LVL_ERROR, "Failed offlining %s", fun->fnode->name); 672 665 return rc; 673 666 } … … 676 669 if (rc != EOK) { 677 670 fibril_mutex_unlock(&isa->mutex); 678 ddf_msg(LVL_ERROR, "Failed unbinding %s", ddf_fun_get_name(fun->fnode));671 ddf_msg(LVL_ERROR, "Failed unbinding %s", fun->fnode->name); 679 672 return rc; 680 673 } … … 712 705 static void isa_init() 713 706 { 714 ddf_log_init(NAME );707 ddf_log_init(NAME, LVL_ERROR); 715 708 isa_fun_ops.interfaces[HW_RES_DEV_IFACE] = &isa_fun_hw_res_ops; 716 709 }
Note:
See TracChangeset
for help on using the changeset viewer.