Changeset 9348862 in mainline


Ignore:
Timestamp:
2013-09-21T00:43:24Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4cf5b8e0
Parents:
3f03199
Message:

usb: Move HC driver implementation functions to a separate structure.

Location:
uspace
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/hc.c

    r3f03199 r9348862  
    296296{
    297297        assert(hcd);
    298         hc_t *instance = hcd->private_data;
     298        hc_t *instance = hcd->driver.data;
    299299        assert(instance);
    300300
  • uspace/drv/bus/usb/ohci/ohci.c

    r3f03199 r9348862  
    5858        assert(dev);
    5959        hcd_t *hcd = dev_to_hcd(dev);
    60         if (!hcd || !hcd->private_data) {
     60        if (!hcd || !hcd->driver.data) {
    6161                usb_log_warning("Interrupt on device that is not ready.\n");
    6262                return;
     
    6464
    6565        const uint16_t status = IPC_GET_ARG1(*call);
    66         hc_interrupt(hcd->private_data, status);
     66        hc_interrupt(hcd->driver.data, status);
    6767}
    6868
  • uspace/drv/bus/usb/ohci/ohci_endpoint.c

    r3f03199 r9348862  
    9090        endpoint_set_hc_data(
    9191            ep, ohci_ep, ohci_ep_toggle_get, ohci_ep_toggle_set);
    92         hc_enqueue_endpoint(hcd->private_data, ep);
     92        hc_enqueue_endpoint(hcd->driver.data, ep);
    9393        return EOK;
    9494}
     
    104104        assert(ep);
    105105        ohci_endpoint_t *instance = ohci_endpoint_get(ep);
    106         hc_dequeue_endpoint(hcd->private_data, ep);
     106        hc_dequeue_endpoint(hcd->driver.data, ep);
    107107        if (instance) {
    108108                free32(instance->ed);
  • uspace/drv/bus/usb/uhci/hc.c

    r3f03199 r9348862  
    444444{
    445445        assert(hcd);
    446         hc_t *instance = hcd->private_data;
     446        hc_t *instance = hcd->driver.data;
    447447        assert(instance);
    448448        assert(batch);
  • uspace/drv/bus/usb/uhci/uhci.c

    r3f03199 r9348862  
    5757        assert(dev);
    5858        hcd_t *hcd = dev_to_hcd(dev);
    59         if (!hcd || !hcd->private_data) {
     59        if (!hcd || !hcd->driver.data) {
    6060                usb_log_error("Interrupt on not yet initialized device.\n");
    6161                return;
    6262        }
    6363        const uint16_t status = IPC_GET_ARG1(*call);
    64         hc_interrupt(hcd->private_data, status);
     64        hc_interrupt(hcd->driver.data, status);
    6565}
    6666
  • uspace/drv/bus/usb/vhc/transfer.c

    r3f03199 r9348862  
    167167        assert(hcd);
    168168        assert(batch);
    169         vhc_data_t *vhc = hcd->private_data;
     169        vhc_data_t *vhc = hcd->driver.data;
    170170        assert(vhc);
    171171
  • uspace/lib/usbhost/include/usb/host/hcd.h

    r3f03199 r9348862  
    5050typedef void (*ep_remove_hook_t)(hcd_t *, endpoint_t *);
    5151
    52 /** Generic host controller driver structure. */
    53 struct hcd {
    54         /** Endpoint manager. */
    55         usb_endpoint_manager_t ep_manager;
    56 
     52typedef struct {
    5753        /** Device specific driver data. */
    58         void *private_data;
     54        void *data;
    5955        /** Transfer scheduling, implement in device driver. */
    6056        schedule_hook_t schedule;
     
    6359        /** Hook called upon removing of an endpoint. */
    6460        ep_remove_hook_t ep_remove_hook;
     61} hc_driver_t;
     62
     63/** Generic host controller driver structure. */
     64struct hcd {
     65        /** Endpoint manager. */
     66        usb_endpoint_manager_t ep_manager;
     67
     68        /** Driver implementation */
     69        hc_driver_t driver;
    6570};
    6671
     
    7277{
    7378        assert(hcd);
    74         hcd->private_data = data;
    75         hcd->schedule = schedule;
    76         hcd->ep_add_hook = add_hook;
    77         hcd->ep_remove_hook = rem_hook;
     79        hcd->driver.data = data;
     80        hcd->driver.schedule = schedule;
     81        hcd->driver.ep_add_hook = add_hook;
     82        hcd->driver.ep_remove_hook = rem_hook;
    7883}
    7984
  • uspace/lib/usbhost/src/hcd.c

    r3f03199 r9348862  
    5252        assert(ep);
    5353        assert(hcd);
    54         if (hcd->ep_add_hook)
    55                 return hcd->ep_add_hook(hcd, ep);
     54        if (hcd->driver.ep_add_hook)
     55                return hcd->driver.ep_add_hook(hcd, ep);
    5656        return EOK;
    5757}
     
    6666        assert(ep);
    6767        assert(hcd);
    68         if (hcd->ep_remove_hook)
    69                 hcd->ep_remove_hook(hcd, ep);
     68        if (hcd->driver.ep_remove_hook)
     69                hcd->driver.ep_remove_hook(hcd, ep);
    7070}
    7171
     
    9797        usb_endpoint_manager_init(&hcd->ep_manager, bandwidth, bw_count, max_speed);
    9898
    99         hcd->private_data = NULL;
    100         hcd->schedule = NULL;
    101         hcd->ep_add_hook = NULL;
    102         hcd->ep_remove_hook = NULL;
     99        hcd->driver.data = NULL;
     100        hcd->driver.schedule = NULL;
     101        hcd->driver.ep_add_hook = NULL;
     102        hcd->driver.ep_remove_hook = NULL;
    103103}
    104104
     
    207207                return ENOSPC;
    208208        }
    209         if (!hcd->schedule) {
     209        if (!hcd->driver.schedule) {
    210210                usb_log_error("HCD does not implement scheduler.\n");
    211211                return ENOTSUP;
     
    239239        }
    240240
    241         const int ret = hcd->schedule(hcd, batch);
     241        const int ret = hcd->driver.schedule(hcd, batch);
    242242        if (ret != EOK)
    243243                usb_transfer_batch_destroy(batch);
Note: See TracChangeset for help on using the changeset viewer.