Changeset d46b13d in mainline
- Timestamp:
- 2011-09-19T13:07:40Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 983e135
- Parents:
- ee9ea16
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhub/usbhub.c
ree9ea16 rd46b13d 55 55 #include <usb/classes/classes.h> 56 56 57 #define HUB_FNC_NAME "hub" 57 58 58 59 static usb_hub_info_t * usb_hub_info_create(usb_device_t *usb_dev); 59 60 static int usb_hub_process_hub_specific_info(usb_hub_info_t *hub_info); 60 61 static int usb_hub_set_configuration(usb_hub_info_t *hub_info); 61 static int usb_hub_start_hub_fibril(usb_hub_info_t *hub_info);62 62 static int usb_process_hub_over_current(usb_hub_info_t *hub_info, 63 63 usb_hub_status_t status); … … 83 83 * @return error code 84 84 */ 85 int usb_hub_add_device(usb_device_t *usb_dev) { 85 int usb_hub_add_device(usb_device_t *usb_dev) 86 { 86 87 if (!usb_dev) return EINVAL; 87 88 usb_hub_info_t *hub_info = usb_hub_info_create(usb_dev); … … 106 107 return opResult; 107 108 } 109 108 110 //get port count and create attached_devs 109 111 opResult = usb_hub_process_hub_specific_info(hub_info); … … 115 117 } 116 118 117 usb_log_debug("Creating 'hub' function in DDF.\n");119 usb_log_debug("Creating DDF function '" HUB_FNC_NAME "'.\n"); 118 120 ddf_fun_t *hub_fun = ddf_fun_create(hub_info->usb_device->ddf_dev, 119 fun_exposed, "hub"); 120 assert(hub_fun != NULL); 121 hub_fun->ops = NULL; 121 fun_exposed, HUB_FNC_NAME); 122 if (hub_fun == NULL) { 123 usb_log_error("Failed to create hub function.\n"); 124 free(hub_info); 125 return ENOMEM; 126 } 122 127 123 128 opResult = ddf_fun_bind(hub_fun); 124 assert(opResult == EOK); 125 126 opResult = usb_hub_start_hub_fibril(hub_info); 127 if (opResult != EOK) 129 if (opResult != EOK) { 130 usb_log_error("Failed to bind hub function: %s.\n", 131 str_error(opResult)); 128 132 free(hub_info); 129 return opResult; 133 ddf_fun_destroy(hub_fun); 134 return opResult; 135 } 136 137 opResult = usb_device_auto_poll(hub_info->usb_device, 0, 138 hub_port_changes_callback, ((hub_info->port_count + 1) / 8) + 1, 139 usb_hub_polling_terminated_callback, hub_info); 140 if (opResult != EOK) { 141 ddf_fun_destroy(hub_fun); 142 free(hub_info); 143 usb_log_error("Failed to create polling fibril: %s.\n", 144 str_error(opResult)); 145 return opResult; 146 } 147 usb_log_info("Controlling hub '%s' (%zu ports).\n", 148 hub_info->usb_device->ddf_dev->name, hub_info->port_count); 149 150 return EOK; 130 151 } 131 152 … … 322 343 config_descriptor->configuration_number); 323 344 324 return EOK;325 }326 327 /**328 * create and start fibril with hub control loop329 *330 * Before the fibril is started, the control pipe and host controller331 * connection of the hub is open.332 *333 * @param hub_info hub representing structure334 * @return error code335 */336 static int usb_hub_start_hub_fibril(usb_hub_info_t *hub_info) {337 int rc;338 339 rc = usb_device_auto_poll(hub_info->usb_device, 0,340 hub_port_changes_callback, ((hub_info->port_count + 1) / 8) + 1,341 usb_hub_polling_terminated_callback, hub_info);342 if (rc != EOK) {343 usb_log_error("Failed to create polling fibril: %s.\n",344 str_error(rc));345 free(hub_info);346 return rc;347 }348 349 usb_log_info("Controlling hub `%s' (%zu ports).\n",350 hub_info->usb_device->ddf_dev->name, hub_info->port_count);351 345 return EOK; 352 346 }
Note:
See TracChangeset
for help on using the changeset viewer.