Changes in / [7b6f116:5dfee52] in mainline


Ignore:
Location:
uspace
Files:
3 added
2 deleted
12 edited

Legend:

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

    r7b6f116 r5dfee52  
    9595}
    9696/*----------------------------------------------------------------------------*/
    97 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts)
     97int hc_init(hc_t *instance, ddf_fun_t *fun, ddf_dev_t *dev,
     98    uintptr_t regs, size_t reg_size, bool interrupts)
    9899{
    99100        assert(instance);
  • uspace/drv/ohci/hc.h

    r7b6f116 r5dfee52  
    7777int hc_register_hub(hc_t *instance, ddf_fun_t *hub_fun);
    7878
    79 int hc_init(hc_t *instance, uintptr_t regs, size_t reg_size, bool interrupts);
     79int hc_init(hc_t *instance, ddf_fun_t *fun, ddf_dev_t *dev,
     80     uintptr_t regs, size_t reg_size, bool interrupts);
    8081
    8182void hc_start_hw(hc_t *instance);
  • uspace/drv/ohci/main.c

    r7b6f116 r5dfee52  
    4343#define NAME "ohci"
    4444
    45 /** Initializes a new ddf driver instance of OHCI hcd.
    46  *
    47  * @param[in] device DDF instance of the device to initialize.
    48  * @return Error code.
    49  */
    50 static int ohci_add_device(ddf_dev_t *device)
    51 {
    52         usb_log_debug("ohci_add_device() called\n");
    53         assert(device);
    54 
    55         int ret = device_setup_ohci(device);
    56         if (ret != EOK) {
    57                 usb_log_error("Failed to initialize OHCI driver: %s.\n",
    58                     str_error(ret));
    59                 return ret;
    60         }
    61         usb_log_info("Controlling new OHCI device '%s'.\n", device->name);
    62 
    63         return EOK;
    64 }
     45static int ohci_add_device(ddf_dev_t *device);
    6546/*----------------------------------------------------------------------------*/
    6647static driver_ops_t ohci_driver_ops = {
     
    7253        .driver_ops = &ohci_driver_ops
    7354};
     55/*----------------------------------------------------------------------------*/
     56/** Initializes a new ddf driver instance of OHCI hcd.
     57 *
     58 * @param[in] device DDF instance of the device to initialize.
     59 * @return Error code.
     60 */
     61int ohci_add_device(ddf_dev_t *device)
     62{
     63        usb_log_debug("ohci_add_device() called\n");
     64        assert(device);
     65        ohci_t *ohci = malloc(sizeof(ohci_t));
     66        if (ohci == NULL) {
     67                usb_log_error("Failed to allocate OHCI driver.\n");
     68                return ENOMEM;
     69        }
     70
     71        int ret = ohci_init(ohci, device);
     72        if (ret != EOK) {
     73                usb_log_error("Failed to initialize OHCI driver: %s.\n",
     74                    str_error(ret));
     75                return ret;
     76        }
     77//      device->driver_data = ohci;
     78        hc_register_hub(&ohci->hc, ohci->rh_fun);
     79
     80        usb_log_info("Controlling new OHCI device `%s'.\n", device->name);
     81
     82        return EOK;
     83}
    7484/*----------------------------------------------------------------------------*/
    7585/** Initializes global driver structures (NONE).
  • uspace/drv/ohci/ohci.c

    r7b6f116 r5dfee52  
    4444#include "iface.h"
    4545#include "pci.h"
    46 #include "hc.h"
    47 #include "root_hub.h"
    48 
    49 typedef struct ohci {
    50         ddf_fun_t *hc_fun;
    51         ddf_fun_t *rh_fun;
    52 
    53         hc_t hc;
    54         rh_t rh;
    55 } ohci_t;
    56 
    57 static inline ohci_t * dev_to_ohci(ddf_dev_t *dev)
    58 {
    59         assert(dev);
    60         assert(dev->driver_data);
    61         return dev->driver_data;
    62 }
    6346
    6447/** IRQ handling callback, identifies device
     
    7053static void irq_handler(ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *call)
    7154{
    72         hc_t *hc = &dev_to_ohci(dev)->hc;
     55        assert(dev);
     56        assert(dev->driver_data);
     57        hc_t *hc = &((ohci_t*)dev->driver_data)->hc;
     58        uint16_t status = IPC_GET_ARG1(*call);
    7359        assert(hc);
    74         const uint16_t status = IPC_GET_ARG1(*call);
    7560        hc_interrupt(hc, status);
    7661}
     
    8671{
    8772        assert(fun);
    88         usb_device_keeper_t *manager = &dev_to_ohci(fun->dev)->hc.manager;
     73        usb_device_keeper_t *manager = &((ohci_t*)fun->dev->driver_data)->hc.manager;
    8974
    9075        usb_address_t addr = usb_device_keeper_find(manager, handle);
     
    10994    ddf_fun_t *fun, devman_handle_t *handle)
    11095{
    111         assert(fun);
    112         ddf_fun_t *hc_fun = dev_to_ohci(fun->dev)->hc_fun;
    113         assert(hc_fun);
    114 
    115         if (handle != NULL)
    116                 *handle = hc_fun->handle;
     96        assert(handle);
     97        ddf_fun_t *hc_fun = ((ohci_t*)fun->dev->driver_data)->hc_fun;
     98        assert(hc_fun != NULL);
     99
     100        *handle = hc_fun->handle;
    117101        return EOK;
    118102}
    119103/*----------------------------------------------------------------------------*/
    120 /** Root hub USB interface */
     104/** This iface is generic for both RH and HC. */
    121105static usb_iface_t usb_iface = {
    122106        .get_hc_handle = usb_iface_get_hc_handle,
     
    124108};
    125109/*----------------------------------------------------------------------------*/
    126 /** Standard USB HC options (HC interface) */
    127110static ddf_dev_ops_t hc_ops = {
    128111        .interfaces[USBHC_DEV_IFACE] = &hc_iface, /* see iface.h/c */
    129112};
    130113/*----------------------------------------------------------------------------*/
    131 /** Standard USB RH options (RH interface) */
    132114static ddf_dev_ops_t rh_ops = {
    133115        .interfaces[USB_DEV_IFACE] = &usb_iface,
     
    136118/** Initialize hc and rh ddf structures and their respective drivers.
    137119 *
     120 * @param[in] instance OHCI structure to use.
    138121 * @param[in] device DDF instance of the device to use.
    139  * @param[in] instance OHCI structure to use.
    140122 *
    141123 * This function does all the preparatory work for hc and rh drivers:
     
    145127 *  - registers interrupt handler
    146128 */
    147 int device_setup_ohci(ddf_dev_t *device)
    148 {
    149         ohci_t *instance = malloc(sizeof(ohci_t));
    150         if (instance == NULL) {
    151                 usb_log_error("Failed to allocate OHCI driver.\n");
    152                 return ENOMEM;
    153         }
    154 
    155 #define CHECK_RET_DEST_FREE_RETURN(ret, message...) \
     129int ohci_init(ohci_t *instance, ddf_dev_t *device)
     130{
     131        assert(instance);
     132        instance->hc_fun = NULL;
     133        instance->rh_fun = NULL;
     134#define CHECK_RET_DEST_FUN_RETURN(ret, message...) \
    156135if (ret != EOK) { \
    157         if (instance->hc_fun) { \
    158                 instance->hc_fun->ops = NULL; \
    159                 instance->hc_fun->driver_data = NULL; \
     136        usb_log_error(message); \
     137        if (instance->hc_fun) \
    160138                ddf_fun_destroy(instance->hc_fun); \
    161         } \
    162         if (instance->rh_fun) { \
    163                 instance->rh_fun->ops = NULL; \
    164                 instance->rh_fun->driver_data = NULL; \
     139        if (instance->rh_fun) \
    165140                ddf_fun_destroy(instance->rh_fun); \
    166         } \
    167         free(instance); \
    168         usb_log_error(message); \
    169141        return ret; \
    170 } else (void)0
    171 
    172         instance->rh_fun = NULL;
    173         instance->hc_fun = ddf_fun_create(device, fun_exposed, "ohci-hc");
    174         int ret = instance->hc_fun ? EOK : ENOMEM;
    175         CHECK_RET_DEST_FREE_RETURN(ret, "Failed to create OHCI HC function.\n");
    176         instance->hc_fun->ops = &hc_ops;
    177         instance->hc_fun->driver_data = &instance->hc;
    178 
    179         instance->rh_fun = ddf_fun_create(device, fun_inner, "ohci-rh");
    180         ret = instance->rh_fun ? EOK : ENOMEM;
    181         CHECK_RET_DEST_FREE_RETURN(ret, "Failed to create OHCI RH function.\n");
    182         instance->rh_fun->ops = &rh_ops;
    183 
    184         uintptr_t reg_base = 0;
    185         size_t reg_size = 0;
     142}
     143
     144        uintptr_t mem_reg_base = 0;
     145        size_t mem_reg_size = 0;
    186146        int irq = 0;
    187147
    188         ret = pci_get_my_registers(device, &reg_base, &reg_size, &irq);
    189         CHECK_RET_DEST_FREE_RETURN(ret,
     148        int ret =
     149            pci_get_my_registers(device, &mem_reg_base, &mem_reg_size, &irq);
     150        CHECK_RET_DEST_FUN_RETURN(ret,
    190151            "Failed to get memory addresses for %" PRIun ": %s.\n",
    191152            device->handle, str_error(ret));
    192153        usb_log_debug("Memory mapped regs at %p (size %zu), IRQ %d.\n",
    193             (void *) reg_base, reg_size, irq);
     154            (void *) mem_reg_base, mem_reg_size, irq);
    194155
    195156        bool interrupts = false;
    196157#ifdef CONFIG_USBHC_NO_INTERRUPTS
    197         usb_log_warning("Interrupts disabled in OS config, "
     158        usb_log_warning("Interrupts disabled in OS config, " \
    198159            "falling back to polling.\n");
    199160#else
     
    202163                usb_log_warning("Failed to enable interrupts: %s.\n",
    203164                    str_error(ret));
    204                 usb_log_info("HW interrupts not available, "
     165                usb_log_info("HW interrupts not available, " \
    205166                    "falling back to polling.\n");
    206167        } else {
     
    210171#endif
    211172
    212         ret = hc_init(&instance->hc, reg_base, reg_size, interrupts);
    213         CHECK_RET_DEST_FREE_RETURN(ret, "Failed(%d) to init ohci-hcd.\n", ret);
     173        instance->hc_fun = ddf_fun_create(device, fun_exposed, "ohci-hc");
     174        ret = (instance->hc_fun == NULL) ? ENOMEM : EOK;
     175        CHECK_RET_DEST_FUN_RETURN(ret,
     176            "Failed(%d) to create HC function.\n", ret);
     177
     178        ret = hc_init(&instance->hc, instance->hc_fun, device,
     179            mem_reg_base, mem_reg_size, interrupts);
     180        CHECK_RET_DEST_FUN_RETURN(ret, "Failed(%d) to init ohci-hcd.\n", ret);
     181        instance->hc_fun->ops = &hc_ops;
     182        instance->hc_fun->driver_data = &instance->hc;
     183        ret = ddf_fun_bind(instance->hc_fun);
     184        CHECK_RET_DEST_FUN_RETURN(ret,
     185            "Failed(%d) to bind OHCI device function: %s.\n",
     186            ret, str_error(ret));
     187        ret = ddf_fun_add_to_class(instance->hc_fun, USB_HC_DDF_CLASS_NAME);
     188        CHECK_RET_DEST_FUN_RETURN(ret,
     189            "Failed to add OHCI to HC class: %s.\n", str_error(ret));
     190
     191#undef CHECK_RET_HC_RETURN
    214192
    215193#define CHECK_RET_FINI_RETURN(ret, message...) \
    216194if (ret != EOK) { \
     195        usb_log_error(message); \
     196        if (instance->hc_fun) \
     197                ddf_fun_destroy(instance->hc_fun); \
     198        if (instance->rh_fun) \
     199                ddf_fun_destroy(instance->rh_fun); \
    217200        hc_fini(&instance->hc); \
    218         CHECK_RET_DEST_FREE_RETURN(ret, message); \
    219 } else (void)0
     201        return ret; \
     202}
    220203
    221204        /* It does no harm if we register this on polling */
     
    225208            "Failed(%d) to register interrupt handler.\n", ret);
    226209
    227         ret = ddf_fun_bind(instance->hc_fun);
     210        instance->rh_fun = ddf_fun_create(device, fun_inner, "ohci-rh");
     211        ret = (instance->rh_fun == NULL) ? ENOMEM : EOK;
    228212        CHECK_RET_FINI_RETURN(ret,
    229             "Failed(%d) to bind OHCI device function: %s.\n",
    230             ret, str_error(ret));
    231 
    232         ret = ddf_fun_add_to_class(instance->hc_fun, USB_HC_DDF_CLASS_NAME);
    233         CHECK_RET_FINI_RETURN(ret,
    234             "Failed to add OHCI to HC class: %s.\n", str_error(ret));
    235 
     213            "Failed(%d) to create root hub function.\n", ret);
     214
     215
     216        instance->rh_fun->ops = &rh_ops;
     217        instance->rh_fun->driver_data = NULL;
     218       
    236219        device->driver_data = instance;
    237220
    238221        hc_start_hw(&instance->hc);
    239         hc_register_hub(&instance->hc, instance->rh_fun);
    240222        return EOK;
    241 
    242 #undef CHECK_RET_DEST_FUN_RETURN
    243223#undef CHECK_RET_FINI_RETURN
    244224}
  • uspace/drv/ohci/ohci.h

    r7b6f116 r5dfee52  
    3838#include <ddf/driver.h>
    3939
    40 int device_setup_ohci(ddf_dev_t *device);
     40#include "hc.h"
     41#include "root_hub.h"
     42
     43typedef struct ohci {
     44        ddf_fun_t *hc_fun;
     45        ddf_fun_t *rh_fun;
     46
     47        hc_t hc;
     48        rh_t rh;
     49} ohci_t;
     50
     51int ohci_init(ohci_t *instance, ddf_dev_t *device);
    4152
    4253#endif
  • uspace/drv/ohci/pci.c

    r7b6f116 r5dfee52  
    5858    uintptr_t *mem_reg_address, size_t *mem_reg_size, int *irq_no)
    5959{
    60         assert(dev);
    61         assert(mem_reg_address);
    62         assert(mem_reg_size);
    63         assert(irq_no);
     60        assert(dev != NULL);
    6461
    6562        int parent_phone = devman_parent_device_connect(dev->handle,
  • uspace/drv/ohci/root_hub.c

    r7b6f116 r5dfee52  
    237237                return ENOMEM;
    238238
    239         usb_log_info("OHCI root hub with %zu ports initialized.\n",
     239        usb_log_info("OHCI root hub with %d ports initialized.\n",
    240240            instance->port_count);
    241241
  • uspace/drv/uhci-hcd/hc.c

    r7b6f116 r5dfee52  
    6060 *
    6161 * @param[in] instance Memory place to initialize.
     62 * @param[in] fun DDF function.
    6263 * @param[in] regs Address of I/O control registers.
    6364 * @param[in] size Size of I/O control registers.
     
    6869 * interrupt fibrils.
    6970 */
    70 int hc_init(hc_t *instance, void *regs, size_t reg_size, bool interrupts)
     71int hc_init(hc_t *instance, ddf_fun_t *fun,
     72    void *regs, size_t reg_size, bool interrupts)
    7173{
    7274        assert(reg_size >= sizeof(regs_t));
  • uspace/drv/uhci-hcd/hc.h

    r7b6f116 r5dfee52  
    136136} hc_t;
    137137
    138 int hc_init(hc_t *instance, void *regs, size_t reg_size, bool interupts);
     138int hc_init(hc_t *instance, ddf_fun_t *fun,
     139    void *regs, size_t reg_size, bool interupts);
    139140
    140141int hc_schedule(hc_t *instance, usb_transfer_batch_t *batch);
  • uspace/drv/uhci-hcd/main.c

    r7b6f116 r5dfee52  
    6464        assert(device);
    6565
    66         int ret = device_setup_uhci(device);
     66        uhci_t *uhci = malloc(sizeof(uhci_t));
     67        if (uhci == NULL) {
     68                usb_log_error("Failed to allocate UHCI driver.\n");
     69                return ENOMEM;
     70        }
     71
     72        int ret = uhci_init(uhci, device);
    6773        if (ret != EOK) {
    6874                usb_log_error("Failed to initialize UHCI driver: %s.\n",
     
    7076                return ret;
    7177        }
     78        device->driver_data = uhci;
     79
    7280        usb_log_info("Controlling new UHCI device '%s'.\n", device->name);
    7381
  • uspace/drv/uhci-hcd/uhci.c

    r7b6f116 r5dfee52  
    4444#include "pci.h"
    4545
    46 #include "hc.h"
    47 #include "root_hub.h"
    48 
    49 /** Structure representing both functions of UHCI hc, USB host controller
    50  * and USB root hub */
    51 typedef struct uhci {
    52         /** Pointer to DDF represenation of UHCI host controller */
    53         ddf_fun_t *hc_fun;
    54         /** Pointer to DDF represenation of UHCI root hub */
    55         ddf_fun_t *rh_fun;
    56 
    57         /** Internal driver's represenation of UHCI host controller */
    58         hc_t hc;
    59         /** Internal driver's represenation of UHCI root hub */
    60         rh_t rh;
    61 } uhci_t;
    62 
    63 static inline uhci_t * dev_to_uhci(ddf_dev_t *dev)
    64 {
    65         assert(dev);
    66         assert(dev->driver_data);
    67         return dev->driver_data;
    68 }
    69 /*----------------------------------------------------------------------------*/
    7046/** IRQ handling callback, forward status from call to diver structure.
    7147 *
     
    9369{
    9470        assert(fun);
    95         usb_device_keeper_t *manager = &dev_to_uhci(fun->dev)->hc.manager;
     71        usb_device_keeper_t *manager =
     72            &((uhci_t*)fun->dev->driver_data)->hc.manager;
     73
    9674        usb_address_t addr = usb_device_keeper_find(manager, handle);
    97 
    9875        if (addr < 0) {
    9976                return addr;
     
    11693    ddf_fun_t *fun, devman_handle_t *handle)
    11794{
    118         assert(fun);
    119         ddf_fun_t *hc_fun = dev_to_uhci(fun->dev)->hc_fun;
    120         assert(hc_fun);
    121 
    122         if (handle != NULL)
    123                 *handle = hc_fun->handle;
     95        assert(handle);
     96        ddf_fun_t *hc_fun = ((uhci_t*)fun->dev->driver_data)->hc_fun;
     97        assert(hc_fun != NULL);
     98
     99        *handle = hc_fun->handle;
    124100        return EOK;
    125101}
     
    150126static hw_res_ops_t hw_res_iface = {
    151127        .get_resource_list = get_resource_list,
    152         .enable_interrupt = NULL,
     128        .enable_interrupt = NULL
    153129};
    154130/*----------------------------------------------------------------------------*/
     
    170146 *  - registers interrupt handler
    171147 */
    172 int device_setup_uhci(ddf_dev_t *device)
    173 {
    174         assert(device);
    175         uhci_t *instance = malloc(sizeof(uhci_t));
    176         if (instance == NULL) {
    177                 usb_log_error("Failed to allocate OHCI driver.\n");
    178                 return ENOMEM;
    179         }
    180 
    181 #define CHECK_RET_DEST_FREE_RETURN(ret, message...) \
     148int uhci_init(uhci_t *instance, ddf_dev_t *device)
     149{
     150        assert(instance);
     151        instance->hc_fun = NULL;
     152        instance->rh_fun = NULL;
     153#define CHECK_RET_DEST_FUN_RETURN(ret, message...) \
    182154if (ret != EOK) { \
     155        usb_log_error(message); \
    183156        if (instance->hc_fun) \
    184                 instance->hc_fun->ops = NULL; \
    185                 instance->hc_fun->driver_data = NULL; \
    186157                ddf_fun_destroy(instance->hc_fun); \
    187         if (instance->rh_fun) {\
    188                 instance->rh_fun->ops = NULL; \
    189                 instance->rh_fun->driver_data = NULL; \
     158        if (instance->rh_fun) \
    190159                ddf_fun_destroy(instance->rh_fun); \
    191         } \
    192         free(instance); \
    193         usb_log_error(message); \
    194160        return ret; \
    195 } else (void)0
    196 
    197         instance->rh_fun = NULL;
    198         instance->hc_fun = ddf_fun_create(device, fun_exposed, "uhci-hc");
    199         int ret = (instance->hc_fun == NULL) ? ENOMEM : EOK;
    200         CHECK_RET_DEST_FREE_RETURN(ret, "Failed to create UHCI HC function.\n");
    201         instance->hc_fun->ops = &hc_ops;
    202         instance->hc_fun->driver_data = &instance->hc;
    203 
    204         instance->rh_fun = ddf_fun_create(device, fun_inner, "uhci-rh");
    205         ret = (instance->rh_fun == NULL) ? ENOMEM : EOK;
    206         CHECK_RET_DEST_FREE_RETURN(ret, "Failed to create UHCI RH function.\n");
    207         instance->rh_fun->ops = &rh_ops;
    208         instance->rh_fun->driver_data = &instance->rh;
    209 
    210         uintptr_t reg_base = 0;
    211         size_t reg_size = 0;
     161}
     162
     163        uintptr_t io_reg_base = 0;
     164        size_t io_reg_size = 0;
    212165        int irq = 0;
    213166
    214         ret = pci_get_my_registers(device, &reg_base, &reg_size, &irq);
    215         CHECK_RET_DEST_FREE_RETURN(ret,
     167        int ret =
     168            pci_get_my_registers(device, &io_reg_base, &io_reg_size, &irq);
     169        CHECK_RET_DEST_FUN_RETURN(ret,
    216170            "Failed to get I/O addresses for %" PRIun ": %s.\n",
    217171            device->handle, str_error(ret));
    218172        usb_log_debug("I/O regs at 0x%p (size %zu), IRQ %d.\n",
    219             (void *) reg_base, reg_size, irq);
     173            (void *) io_reg_base, io_reg_size, irq);
    220174
    221175        ret = pci_disable_legacy(device);
    222         CHECK_RET_DEST_FREE_RETURN(ret,
     176        CHECK_RET_DEST_FUN_RETURN(ret,
    223177            "Failed(%d) to disable legacy USB: %s.\n", ret, str_error(ret));
    224178
     
    240194#endif
    241195
    242 
    243         ret = hc_init(&instance->hc, (void*)reg_base, reg_size, interrupts);
    244         CHECK_RET_DEST_FREE_RETURN(ret,
     196        instance->hc_fun = ddf_fun_create(device, fun_exposed, "uhci-hc");
     197        ret = (instance->hc_fun == NULL) ? ENOMEM : EOK;
     198        CHECK_RET_DEST_FUN_RETURN(ret,
     199            "Failed(%d) to create HC function: %s.\n", ret, str_error(ret));
     200
     201        ret = hc_init(&instance->hc, instance->hc_fun,
     202            (void*)io_reg_base, io_reg_size, interrupts);
     203        CHECK_RET_DEST_FUN_RETURN(ret,
    245204            "Failed(%d) to init uhci-hcd: %s.\n", ret, str_error(ret));
     205
     206        instance->hc_fun->ops = &hc_ops;
     207        instance->hc_fun->driver_data = &instance->hc;
     208        ret = ddf_fun_bind(instance->hc_fun);
     209        CHECK_RET_DEST_FUN_RETURN(ret,
     210            "Failed(%d) to bind UHCI device function: %s.\n",
     211            ret, str_error(ret));
     212        ret = ddf_fun_add_to_class(instance->hc_fun, USB_HC_DDF_CLASS_NAME);
     213        CHECK_RET_DEST_FUN_RETURN(ret,
     214            "Failed to add UHCI to HC class: %s.\n", str_error(ret));
     215
     216#undef CHECK_RET_HC_RETURN
    246217
    247218#define CHECK_RET_FINI_RETURN(ret, message...) \
    248219if (ret != EOK) { \
     220        usb_log_error(message); \
     221        if (instance->hc_fun) \
     222                ddf_fun_destroy(instance->hc_fun); \
     223        if (instance->rh_fun) \
     224                ddf_fun_destroy(instance->rh_fun); \
    249225        hc_fini(&instance->hc); \
    250         CHECK_RET_DEST_FREE_RETURN(ret, message); \
    251226        return ret; \
    252 } else (void)0
     227}
    253228
    254229        /* It does no harm if we register this on polling */
     
    259234            ret, str_error(ret));
    260235
    261         ret = ddf_fun_bind(instance->hc_fun);
    262         CHECK_RET_FINI_RETURN(ret,
    263             "Failed(%d) to bind UHCI device function: %s.\n",
     236        instance->rh_fun = ddf_fun_create(device, fun_inner, "uhci-rh");
     237        ret = (instance->rh_fun == NULL) ? ENOMEM : EOK;
     238        CHECK_RET_FINI_RETURN(ret,
     239            "Failed(%d) to create root hub function: %s.\n",
    264240            ret, str_error(ret));
    265 
    266         ret = ddf_fun_add_to_class(instance->hc_fun, USB_HC_DDF_CLASS_NAME);
    267         CHECK_RET_FINI_RETURN(ret,
    268             "Failed to add UHCI to HC class: %s.\n", str_error(ret));
    269241
    270242        ret = rh_init(&instance->rh, instance->rh_fun,
     
    273245            "Failed(%d) to setup UHCI root hub: %s.\n", ret, str_error(ret));
    274246
     247        instance->rh_fun->ops = &rh_ops;
     248        instance->rh_fun->driver_data = &instance->rh;
    275249        ret = ddf_fun_bind(instance->rh_fun);
    276250        CHECK_RET_FINI_RETURN(ret,
    277251            "Failed(%d) to register UHCI root hub: %s.\n", ret, str_error(ret));
    278252
    279         device->driver_data = instance;
    280253        return EOK;
    281254#undef CHECK_RET_FINI_RETURN
  • uspace/drv/uhci-hcd/uhci.h

    r7b6f116 r5dfee52  
    3838#include <ddf/driver.h>
    3939
    40 int device_setup_uhci(ddf_dev_t *device);
     40#include "hc.h"
     41#include "root_hub.h"
     42
     43/** Structure representing both functions of UHCI hc, USB host controller
     44 * and USB root hub */
     45typedef struct uhci {
     46        /** Pointer to DDF represenation of UHCI host controller */
     47        ddf_fun_t *hc_fun;
     48        /** Pointer to DDF represenation of UHCI root hub */
     49        ddf_fun_t *rh_fun;
     50
     51        /** Internal driver's represenation of UHCI host controller */
     52        hc_t hc;
     53        /** Internal driver's represenation of UHCI root hub */
     54        rh_t rh;
     55} uhci_t;
     56
     57int uhci_init(uhci_t *instance, ddf_dev_t *device);
    4158#endif
    4259/**
Note: See TracChangeset for help on using the changeset viewer.