Changeset 395bb79 in mainline


Ignore:
Timestamp:
2012-12-16T18:17:20Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4bfe063
Parents:
f51587f5
Message:

ohci: Decouple OHCI from generic hcd.

Location:
uspace/drv/bus/usb/ohci
Files:
2 edited

Legend:

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

    rf51587f5 r395bb79  
    5151/** Main OHCI driver structure */
    5252typedef struct hc {
    53         /** Generic USB hc driver */
    54         hcd_t generic;
    55 
    5653        /** Memory mapped I/O registers area */
    5754        ohci_regs_t *registers;
  • uspace/drv/bus/usb/ohci/ohci.c

    rf51587f5 r395bb79  
    187187            "Failed to create OHCI HC function: %s.\n", str_error(ret));
    188188        ddf_fun_set_ops(instance->hc_fun, &hc_ops);
    189         hc_t *hc = ddf_fun_data_alloc(instance->hc_fun, sizeof(hc_t));
    190         ret = hc ? EOK : ENOMEM;
     189        hcd_t *hcd = ddf_fun_data_alloc(instance->hc_fun, sizeof(hcd_t));
     190        ret = hcd ? EOK : ENOMEM;
    191191        CHECK_RET_DEST_FREE_RETURN(ret,
    192192            "Failed to allocate HCD structure: %s.\n", str_error(ret));
    193193
    194         hcd_init(&hc->generic, USB_SPEED_FULL,
    195             BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
     194        hcd_init(hcd, USB_SPEED_FULL, BANDWIDTH_AVAILABLE_USB11,
     195            bandwidth_count_usb11);
     196
     197        ret = ddf_fun_bind(instance->hc_fun);
     198        CHECK_RET_DEST_FREE_RETURN(ret,
     199            "Failed to bind OHCI device function: %s.\n", str_error(ret));
     200
     201        ret = ddf_fun_add_to_category(instance->hc_fun, USB_HC_CATEGORY);
     202        CHECK_RET_DEST_FREE_RETURN(ret,
     203            "Failed to add OHCI to HC class: %s.\n", str_error(ret));
     204
     205        /* HC should be ok at this point (except it can't do anything) */
    196206
    197207        instance->rh_fun = ddf_fun_create(device, fun_inner, "ohci_rh");
     
    227237        CHECK_RET_DEST_FREE_RETURN(ret,
    228238            "Failed to generate IRQ code: %s.\n", str_error(ret));
    229 
    230239
    231240        /* Register handler to avoid interrupt lockup */
     
    247256        }
    248257
    249         ret = hc_init(hc, reg_base, reg_size, interrupts);
     258        hc_t *hc_impl = malloc(sizeof(hc_t));
     259        assert(hc_impl);
     260
     261        ret = hc_init(hc_impl, reg_base, reg_size, interrupts);
    250262        CHECK_RET_DEST_FREE_RETURN(ret,
    251263            "Failed to init ohci_hcd: %s.\n", str_error(ret));
    252264
    253         hcd_set_implementation(&hc->generic, hc, hc_schedule,
     265        hcd_set_implementation(hcd, hc_impl, hc_schedule,
    254266            ohci_endpoint_init, ohci_endpoint_fini);
    255267
    256268#define CHECK_RET_FINI_RETURN(ret, message...) \
    257269if (ret != EOK) { \
    258         hc_fini(hc); \
     270        hc_fini(hc_impl); \
    259271        unregister_interrupt_handler(device, irq); \
    260272        CHECK_RET_DEST_FREE_RETURN(ret, message); \
    261273} else (void)0
    262274
    263 
    264         ret = ddf_fun_bind(instance->hc_fun);
    265         CHECK_RET_FINI_RETURN(ret,
    266             "Failed to bind OHCI device function: %s.\n", str_error(ret));
    267 
    268         ret = ddf_fun_add_to_category(instance->hc_fun, USB_HC_CATEGORY);
    269         CHECK_RET_FINI_RETURN(ret,
    270             "Failed to add OHCI to HC class: %s.\n", str_error(ret));
    271 
    272         ret = hcd_register_hub(&hc->generic, &hc->rh.address, instance->rh_fun);
     275        ret = hcd_register_hub(hcd, &hc_impl->rh.address, instance->rh_fun);
    273276        CHECK_RET_FINI_RETURN(ret,
    274277            "Failed to register OHCI root hub: %s.\n", str_error(ret));
Note: See TracChangeset for help on using the changeset viewer.