Changeset 1d5a540 in mainline for uspace/lib
- Timestamp:
- 2012-08-17T11:52:20Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 034c4202
- Parents:
- 8312577 (diff), 56fd7cf (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/lib
- Files:
-
- 1 added
- 14 edited
-
drv/generic/driver.c (modified) (9 diffs)
-
drv/generic/interrupt.c (modified) (1 diff)
-
drv/generic/private/driver.h (added)
-
drv/generic/remote_graph_dev.c (modified) (1 diff)
-
drv/include/ddf/driver.h (modified) (4 diffs)
-
nic/src/nic_driver.c (modified) (8 diffs)
-
nic/src/nic_impl.c (modified) (24 diffs)
-
usb/include/usb/hc.h (modified) (1 diff)
-
usb/src/ddfiface.c (modified) (4 diffs)
-
usb/src/hc.c (modified) (1 diff)
-
usbdev/src/devdrv.c (modified) (5 diffs)
-
usbdev/src/devpoll.c (modified) (2 diffs)
-
usbdev/src/hub.c (modified) (2 diffs)
-
usbdev/src/recognise.c (modified) (4 diffs)
-
usbhost/include/usb/host/hcd.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/drv/generic/driver.c
r8312577 r1d5a540 36 36 /** @file 37 37 */ 38 39 #define _DDF_DATA_IMPLANT 38 40 39 41 #include <assert.h> … … 58 60 #include "ddf/driver.h" 59 61 #include "ddf/interrupt.h" 62 #include "private/driver.h" 60 63 61 64 /** Driver structure */ … … 523 526 static void delete_device(ddf_dev_t *dev) 524 527 { 528 if (dev->parent_sess) 529 async_hangup(dev->parent_sess); 525 530 if (dev->driver_data != NULL) 526 531 free(dev->driver_data); … … 597 602 } 598 603 604 /** Implant foreign driver-specific device data. 605 * 606 * XXX This is used to transition USB to new interface. Do not use 607 * in new code. Use of this function must be removed. 608 */ 609 void ddf_fun_data_implant(ddf_fun_t *fun, void *data) 610 { 611 assert(fun->driver_data == NULL); 612 fun->driver_data = data; 613 } 614 615 /** Return driver-specific device data. */ 616 void *ddf_dev_data_get(ddf_dev_t *dev) 617 { 618 return dev->driver_data; 619 } 620 621 /** Get device handle. */ 622 devman_handle_t ddf_dev_get_handle(ddf_dev_t *dev) 623 { 624 return dev->handle; 625 } 626 627 /** Return device name. 628 * 629 * @param dev Device 630 * @return Device name. Valid as long as @a dev is valid. 631 */ 632 const char *ddf_dev_get_name(ddf_dev_t *dev) 633 { 634 return dev->name; 635 } 636 637 /** Create session with the parent function. 638 * 639 * The session will be automatically closed when @a dev is destroyed. 640 * 641 * @param dev Device 642 * @param mgmt Exchange management style 643 * @return New session or NULL if session could not be created 644 */ 645 async_sess_t *ddf_dev_parent_sess_create(ddf_dev_t *dev, exch_mgmt_t mgmt) 646 { 647 assert(dev->parent_sess == NULL); 648 dev->parent_sess = devman_parent_device_connect(mgmt, dev->handle, 649 IPC_FLAG_BLOCKING); 650 651 return dev->parent_sess; 652 } 653 654 /** Return existing session with the parent function. 655 * 656 * @param dev Device 657 * @return Existing session or NULL if there is no session 658 */ 659 async_sess_t *ddf_dev_parent_sess_get(ddf_dev_t *dev) 660 { 661 return dev->parent_sess; 662 } 663 664 /** Set function name (if it was not specified when node was created.) 665 * 666 * @param dev Device whose name has not been set yet 667 * @param name Name, will be copied 668 * @return EOK on success, ENOMEM if out of memory 669 */ 670 int ddf_fun_set_name(ddf_fun_t *dev, const char *name) 671 { 672 assert(dev->name == NULL); 673 674 dev->name = str_dup(name); 675 if (dev->name == NULL) 676 return ENOENT; 677 678 return EOK; 679 } 680 681 /** Get device to which function belongs. */ 682 ddf_dev_t *ddf_fun_get_dev(ddf_fun_t *fun) 683 { 684 return fun->dev; 685 } 686 687 /** Get function handle. 688 * 689 * XXX USB uses this, but its use should be eliminated. 690 */ 691 devman_handle_t ddf_fun_get_handle(ddf_fun_t *fun) 692 { 693 return fun->handle; 694 } 695 599 696 /** Create a DDF function node. 600 697 * … … 608 705 * This function should only fail if there is not enough free memory. 609 706 * Specifically, this function succeeds even if @a dev already has 610 * a (bound) function with the same name. 707 * a (bound) function with the same name. @a name can be NULL in which 708 * case the caller will set the name later using ddf_fun_set_name(). 709 * He must do this before binding the function. 611 710 * 612 711 * Type: A function of type fun_inner indicates that DDF should attempt … … 616 715 * @param dev Device to which we are adding function 617 716 * @param ftype Type of function (fun_inner or fun_exposed) 618 * @param name Name of function 717 * @param name Name of function or NULL 619 718 * 620 719 * @return New function or @c NULL if memory is not available … … 633 732 fun->ftype = ftype; 634 733 635 fun->name = str_dup(name); 636 if (fun->name == NULL) { 637 delete_function(fun); 638 return NULL; 734 if (name != NULL) { 735 fun->name = str_dup(name); 736 if (fun->name == NULL) { 737 delete_function(fun); 738 return NULL; 739 } 639 740 } 640 741 … … 654 755 fun->driver_data = data; 655 756 return data; 757 } 758 759 /** Return driver-specific function data. */ 760 void *ddf_fun_data_get(ddf_fun_t *fun) 761 { 762 return fun->driver_data; 763 } 764 765 /** Return function name. 766 * 767 * @param fun Function 768 * @return Function name. Valid as long as @a fun is valid. 769 */ 770 const char *ddf_fun_get_name(ddf_fun_t *fun) 771 { 772 return fun->name; 656 773 } 657 774 … … 805 922 add_match_id(&fun->match_ids, match_id); 806 923 return EOK; 924 } 925 926 /** Set function ops. */ 927 void ddf_fun_set_ops(ddf_fun_t *fun, ddf_dev_ops_t *dev_ops) 928 { 929 assert(fun->conn_handler == NULL); 930 fun->ops = dev_ops; 931 } 932 933 /** Set user-defined connection handler. 934 * 935 * This allows handling connections the non-devman way. 936 */ 937 void ddf_fun_set_conn_handler(ddf_fun_t *fun, async_client_conn_t conn) 938 { 939 assert(fun->ops == NULL); 940 fun->conn_handler = conn; 807 941 } 808 942 -
uspace/lib/drv/generic/interrupt.c
r8312577 r1d5a540 41 41 42 42 #include "ddf/interrupt.h" 43 #include "private/driver.h" 43 44 44 45 static void driver_irq_handler(ipc_callid_t iid, ipc_call_t *icall); -
uspace/lib/drv/generic/remote_graph_dev.c
r8312577 r1d5a540 56 56 graph_dev_ops_t *graph_dev_ops = (graph_dev_ops_t *) ops; 57 57 58 if (!graph_dev_ops->connect || ! fun->driver_data) {58 if (!graph_dev_ops->connect || !ddf_fun_data_get(fun)) { 59 59 async_answer_0(callid, ENOTSUP); 60 60 return; 61 61 } 62 62 63 (*graph_dev_ops->connect)( fun->driver_data, callid, call, NULL);63 (*graph_dev_ops->connect)(ddf_fun_data_get(fun), callid, call, NULL); 64 64 } 65 65 -
uspace/lib/drv/include/ddf/driver.h
r8312577 r1d5a540 42 42 #include "../dev_iface.h" 43 43 44 typedef struct ddf_dev ddf_dev_t;45 typedef struct ddf_fun ddf_fun_t;46 44 47 45 /* 48 46 * Device 49 47 */ 48 49 typedef struct ddf_dev ddf_dev_t; 50 typedef struct ddf_fun ddf_fun_t; 50 51 51 52 /** Devices operations */ … … 75 76 76 77 /** Device structure */ 77 struct ddf_dev { 78 /** 79 * Globally unique device identifier (assigned to the device by the 80 * device manager). 81 */ 82 devman_handle_t handle; 83 84 /** Reference count */ 85 atomic_t refcnt; 86 87 /** 88 * Session to the parent device driver (if it is different from this 89 * driver) 90 */ 91 async_sess_t *parent_sess; 92 93 /** Device name */ 94 const char *name; 95 96 /** Driver-specific data associated with this device */ 97 void *driver_data; 98 99 /** Link in the list of devices handled by the driver */ 100 link_t link; 101 }; 78 struct ddf_dev; 102 79 103 80 /** Function structure */ 104 struct ddf_fun { 105 /** True if bound to the device manager */ 106 bool bound; 107 108 /** Function indentifier (asigned by device manager) */ 109 devman_handle_t handle; 110 111 /** Reference count */ 112 atomic_t refcnt; 113 114 /** Device which this function belogs to */ 115 ddf_dev_t *dev; 116 117 /** Function type */ 118 fun_type_t ftype; 119 120 /** Function name */ 121 const char *name; 122 123 /** List of device ids for driver matching */ 124 match_id_list_t match_ids; 125 126 /** Driver-specific data associated with this function */ 127 void *driver_data; 128 129 /** Implementation of operations provided by this function */ 130 ddf_dev_ops_t *ops; 131 132 /** Connection handler or @c NULL to use the DDF default handler. */ 133 async_client_conn_t conn_handler; 134 135 /** Link in the list of functions handled by the driver */ 136 link_t link; 137 }; 81 struct ddf_fun; 138 82 139 83 /* … … 167 111 } driver_t; 168 112 113 /** XXX Only to transition USB */ 114 #ifdef _DDF_DATA_IMPLANT 115 extern void ddf_fun_data_implant(ddf_fun_t *, void *); 116 #endif 117 169 118 extern int ddf_driver_main(driver_t *); 170 119 171 120 extern void *ddf_dev_data_alloc(ddf_dev_t *, size_t); 121 extern void *ddf_dev_data_get(ddf_dev_t *); 122 extern devman_handle_t ddf_dev_get_handle(ddf_dev_t *); 123 extern const char *ddf_dev_get_name(ddf_dev_t *); 124 extern async_sess_t *ddf_dev_parent_sess_create(ddf_dev_t *, exch_mgmt_t); 125 extern async_sess_t *ddf_dev_parent_sess_get(ddf_dev_t *); 172 126 extern ddf_fun_t *ddf_fun_create(ddf_dev_t *, fun_type_t, const char *); 127 extern devman_handle_t ddf_fun_get_handle(ddf_fun_t *); 173 128 extern void ddf_fun_destroy(ddf_fun_t *); 174 129 extern void *ddf_fun_data_alloc(ddf_fun_t *, size_t); 130 extern void *ddf_fun_data_get(ddf_fun_t *); 131 extern const char *ddf_fun_get_name(ddf_fun_t *); 132 extern int ddf_fun_set_name(ddf_fun_t *, const char *); 133 extern ddf_dev_t *ddf_fun_get_dev(ddf_fun_t *); 175 134 extern int ddf_fun_bind(ddf_fun_t *); 176 135 extern int ddf_fun_unbind(ddf_fun_t *); … … 178 137 extern int ddf_fun_offline(ddf_fun_t *); 179 138 extern int ddf_fun_add_match_id(ddf_fun_t *, const char *, int); 180 139 extern void ddf_fun_set_ops(ddf_fun_t *, ddf_dev_ops_t *); 140 extern void ddf_fun_set_conn_handler(ddf_fun_t *, async_client_conn_t); 181 141 extern int ddf_fun_add_to_category(ddf_fun_t *, const char *); 182 142 -
uspace/lib/nic/src/nic_driver.c
r8312577 r1d5a540 47 47 #include <sysinfo.h> 48 48 #include <as.h> 49 #include <devman.h>50 49 #include <ddf/interrupt.h> 51 50 #include <ops/nic.h> … … 250 249 { 251 250 ddf_dev_t *dev = nic_data->dev; 251 async_sess_t *parent_sess; 252 252 253 253 /* Connect to the parent's driver. */ 254 dev->parent_sess = devman_parent_device_connect(EXCHANGE_SERIALIZE, 255 dev->handle, IPC_FLAG_BLOCKING); 256 if (dev->parent_sess == NULL) 254 parent_sess = ddf_dev_parent_sess_create(dev, EXCHANGE_SERIALIZE); 255 if (parent_sess == NULL) 257 256 return EPARTY; 258 257 259 return hw_res_get_list_parsed( nic_data->dev->parent_sess, resources, 0);258 return hw_res_get_list_parsed(parent_sess, resources, 0); 260 259 } 261 260 … … 650 649 * 651 650 */ 652 static nic_t *nic_create( void)653 { 654 nic_t *nic_data = malloc(sizeof(nic_t));651 static nic_t *nic_create(ddf_dev_t *dev) 652 { 653 nic_t *nic_data = ddf_dev_data_alloc(dev, sizeof(nic_t)); 655 654 if (nic_data == NULL) 656 655 return NULL; 657 656 658 657 /* Force zero to all uninitialized fields (e.g. added in future) */ 659 bzero(nic_data, sizeof(nic_t));660 658 if (nic_rxc_init(&nic_data->rx_control) != EOK) { 661 free(nic_data);662 659 return NULL; 663 660 } 664 661 665 662 if (nic_wol_virtues_init(&nic_data->wol_virtues) != EOK) { 666 free(nic_data);667 663 return NULL; 668 664 } … … 705 701 nic_t *nic_create_and_bind(ddf_dev_t *device) 706 702 { 707 assert(device); 708 assert(!device->driver_data); 709 710 nic_t *nic_data = nic_create(); 703 nic_t *nic_data = nic_create(device); 711 704 if (!nic_data) 712 705 return NULL; 713 706 714 707 nic_data->dev = device; 715 device->driver_data = nic_data;716 708 717 709 return nic_data; … … 724 716 * @param data 725 717 */ 726 static void nic_destroy(nic_t *nic_data) { 727 if (nic_data->client_session != NULL) { 728 async_hangup(nic_data->client_session); 729 } 730 718 static void nic_destroy(nic_t *nic_data) 719 { 731 720 free(nic_data->specific); 732 free(nic_data);733 721 } 734 722 … … 740 728 * @param device The NIC device structure 741 729 */ 742 void nic_unbind_and_destroy(ddf_dev_t *device){ 743 if (!device) 744 return; 745 if (!device->driver_data) 746 return; 747 748 nic_destroy((nic_t *) device->driver_data); 749 device->driver_data = NULL; 730 void nic_unbind_and_destroy(ddf_dev_t *device) 731 { 732 nic_destroy(nic_get_from_ddf_dev(device)); 750 733 return; 751 734 } … … 983 966 nic_t *nic_get_from_ddf_dev(ddf_dev_t *dev) 984 967 { 985 return (nic_t *) d ev->driver_data;986 } ;968 return (nic_t *) ddf_dev_data_get(dev); 969 } 987 970 988 971 /** … … 992 975 nic_t *nic_get_from_ddf_fun(ddf_fun_t *fun) 993 976 { 994 return (nic_t *) fun->driver_data;995 } ;977 return (nic_t *) ddf_fun_data_get(fun); 978 } 996 979 997 980 /** -
uspace/lib/nic/src/nic_impl.c
r8312577 r1d5a540 54 54 int nic_get_state_impl(ddf_fun_t *fun, nic_device_state_t *state) 55 55 { 56 nic_t *nic_data = (nic_t *) fun->driver_data;56 nic_t *nic_data = nic_get_from_ddf_fun(fun); 57 57 fibril_rwlock_read_lock(&nic_data->main_lock); 58 58 *state = nic_data->state; … … 78 78 } 79 79 80 nic_t *nic_data = (nic_t *) fun->driver_data;80 nic_t *nic_data = nic_get_from_ddf_fun(fun); 81 81 82 82 fibril_rwlock_write_lock(&nic_data->main_lock); … … 170 170 int nic_send_frame_impl(ddf_fun_t *fun, void *data, size_t size) 171 171 { 172 nic_t *nic_data = (nic_t *) fun->driver_data;172 nic_t *nic_data = nic_get_from_ddf_fun(fun); 173 173 174 174 fibril_rwlock_read_lock(&nic_data->main_lock); … … 192 192 int nic_callback_create_impl(ddf_fun_t *fun) 193 193 { 194 nic_t *nic = (nic_t *) fun->driver_data;194 nic_t *nic = nic_get_from_ddf_fun(fun); 195 195 fibril_rwlock_write_lock(&nic->main_lock); 196 196 … … 218 218 { 219 219 assert(address); 220 nic_t *nic_data = (nic_t *) fun->driver_data;220 nic_t *nic_data = nic_get_from_ddf_fun(fun); 221 221 fibril_rwlock_read_lock(&nic_data->main_lock); 222 222 memcpy(address, &nic_data->mac, sizeof (nic_address_t)); … … 236 236 int nic_get_stats_impl(ddf_fun_t *fun, nic_device_stats_t *stats) 237 237 { 238 nic_t *nic_data = (nic_t *) fun->driver_data;238 nic_t *nic_data = nic_get_from_ddf_fun(fun); 239 239 assert (stats != NULL); 240 240 fibril_rwlock_read_lock(&nic_data->stats_lock); … … 259 259 size_t max_count, nic_address_t *addr_list, size_t *addr_count) 260 260 { 261 nic_t *nic_data = (nic_t *) fun->driver_data;261 nic_t *nic_data = nic_get_from_ddf_fun(fun); 262 262 fibril_rwlock_read_lock(&nic_data->rxc_lock); 263 263 nic_rxc_unicast_get_mode(&nic_data->rx_control, mode, max_count, … … 291 291 } 292 292 293 nic_t *nic_data = (nic_t *) fun->driver_data;293 nic_t *nic_data = nic_get_from_ddf_fun(fun); 294 294 fibril_rwlock_write_lock(&nic_data->rxc_lock); 295 295 int rc = ENOTSUP; … … 326 326 size_t max_count, nic_address_t *addr_list, size_t *addr_count) 327 327 { 328 nic_t *nic_data = (nic_t *) fun->driver_data;328 nic_t *nic_data = nic_get_from_ddf_fun(fun); 329 329 fibril_rwlock_read_lock(&nic_data->rxc_lock); 330 330 nic_rxc_multicast_get_mode(&nic_data->rx_control, mode, max_count, … … 358 358 } 359 359 360 nic_t *nic_data = (nic_t *) fun->dev->driver_data;360 nic_t *nic_data = nic_get_from_ddf_fun(fun); 361 361 fibril_rwlock_write_lock(&nic_data->rxc_lock); 362 362 int rc = ENOTSUP; … … 382 382 int nic_broadcast_get_mode_impl(ddf_fun_t *fun, nic_broadcast_mode_t *mode) 383 383 { 384 nic_t *nic_data = (nic_t *) fun->driver_data;384 nic_t *nic_data = nic_get_from_ddf_fun(fun); 385 385 fibril_rwlock_read_lock(&nic_data->rxc_lock); 386 386 nic_rxc_broadcast_get_mode(&nic_data->rx_control, mode); … … 402 402 int nic_broadcast_set_mode_impl(ddf_fun_t *fun, nic_broadcast_mode_t mode) 403 403 { 404 nic_t *nic_data = (nic_t *) fun->driver_data;404 nic_t *nic_data = nic_get_from_ddf_fun(fun); 405 405 fibril_rwlock_write_lock(&nic_data->rxc_lock); 406 406 int rc = ENOTSUP; … … 429 429 size_t max_count, nic_address_t *addr_list, size_t *addr_count) 430 430 { 431 nic_t *nic_data = (nic_t *) fun->driver_data;431 nic_t *nic_data = nic_get_from_ddf_fun(fun); 432 432 fibril_rwlock_read_lock(&nic_data->rxc_lock); 433 433 nic_rxc_blocked_sources_get(&nic_data->rx_control, … … 452 452 const nic_address_t *addr_list, size_t addr_count) 453 453 { 454 nic_t *nic_data = (nic_t *) fun->driver_data;454 nic_t *nic_data = nic_get_from_ddf_fun(fun); 455 455 fibril_rwlock_write_lock(&nic_data->rxc_lock); 456 456 if (nic_data->on_blocked_sources_change) { … … 474 474 int nic_vlan_get_mask_impl(ddf_fun_t *fun, nic_vlan_mask_t *mask) 475 475 { 476 nic_t *nic_data = (nic_t *) fun->driver_data;476 nic_t *nic_data = nic_get_from_ddf_fun(fun); 477 477 fibril_rwlock_read_lock(&nic_data->rxc_lock); 478 478 int rc = nic_rxc_vlan_get_mask(&nic_data->rx_control, mask); … … 492 492 int nic_vlan_set_mask_impl(ddf_fun_t *fun, const nic_vlan_mask_t *mask) 493 493 { 494 nic_t *nic_data = (nic_t *) fun->driver_data;494 nic_t *nic_data = nic_get_from_ddf_fun(fun); 495 495 fibril_rwlock_write_lock(&nic_data->rxc_lock); 496 496 int rc = nic_rxc_vlan_set_mask(&nic_data->rx_control, mask); … … 520 520 const void *data, size_t length, nic_wv_id_t *new_id) 521 521 { 522 nic_t *nic_data = (nic_t *) fun->driver_data;522 nic_t *nic_data = nic_get_from_ddf_fun(fun); 523 523 if (nic_data->on_wol_virtue_add == NULL 524 524 || nic_data->on_wol_virtue_remove == NULL) { … … 594 594 int nic_wol_virtue_remove_impl(ddf_fun_t *fun, nic_wv_id_t id) 595 595 { 596 nic_t *nic_data = (nic_t *) fun->driver_data;596 nic_t *nic_data = nic_get_from_ddf_fun(fun); 597 597 if (nic_data->on_wol_virtue_add == NULL 598 598 || nic_data->on_wol_virtue_remove == NULL) { … … 631 631 nic_wv_type_t *type, size_t max_length, void *data, size_t *length) 632 632 { 633 nic_t *nic_data = (nic_t *) fun->driver_data;633 nic_t *nic_data = nic_get_from_ddf_fun(fun); 634 634 fibril_rwlock_read_lock(&nic_data->wv_lock); 635 635 const nic_wol_virtue_t *virtue = … … 669 669 size_t max_count, nic_wv_id_t *id_list, size_t *id_count) 670 670 { 671 nic_t *nic_data = (nic_t *) fun->driver_data;671 nic_t *nic_data = nic_get_from_ddf_fun(fun); 672 672 fibril_rwlock_read_lock(&nic_data->wv_lock); 673 673 int rc = nic_wol_virtues_list(&nic_data->wol_virtues, type, … … 689 689 int nic_wol_virtue_get_caps_impl(ddf_fun_t *fun, nic_wv_type_t type, int *count) 690 690 { 691 nic_t *nic_data = (nic_t *) fun->driver_data;691 nic_t *nic_data = nic_get_from_ddf_fun(fun); 692 692 fibril_rwlock_read_lock(&nic_data->wv_lock); 693 693 *count = nic_data->wol_virtues.caps_max[type] … … 712 712 nic_poll_mode_t *mode, struct timeval *period) 713 713 { 714 nic_t *nic_data = (nic_t *) fun->driver_data;714 nic_t *nic_data = nic_get_from_ddf_fun(fun); 715 715 fibril_rwlock_read_lock(&nic_data->main_lock); 716 716 *mode = nic_data->poll_mode; … … 735 735 nic_poll_mode_t mode, const struct timeval *period) 736 736 { 737 nic_t *nic_data = (nic_t *) fun->driver_data;737 nic_t *nic_data = nic_get_from_ddf_fun(fun); 738 738 /* If the driver does not implement the poll mode change handler it cannot 739 739 * switch off interrupts and this is not supported. */ … … 783 783 */ 784 784 int nic_poll_now_impl(ddf_fun_t *fun) { 785 nic_t *nic_data = (nic_t *) fun->driver_data;785 nic_t *nic_data = nic_get_from_ddf_fun(fun); 786 786 fibril_rwlock_read_lock(&nic_data->main_lock); 787 787 if (nic_data->poll_mode != NIC_POLL_ON_DEMAND) { -
uspace/lib/usb/include/usb/hc.h
r8312577 r1d5a540 77 77 } 78 78 79 int usb_hc_connection_initialize_from_device(usb_hc_connection_t *, 80 const ddf_dev_t *); 79 int usb_hc_connection_initialize_from_device(usb_hc_connection_t *, ddf_dev_t *); 81 80 82 81 void usb_hc_connection_deinitialize(usb_hc_connection_t *); -
uspace/lib/usb/src/ddfiface.c
r8312577 r1d5a540 68 68 { 69 69 assert(fun); 70 return usb_get_hc_by_handle( fun->handle, handle);70 return usb_get_hc_by_handle(ddf_fun_get_handle(fun), handle); 71 71 } 72 72 … … 82 82 83 83 if (handle != NULL) { 84 *handle = fun->handle;84 *handle = ddf_fun_get_handle(fun); 85 85 } 86 86 … … 99 99 { 100 100 assert(fun); 101 return usb_get_address_by_handle( fun->handle, address);101 return usb_get_address_by_handle(ddf_fun_get_handle(fun), address); 102 102 } 103 103 … … 116 116 usb_address_t *address) 117 117 { 118 assert(fun); 119 assert(fun->driver_data); 120 const usb_hub_attached_device_t *device = fun->driver_data; 118 const usb_hub_attached_device_t *device = ddf_fun_data_get(fun); 121 119 assert(device->fun == fun); 122 120 if (address) -
uspace/lib/usb/src/hc.c
r8312577 r1d5a540 115 115 */ 116 116 int usb_hc_connection_initialize_from_device(usb_hc_connection_t *connection, 117 const ddf_dev_t *device) 118 { 119 assert(connection); 120 121 if (device == NULL) { 117 ddf_dev_t *device) 118 { 119 if (device == NULL) 122 120 return EBADMEM; 123 }124 121 125 122 devman_handle_t hc_handle; 126 const int rc = usb_get_hc_by_handle(d evice->handle, &hc_handle);123 const int rc = usb_get_hc_by_handle(ddf_dev_get_handle(device), &hc_handle); 127 124 if (rc == EOK) { 128 125 usb_hc_connection_initialize(connection, hc_handle); -
uspace/lib/usbdev/src/devdrv.c
r8312577 r1d5a540 105 105 if (dev == NULL) { 106 106 usb_log_error("USB device `%s' structure allocation failed.\n", 107 gen_dev->name);107 ddf_dev_get_name(gen_dev)); 108 108 return ENOMEM; 109 109 } … … 114 114 if (rc != EOK) { 115 115 usb_log_error("USB device `%s' init failed (%s): %s.\n", 116 gen_dev->name, err_msg, str_error(rc));116 ddf_dev_get_name(gen_dev), err_msg, str_error(rc)); 117 117 return rc; 118 118 } … … 139 139 return ENOTSUP; 140 140 /* Just tell the driver to stop whatever it is doing */ 141 usb_device_t *usb_dev = gen_dev->driver_data;141 usb_device_t *usb_dev = ddf_dev_data_get(gen_dev); 142 142 const int ret = driver->ops->device_rem(usb_dev); 143 143 if (ret != EOK) … … 160 160 if (driver->ops->device_gone == NULL) 161 161 return ENOTSUP; 162 usb_device_t *usb_dev = gen_dev->driver_data;162 usb_device_t *usb_dev = ddf_dev_data_get(gen_dev); 163 163 const int ret = driver->ops->device_gone(usb_dev); 164 164 if (ret == EOK) … … 415 415 usb_address_t address; 416 416 417 int rc = usb_get_info_by_handle(ddf_dev ->handle,417 int rc = usb_get_info_by_handle(ddf_dev_get_handle(ddf_dev), 418 418 &hc_handle, &address, &usb_dev->interface_no); 419 419 if (rc != EOK) { -
uspace/lib/usbdev/src/devpoll.c
r8312577 r1d5a540 80 80 usb_log_debug("Poll%p: started polling of `%s' - " \ 81 81 "interface %d (%s,%d,%d), %zuB/%zu.\n", 82 data, d ata->dev->ddf_dev->name,82 data, ddf_dev_get_name(data->dev->ddf_dev), 83 83 (int) mapping->interface->interface_number, 84 84 usb_str_class(mapping->interface->interface_class), … … 159 159 if (failed) { 160 160 usb_log_error("Polling of device `%s' terminated: " 161 "recurring failures.\n", data->dev->ddf_dev->name); 161 "recurring failures.\n", ddf_dev_get_name( 162 data->dev->ddf_dev)); 162 163 } else { 163 164 usb_log_debug("Polling of device `%s' terminated: " 164 "driver request.\n", data->dev->ddf_dev->name); 165 "driver request.\n", ddf_dev_get_name( 166 data->dev->ddf_dev)); 165 167 } 166 168 } -
uspace/lib/usbdev/src/hub.c
r8312577 r1d5a540 63 63 return EBADMEM; 64 64 return usb_hc_bind_address(connection, 65 attached_device->address, attached_device->fun->handle);65 attached_device->address, ddf_fun_get_handle(attached_device->fun)); 66 66 } 67 67 … … 287 287 rc = usb_hub_register_device(hc_conn, &new_device); 288 288 if (rc != EOK) { 289 /* We know nothing about that data. */290 if (new_dev_data)291 child_fun->driver_data = NULL;292 289 /* The child function is already created. */ 293 290 ddf_fun_destroy(child_fun); -
uspace/lib/usbdev/src/recognise.c
r8312577 r1d5a540 33 33 * Functions for recognition of attached devices. 34 34 */ 35 36 /** XXX Fix this */ 37 #define _DDF_DATA_IMPLANT 35 38 36 39 #include <sys/types.h> … … 352 355 353 356 if (dev_ops != NULL) 354 child->ops = dev_ops;357 ddf_fun_set_ops(child, dev_ops); 355 358 else 356 child->ops = &child_ops; 357 358 child->driver_data = dev_data; 359 ddf_fun_set_ops(child, &child_ops); 360 361 ddf_fun_data_implant(child, dev_data); 362 359 363 /* 360 364 * Store the attached device in fun … … 373 377 } 374 378 375 rc = usb_device_create_match_ids(ctrl_pipe, &child->match_ids); 379 match_id_list_t match_ids; 380 init_match_ids(&match_ids); 381 rc = usb_device_create_match_ids(ctrl_pipe, &match_ids); 376 382 if (rc != EOK) 377 383 goto failure; 384 385 list_foreach(match_ids.ids, id_link) { 386 match_id_t *match_id = list_get_instance(id_link, match_id_t, link); 387 rc = ddf_fun_add_match_id(child, match_id->id, match_id->score); 388 if (rc != EOK) { 389 clean_match_ids(&match_ids); 390 goto failure; 391 } 392 } 393 394 clean_match_ids(&match_ids); 378 395 379 396 rc = ddf_fun_bind(child); … … 386 403 failure: 387 404 if (child != NULL) { 388 /* We know nothing about the data if it came from outside. */389 if (dev_data)390 child->driver_data = NULL;391 392 405 /* This takes care of match_id deallocation as well. */ 393 406 ddf_fun_destroy(child); -
uspace/lib/usbhost/include/usb/host/hcd.h
r8312577 r1d5a540 98 98 * @return pointer cast to hcd_t*. 99 99 */ 100 static inline hcd_t * fun_to_hcd(constddf_fun_t *fun)100 static inline hcd_t *fun_to_hcd(ddf_fun_t *fun) 101 101 { 102 assert(fun); 103 return fun->driver_data; 102 return ddf_fun_data_get(fun); 104 103 } 105 104
Note:
See TracChangeset
for help on using the changeset viewer.
