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