Changeset 2757247 in mainline
- Timestamp:
- 2013-08-07T13:55:15Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0918382f
- Parents:
- e991937
- Location:
- uspace/lib/usbhost
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbhost/include/usb/host/ddf_helpers.h
re991937 r2757247 40 40 #include <usbhc_iface.h> 41 41 42 int hcd_ddf_add_usb_device(ddf_dev_t *parent,43 usb_address_t address, usb_speed_t speed, const char *name,44 const match_id_list_t *mids);45 42 int hcd_ddf_setup_hc(ddf_dev_t *device, usb_speed_t max_speed, 46 43 size_t bw, bw_count_func_t bw_count); 47 44 void hcd_ddf_clean_hc(ddf_dev_t *device); 48 45 int hcd_ddf_setup_root_hub(ddf_dev_t *device); 49 int hcd_ddf_new_device(ddf_dev_t *device, usb_address_t *address);50 int hcd_ddf_remove_device(ddf_dev_t *device, usb_address_t address);51 46 52 47 hcd_t *dev_to_hcd(ddf_dev_t *dev); -
uspace/lib/usbhost/src/ddf_helpers.c
re991937 r2757247 70 70 typedef struct usb_dev { 71 71 link_t link; 72 list_t devices; 72 73 ddf_fun_t *fun; 73 74 usb_address_t address; 74 75 usb_speed_t speed; 76 unsigned port; 75 77 } usb_dev_t; 78 79 static int hcd_ddf_new_device(ddf_dev_t *device, usb_dev_t *hub, unsigned port, 80 usb_address_t *id); 81 static int hcd_ddf_remove_device(ddf_dev_t *device, usb_dev_t *hub, 82 usb_address_t id); 83 84 85 /* DDF INTERFACE */ 76 86 77 87 /** Register endpoint interface function. … … 162 172 assert(dev); 163 173 usb_address_t address = 0; 174 unsigned port = 0; //TODO provide real value here 164 175 usb_log_debug("Device %d reported a new USB device\n", dev->address); 165 const int ret = hcd_ddf_new_device(ddf_dev, &address);176 const int ret = hcd_ddf_new_device(ddf_dev, dev, port, &address); 166 177 if (ret == EOK && handle) 167 178 *handle = address; … … 176 187 assert(ddf_dev); 177 188 assert(dev); 178 usb_log_debug(" Device %dreported removal of device %d\n",179 d ev->address, (int)handle);180 return hcd_ddf_remove_device(ddf_dev, (usb_address_t)handle);189 usb_log_debug("Hub `%s' reported removal of device %d\n", 190 ddf_fun_get_name(fun), (int)handle); 191 return hcd_ddf_remove_device(ddf_dev, dev, (usb_address_t)handle); 181 192 } 182 193 … … 247 258 } 248 259 249 /** Root hub USBinterface */260 /** USB device interface */ 250 261 static usb_iface_t usb_iface = { 251 262 .get_my_device_handle = get_my_device_handle, … … 264 275 }; 265 276 266 /** Standard USB RH options (device interface) */277 /** Standard USB device interface) */ 267 278 static ddf_dev_ops_t usb_ops = { 268 279 .interfaces[USB_DEV_IFACE] = &usb_iface, 269 280 }; 281 282 283 /* DDF HELPERS */ 270 284 271 285 #define GET_DEVICE_DESC(size) \ … … 291 305 }; 292 306 293 int hcd_ddf_add_usb_device(ddf_dev_t *parent,294 u sb_address_t address, usb_speed_t speed, const char *name,307 static int hcd_ddf_add_device(ddf_dev_t *parent, usb_dev_t *hub_dev, 308 unsigned port, usb_address_t address, usb_speed_t speed, const char *name, 295 309 const match_id_list_t *mids) 296 310 { 297 311 assert(parent); 298 hc_dev_t *hc_dev = dev_to_hc_dev(parent);299 312 300 313 char default_name[10] = { 0 }; /* usbxyz-ss */ … … 317 330 info->speed = speed; 318 331 info->fun = fun; 332 info->port = port; 319 333 link_initialize(&info->link); 334 list_initialize(&info->devices); 320 335 321 336 ddf_fun_set_ops(fun, &usb_ops); … … 331 346 } 332 347 333 list_append(&info->link, &hc_dev->devices); 348 if (hub_dev) { 349 list_append(&info->link, &hub_dev->devices); 350 } else { 351 hc_dev_t *hc_dev = dev_to_hc_dev(parent); 352 list_append(&info->link, &hc_dev->devices); 353 } 334 354 return EOK; 335 355 } … … 354 374 } while (0) 355 375 356 357 376 /* This is a copy of lib/usbdev/src/recognise.c */ 358 377 static int create_match_ids(match_id_list_t *l, … … 385 404 } 386 405 387 int hcd_ddf_remove_device(ddf_dev_t *device, usb_address_t id) 406 static int hcd_ddf_remove_device(ddf_dev_t *device, usb_dev_t *hub, 407 usb_address_t id) 388 408 { 389 409 assert(device); … … 399 419 usb_dev_t *victim = NULL; 400 420 401 list_foreach(h c_dev->devices, it) {421 list_foreach(hub->devices, it) { 402 422 victim = list_get_instance(it, usb_dev_t, link); 403 423 if (victim->address == id) … … 410 430 if (ret == EOK) { 411 431 ddf_fun_destroy(victim->fun); 412 hcd_release_address(hcd, id);432 hcd_release_address(hcd, victim->address); 413 433 } else { 414 434 usb_log_warning("Failed to unbind device %d: %s\n", … … 420 440 } 421 441 422 int hcd_ddf_new_device(ddf_dev_t *device, usb_address_t *id) 442 static int hcd_ddf_new_device(ddf_dev_t *device, usb_dev_t *hub, unsigned port, 443 usb_address_t *id) 423 444 { 424 445 assert(device); … … 526 547 527 548 /* Register device */ 528 ret = hcd_ddf_add_ usb_device(device, address, speed, NULL, &mids);549 ret = hcd_ddf_add_device(device, hub, port, address, speed, NULL, &mids); 529 550 clean_match_ids(&mids); 530 551 if (ret != EOK) { … … 553 574 554 575 hcd_reserve_default_address(hcd, speed); 555 const int ret = hcd_ddf_new_device(device, NULL );576 const int ret = hcd_ddf_new_device(device, NULL, 0, NULL); 556 577 hcd_release_default_address(hcd); 557 578 return ret;
Note:
See TracChangeset
for help on using the changeset viewer.