Changeset e4d7363 in mainline for uspace/drv/bus/usb/uhci/main.c


Ignore:
Timestamp:
2017-06-22T21:34:39Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
91ca111
Parents:
cb89430
Message:

usbhost: refactor the initialization

Before that, drivers had to setup MMIO range multiple times, or even parse hw
resources themselves again. The former init method was split in half - init and
start. Init shall allocate and initialize inner structures, start shall start
the HC.

In the XHCI it is demonstrated how to isolate inner HC implementation from the
fact this driver is using libusbhost. It adds some boilerplate code, but
I think it leads to cleaner design.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/uhci/main.c

    rcb89430 re4d7363  
    5050#define NAME "uhci"
    5151
    52 static int uhci_driver_init(hcd_t *, const hw_res_list_parsed_t *, bool);
     52static int uhci_driver_init(hcd_t *, const hw_res_list_parsed_t *);
     53static int uhci_driver_start(hcd_t *, bool);
    5354static void uhci_driver_fini(hcd_t *);
    54 static int disable_legacy(ddf_dev_t *);
     55static int disable_legacy(hcd_t *, ddf_dev_t *);
    5556
    5657static const ddf_hc_driver_t uhci_hc_driver = {
     
    5960        .irq_code_gen = uhci_hc_gen_irq_code,
    6061        .init = uhci_driver_init,
     62        .start = uhci_driver_start,
    6163        .fini = uhci_driver_fini,
    6264        .name = "UHCI",
     
    6870};
    6971
    70 static int uhci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res, bool irq)
     72static int uhci_driver_init(hcd_t *hcd, const hw_res_list_parsed_t *res)
    7173{
    7274        assert(hcd);
     
    7779                return ENOMEM;
    7880
    79         const int ret = hc_init(instance, res, irq);
     81        const int ret = hc_init(instance, res);
    8082        if (ret == EOK) {
    8183                hcd_set_implementation(hcd, instance, &uhci_hc_driver.ops);
     
    8486        }
    8587        return ret;
     88}
     89
     90static int uhci_driver_start(hcd_t *hcd, bool interrupts)
     91{
     92        assert(hcd);
     93        hc_t *hc = hcd_get_driver_data(hcd);
     94
     95        hc->hw_interrupts = interrupts;
     96        hc_start(hc);
     97        return EOK;
    8698}
    8799
     
    102114 * @return Error code.
    103115 */
    104 static int disable_legacy(ddf_dev_t *device)
     116static int disable_legacy(hcd_t *hcd, ddf_dev_t *device)
    105117{
    106118        assert(device);
Note: See TracChangeset for help on using the changeset viewer.