Changeset d37514e in mainline
- Timestamp:
- 2017-10-28T15:41:12Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c910ecf
- Parents:
- d46ceb2b
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/xhci/bus.c
rd46ceb2b rd37514e 280 280 } 281 281 282 static int online_device(bus_t *bus_base, hcd_t *hcd, device_t *dev_base) 283 { 284 int err; 285 286 xhci_hc_t *hc = hcd_get_driver_data(hcd); 287 assert(hc); 288 289 xhci_bus_t *bus = bus_to_xhci_bus(bus_base); 290 assert(bus); 291 292 xhci_device_t *dev = xhci_device_get(dev_base); 293 assert(dev); 294 295 // TODO: Prepare the device for use. Reset? Configure? 296 297 if ((err = ddf_fun_online(dev_base->fun))) { 298 return err; 299 } 300 301 return EOK; 302 } 303 304 static int offline_device(bus_t *bus_base, hcd_t *hcd, device_t *dev_base) 305 { 306 int err; 307 308 xhci_hc_t *hc = hcd_get_driver_data(hcd); 309 assert(hc); 310 311 xhci_bus_t *bus = bus_to_xhci_bus(bus_base); 312 assert(bus); 313 314 xhci_device_t *dev = xhci_device_get(dev_base); 315 assert(dev); 316 317 /* Tear down all drivers working with the device. */ 318 if ((err = ddf_fun_offline(dev_base->fun))) { 319 return err; 320 } 321 322 // TODO: We want to keep the device addressed. Deconfigure? 323 324 return EOK; 325 } 326 282 327 static endpoint_t *create_endpoint(bus_t *base) 283 328 { … … 442 487 .remove_device = remove_device, 443 488 489 .online_device = online_device, 490 .offline_device = offline_device, 491 444 492 .create_endpoint = create_endpoint, 445 493 .destroy_endpoint = destroy_endpoint, -
uspace/drv/bus/usb/xhci/main.c
rd46ceb2b rd37514e 164 164 } 165 165 166 static int xhci_fun_online(ddf_fun_t *fun) 167 { 168 return hcd_ddf_device_online(fun); 169 } 170 171 static int xhci_fun_offline(ddf_fun_t *fun) 172 { 173 return hcd_ddf_device_offline(fun); 174 } 166 175 167 176 static const driver_ops_t xhci_driver_ops = { 168 177 .dev_add = xhci_dev_add, 178 .fun_online = xhci_fun_online, 179 .fun_offline = xhci_fun_offline 169 180 }; 170 181 -
uspace/lib/usbhost/include/usb/host/bus.h
rd46ceb2b rd37514e 82 82 int (*remove_device)(bus_t *, hcd_t *, device_t *); 83 83 84 int (*online_device)(bus_t *, hcd_t *, device_t *); /**< Optional */ 85 int (*offline_device)(bus_t *, hcd_t *, device_t *); /**< Optional */ 86 84 87 /* The following operations are protected by a bus guard. */ 85 88 endpoint_t *(*create_endpoint)(bus_t *); … … 123 126 int bus_remove_device(bus_t *, hcd_t *, device_t *); 124 127 128 int bus_online_device(bus_t *, hcd_t *, device_t *); 129 int bus_offline_device(bus_t *, hcd_t *, device_t *); 130 125 131 int bus_add_endpoint(bus_t *, device_t *, const usb_endpoint_desc_t *, endpoint_t **); 126 132 endpoint_t *bus_find_endpoint(bus_t *, device_t *, usb_target_t, usb_direction_t); -
uspace/lib/usbhost/include/usb/host/ddf_helpers.h
rd46ceb2b rd37514e 85 85 void hcd_ddf_device_destroy(device_t *); 86 86 int hcd_ddf_device_explore(hcd_t *, device_t *); 87 int hcd_ddf_device_online(ddf_fun_t *); 88 int hcd_ddf_device_offline(ddf_fun_t *); 87 89 88 90 hcd_t *dev_to_hcd(ddf_dev_t *dev); -
uspace/lib/usbhost/src/bus.c
rd46ceb2b rd37514e 101 101 } 102 102 103 int bus_online_device(bus_t *bus, hcd_t *hcd, device_t *dev) 104 { 105 assert(bus); 106 assert(hcd); 107 assert(dev); 108 109 if (!bus->ops.online_device) 110 return ENOTSUP; 111 112 return bus->ops.online_device(bus, hcd, dev); 113 } 114 115 int bus_offline_device(bus_t *bus, hcd_t *hcd, device_t *dev) 116 { 117 assert(bus); 118 assert(hcd); 119 assert(dev); 120 121 if (!bus->ops.offline_device) 122 return ENOTSUP; 123 124 return bus->ops.offline_device(bus, hcd, dev); 125 } 126 103 127 int bus_add_endpoint(bus_t *bus, device_t *device, const usb_endpoint_desc_t *desc, endpoint_t **out_ep) 104 128 { -
uspace/lib/usbhost/src/ddf_helpers.c
rd46ceb2b rd37514e 448 448 } 449 449 450 int hcd_ddf_device_online(ddf_fun_t *fun) 451 { 452 assert(fun); 453 454 hcd_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun)); 455 device_t *dev = ddf_fun_data_get(fun); 456 assert(dev); 457 assert(hcd->bus); 458 459 usb_log_info("Device(%d): Requested to be brought online.", dev->address); 460 461 return bus_online_device(hcd->bus, hcd, dev); 462 } 463 464 int hcd_ddf_device_offline(ddf_fun_t *fun) 465 { 466 assert(fun); 467 468 hcd_t *hcd = dev_to_hcd(ddf_fun_get_dev(fun)); 469 device_t *dev = ddf_fun_data_get(fun); 470 assert(dev); 471 assert(hcd->bus); 472 473 usb_log_info("Device(%d): Requested to be taken offline.", dev->address); 474 475 return bus_offline_device(hcd->bus, hcd, dev); 476 } 477 450 478 static int hcd_ddf_new_device(hcd_t *hcd, ddf_dev_t *hc, device_t *hub, unsigned port) 451 479 {
Note:
See TracChangeset
for help on using the changeset viewer.