Changeset eb1a2f4 in mainline for uspace/drv/uhci-hcd/root_hub.c
- Timestamp:
- 2011-02-22T23:30:56Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 3b5d1535, a9c674e0
- Parents:
- dbe25f1 (diff), 664af708 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/uhci-hcd/root_hub.c
rdbe25f1 reb1a2f4 39 39 40 40 #include "root_hub.h" 41 #include "uhci.h" 41 42 42 extern device_ops_t child_ops; 43 static int usb_iface_get_hc_handle_rh_impl(ddf_fun_t *root_hub_fun, 44 devman_handle_t *handle) 45 { 46 ddf_fun_t *hc_fun = root_hub_fun->driver_data; 47 assert(hc_fun != NULL); 48 49 *handle = hc_fun->handle; 50 51 return EOK; 52 } 53 54 static int usb_iface_get_address_rh_impl(ddf_fun_t *fun, devman_handle_t handle, 55 usb_address_t *address) 56 { 57 assert(fun); 58 ddf_fun_t *hc_fun = fun->driver_data; 59 assert(hc_fun); 60 uhci_t *hc = fun_to_uhci(hc_fun); 61 assert(hc); 62 63 usb_address_t addr = usb_address_keeping_find(&hc->address_manager, 64 handle); 65 if (addr < 0) { 66 return addr; 67 } 68 69 if (address != NULL) { 70 *address = addr; 71 } 72 73 return EOK; 74 } 75 76 usb_iface_t usb_iface_root_hub_fun_impl = { 77 .get_hc_handle = usb_iface_get_hc_handle_rh_impl, 78 .get_address = usb_iface_get_address_rh_impl 79 }; 80 81 static ddf_dev_ops_t root_hub_ops = { 82 .interfaces[USB_DEV_IFACE] = &usb_iface_root_hub_fun_impl 83 }; 84 43 85 /*----------------------------------------------------------------------------*/ 44 int setup_root_hub(d evice_t **device, device_t *hc)86 int setup_root_hub(ddf_fun_t **fun, ddf_dev_t *hc) 45 87 { 46 assert(device); 47 device_t *hub = create_device(); 88 assert(fun); 89 int ret; 90 91 ddf_fun_t *hub = ddf_fun_create(hc, fun_inner, "root-hub"); 48 92 if (!hub) { 49 93 usb_log_error("Failed to create root hub device structure.\n"); 50 return ENOMEM;51 }52 char *name;53 int ret = asprintf(&name, "UHCI Root Hub");54 if (ret < 0) {55 usb_log_error("Failed to create root hub name.\n");56 free(hub);57 94 return ENOMEM; 58 95 } … … 62 99 if (ret < 0) { 63 100 usb_log_error("Failed to create root hub match string.\n"); 64 free(hub); 65 free(name); 101 ddf_fun_destroy(hub); 66 102 return ENOMEM; 67 103 } 68 104 69 match_id_t *match_id = create_match_id(); 70 if (!match_id) { 71 usb_log_error("Failed to create root hub match id.\n"); 72 free(hub); 73 free(match_str); 105 ret = ddf_fun_add_match_id(hub, match_str, 100); 106 if (ret != EOK) { 107 usb_log_error("Failed to add root hub match id.\n"); 108 ddf_fun_destroy(hub); 74 109 return ENOMEM; 75 110 } 76 match_id->id = match_str;77 match_id->score = 90;78 111 79 add_match_id(&hub->match_ids, match_id); 80 hub->name = name; 81 hub->parent = hc; 82 hub->ops = &child_ops; 112 hub->ops = &root_hub_ops; 83 113 84 * device= hub;114 *fun = hub; 85 115 return EOK; 86 116 }
Note:
See TracChangeset
for help on using the changeset viewer.