Ignore:
Timestamp:
2015-07-04T03:28:02Z (9 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
55346870
Parents:
2dbfe44
Message:

libusbhost,ehci,ohci,uhci,vhc: Pass ops structure instead of function pointers to intialization

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/include/usb/host/hcd.h

    r2dbfe44 rb5f813c  
    5555
    5656typedef struct {
    57         /** Device specific driver data. */
    58         void *data;
    5957        /** Transfer scheduling, implement in device driver. */
    6058        schedule_hook_t schedule;
     
    6765        /** Periodic polling hook */
    6866        status_hook_t status_hook;
    69 } hc_driver_t;
     67} hcd_ops_t;
    7068
    7169/** Generic host controller driver structure. */
     
    7472        usb_bus_t bus;
    7573
    76         /** Driver implementation */
    77         hc_driver_t driver;
    78 
    7974        /** Interrupt replacement fibril */
    8075        fid_t polling_fibril;
     76
     77        /** Driver implementation */
     78        hcd_ops_t ops;
     79        /** Device specific driver data. */
     80        void * driver_data;
    8181};
    8282
     
    8585
    8686static inline void hcd_set_implementation(hcd_t *hcd, void *data,
    87     schedule_hook_t schedule, ep_add_hook_t add_hook, ep_remove_hook_t rem_hook,
    88     interrupt_hook_t irq_hook, status_hook_t status_hook)
     87    const hcd_ops_t *ops)
    8988{
    9089        assert(hcd);
    91         hcd->driver.data = data;
    92         hcd->driver.schedule = schedule;
    93         hcd->driver.ep_add_hook = add_hook;
    94         hcd->driver.ep_remove_hook = rem_hook;
    95         hcd->driver.irq_hook = irq_hook;
    96         hcd->driver.status_hook = status_hook;
     90        if (ops) {
     91                hcd->driver_data = data;
     92                hcd->ops = *ops;
     93        } else {
     94                memset(&hcd->ops, 0, sizeof(hcd->ops));
     95        }
     96}
     97
     98static inline void * hcd_get_driver_data(hcd_t *hcd)
     99{
     100        assert(hcd);
     101        return hcd->driver_data;
    97102}
    98103
Note: See TracChangeset for help on using the changeset viewer.