Changeset 14dd4c9 in mainline
- Timestamp:
- 2013-08-07T15:03:37Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fa9d3af
- Parents:
- 0918382f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/src/ddf_helpers.c
r0918382f r14dd4c9 46 46 #define CTRL_PIPE_MIN_PACKET_SIZE 8 47 47 48 typedef struct hc_dev {49 ddf_fun_t *ctl_fun;50 list_t devices;51 fibril_mutex_t guard;52 hcd_t hcd;53 } hc_dev_t;54 55 static hc_dev_t *dev_to_hc_dev(ddf_dev_t *dev)56 {57 return ddf_dev_data_get(dev);58 }59 60 hcd_t *dev_to_hcd(ddf_dev_t *dev)61 {62 hc_dev_t *hc_dev = dev_to_hc_dev(dev);63 if (!hc_dev) {64 usb_log_error("Invalid HCD device.\n");65 return NULL;66 }67 return &hc_dev->hcd;68 }69 70 48 typedef struct usb_dev { 71 49 link_t link; 72 50 list_t devices; 51 fibril_mutex_t guard; 73 52 ddf_fun_t *fun; 74 53 usb_address_t address; … … 76 55 unsigned port; 77 56 } usb_dev_t; 57 58 typedef struct hc_dev { 59 ddf_fun_t *ctl_fun; 60 hcd_t hcd; 61 usb_dev_t *root_hub; 62 } hc_dev_t; 63 64 static hc_dev_t *dev_to_hc_dev(ddf_dev_t *dev) 65 { 66 return ddf_dev_data_get(dev); 67 } 68 69 hcd_t *dev_to_hcd(ddf_dev_t *dev) 70 { 71 hc_dev_t *hc_dev = dev_to_hc_dev(dev); 72 if (!hc_dev) { 73 usb_log_error("Invalid HCD device.\n"); 74 return NULL; 75 } 76 return &hc_dev->hcd; 77 } 78 78 79 79 80 static int hcd_ddf_new_device(ddf_dev_t *device, usb_dev_t *hub, unsigned port); … … 312 313 } 313 314 314 //TODO more checks315 315 ddf_fun_t *fun = ddf_fun_create(parent, fun_inner, name); 316 316 if (!fun) … … 327 327 link_initialize(&info->link); 328 328 list_initialize(&info->devices); 329 fibril_mutex_initialize(&info->guard); 329 330 330 331 ddf_fun_set_ops(fun, &usb_ops); … … 341 342 342 343 if (hub_dev) { 344 fibril_mutex_lock(&hub_dev->guard); 343 345 list_append(&info->link, &hub_dev->devices); 346 fibril_mutex_unlock(&hub_dev->guard); 344 347 } else { 345 348 hc_dev_t *hc_dev = dev_to_hc_dev(parent); 346 list_append(&info->link, &hc_dev->devices); 349 assert(hc_dev->root_hub == NULL); 350 hc_dev->root_hub = info; 347 351 } 348 352 return EOK; … … 409 413 assert(hc_dev); 410 414 411 fibril_mutex_lock(&h c_dev->guard);415 fibril_mutex_lock(&hub->guard); 412 416 413 417 usb_dev_t *victim = NULL; … … 420 424 if (victim && victim->port == port) { 421 425 list_remove(&victim->link); 422 fibril_mutex_unlock(&h c_dev->guard);426 fibril_mutex_unlock(&hub->guard); 423 427 const int ret = ddf_fun_unbind(victim->fun); 424 428 if (ret == EOK) { … … 585 589 return ENOMEM; 586 590 } 587 list_initialize(&instance->devices); 588 fibril_mutex_initialize(&instance->guard); 591 instance->root_hub = NULL; 589 592 hcd_init(&instance->hcd, max_speed, bw, bw_count); 590 593
Note:
See TracChangeset
for help on using the changeset viewer.