Ignore:
File:
1 edited

Legend:

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

    r795448f r56fd7cf  
    3333 * @brief UHCI driver
    3434 */
     35
     36/* XXX Fix this */
     37#define _DDF_DATA_IMPLANT
     38
    3539#include <errno.h>
    3640#include <str_error.h>
     
    6064} uhci_t;
    6165
    62 static inline uhci_t * dev_to_uhci(const ddf_dev_t *dev)
    63 {
    64         assert(dev);
    65         return dev->driver_data;
    66 }
    67 /*----------------------------------------------------------------------------*/
     66static inline uhci_t *dev_to_uhci(ddf_dev_t *dev)
     67{
     68        return ddf_dev_data_get(dev);
     69}
     70
    6871/** IRQ handling callback, forward status from call to diver structure.
    6972 *
     
    8386        hc_interrupt(&uhci->hc, status);
    8487}
    85 /*----------------------------------------------------------------------------*/
     88
    8689/** Operations supported by the HC driver */
    8790static ddf_dev_ops_t hc_ops = {
    8891        .interfaces[USBHC_DEV_IFACE] = &hcd_iface, /* see iface.h/c */
    8992};
    90 /*----------------------------------------------------------------------------*/
     93
    9194/** Gets handle of the respective hc.
    9295 *
     
    97100static int usb_iface_get_hc_handle(ddf_fun_t *fun, devman_handle_t *handle)
    98101{
    99         assert(fun);
    100         ddf_fun_t *hc_fun = dev_to_uhci(fun->dev)->hc_fun;
     102        ddf_fun_t *hc_fun = dev_to_uhci(ddf_fun_get_dev(fun))->hc_fun;
    101103        assert(hc_fun);
    102104
    103105        if (handle != NULL)
    104                 *handle = hc_fun->handle;
     106                *handle = ddf_fun_get_handle(hc_fun);
    105107        return EOK;
    106108}
    107 /*----------------------------------------------------------------------------*/
     109
    108110/** USB interface implementation used by RH */
    109111static usb_iface_t usb_iface = {
    110112        .get_hc_handle = usb_iface_get_hc_handle,
    111113};
    112 /*----------------------------------------------------------------------------*/
     114
    113115/** Get root hub hw resources (I/O registers).
    114116 *
     
    118120static hw_resource_list_t *get_resource_list(ddf_fun_t *fun)
    119121{
    120         assert(fun);
    121         rh_t *rh = fun->driver_data;
     122        rh_t *rh = ddf_fun_data_get(fun);
    122123        assert(rh);
    123124        return &rh->resource_list;
    124125}
    125 /*----------------------------------------------------------------------------*/
     126
    126127/** Interface to provide the root hub driver with hw info */
    127128static hw_res_ops_t hw_res_iface = {
     
    129130        .enable_interrupt = NULL,
    130131};
    131 /*----------------------------------------------------------------------------*/
     132
    132133/** RH function support for uhci_rhd */
    133134static ddf_dev_ops_t rh_ops = {
     
    135136        .interfaces[HW_RES_DEV_IFACE] = &hw_res_iface
    136137};
    137 /*----------------------------------------------------------------------------*/
     138
    138139/** Initialize hc and rh DDF structures and their respective drivers.
    139140 *
     
    160161if (ret != EOK) { \
    161162        if (instance->hc_fun) \
    162                 instance->hc_fun->driver_data = NULL; \
    163163                ddf_fun_destroy(instance->hc_fun); \
    164164        if (instance->rh_fun) {\
    165                 instance->rh_fun->driver_data = NULL; \
    166165                ddf_fun_destroy(instance->rh_fun); \
    167166        } \
     
    174173        int ret = (instance->hc_fun == NULL) ? ENOMEM : EOK;
    175174        CHECK_RET_DEST_FREE_RETURN(ret, "Failed to create UHCI HC function.\n");
    176         instance->hc_fun->ops = &hc_ops;
    177         instance->hc_fun->driver_data = &instance->hc.generic;
     175        ddf_fun_set_ops(instance->hc_fun, &hc_ops);
     176        ddf_fun_data_implant(instance->hc_fun, &instance->hc.generic);
    178177
    179178        instance->rh_fun = ddf_fun_create(device, fun_inner, "uhci_rh");
    180179        ret = (instance->rh_fun == NULL) ? ENOMEM : EOK;
    181180        CHECK_RET_DEST_FREE_RETURN(ret, "Failed to create UHCI RH function.\n");
    182         instance->rh_fun->ops = &rh_ops;
    183         instance->rh_fun->driver_data = &instance->rh;
     181        ddf_fun_set_ops(instance->rh_fun, &rh_ops);
     182        ddf_fun_data_implant(instance->rh_fun, &instance->rh);
    184183
    185184        uintptr_t reg_base = 0;
     
    190189        CHECK_RET_DEST_FREE_RETURN(ret,
    191190            "Failed to get I/O addresses for %" PRIun ": %s.\n",
    192             device->handle, str_error(ret));
     191            ddf_dev_get_handle(device), str_error(ret));
    193192        usb_log_debug("I/O regs at 0x%p (size %zu), IRQ %d.\n",
    194193            (void *) reg_base, reg_size, irq);
Note: See TracChangeset for help on using the changeset viewer.