Ignore:
Timestamp:
2017-10-12T14:07:27Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a5976973
Parents:
7e74911
Message:

WIP usbhost refactoring

This commit replaces callbacks with more systematic virtual-like inheritance-like solution. Currently breaks build of HelenOS, but both xhci and usbhost are buildable. More refactoring follows…

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/src/ddf_helpers.c

    r7e74911 r41924f30  
    469469
    470470        /* This checks whether the default address is reserved and gets speed */
    471         int ret = usb_bus_get_speed(&hcd->bus, USB_ADDRESS_DEFAULT, &speed);
     471        int ret = bus_get_speed(hcd->bus, USB_ADDRESS_DEFAULT, &speed);
    472472        if (ret != EOK) {
    473473                usb_log_error("Failed to verify speed: %s.", str_error(ret));
     
    623623        assert(hcd);
    624624
    625         hcd_reserve_default_address(hcd, hcd->bus.max_speed);
     625        hcd_reserve_default_address(hcd, USB_SPEED_MAX);
    626626        const int ret = hcd_ddf_new_device(device, NULL, 0);
    627627        hcd_release_default_address(hcd);
     
    639639 * This function does all the ddf work for hc driver.
    640640 */
    641 int hcd_ddf_setup_hc(ddf_dev_t *device, usb_speed_t max_speed,
    642     size_t bw, bw_count_func_t bw_count)
     641int hcd_ddf_setup_hc(ddf_dev_t *device)
    643642{
    644643        assert(device);
     
    650649        }
    651650        instance->root_hub = NULL;
    652         hcd_init(&instance->hcd, max_speed, bw, bw_count);
     651        hcd_init(&instance->hcd);
    653652
    654653        int ret = ENOMEM;
     
    851850{
    852851        assert(driver);
    853         static const struct { size_t bw; bw_count_func_t bw_count; }bw[] = {
    854             [USB_SPEED_FULL] = { .bw = BANDWIDTH_AVAILABLE_USB11,
    855                                  .bw_count = bandwidth_count_usb11 },
    856             [USB_SPEED_HIGH] = { .bw = BANDWIDTH_AVAILABLE_USB11,
    857                                  .bw_count = bandwidth_count_usb11 },
    858             [USB_SPEED_SUPER] = { .bw = BANDWIDTH_AVAILABLE_USB11,
    859                                  .bw_count = bandwidth_count_usb11 },
    860         };
    861852
    862853        int ret = EOK;
    863         const usb_speed_t speed = driver->hc_speed;
    864         if (speed >= ARRAY_SIZE(bw) || bw[speed].bw == 0) {
    865                 usb_log_error("Driver `%s' reported unsupported speed: %s",
    866                     driver->name, usb_str_speed(speed));
    867                 return ENOTSUP;
    868         }
    869854
    870855        hw_res_list_parsed_t hw_res;
     
    877862        }
    878863
    879         ret = hcd_ddf_setup_hc(device, speed, bw[speed].bw, bw[speed].bw_count);
     864        ret = hcd_ddf_setup_hc(device);
    880865        if (ret != EOK) {
    881866                usb_log_error("Failed to setup generic HCD.\n");
Note: See TracChangeset for help on using the changeset viewer.