Changeset f51587f5 in mainline


Ignore:
Timestamp:
2012-12-16T17:17:37Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
395bb79
Parents:
8de2cca
Message:

ohci: Move generic hcd initialization out of device hc init.

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

Legend:

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

    r8de2cca rf51587f5  
    8888static int hc_init_memory(hc_t *instance);
    8989static int interrupt_emulator(hc_t *instance);
    90 static int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);
    9190
    9291/** Get number of PIO ranges used in IRQ code.
     
    161160
    162161        list_initialize(&instance->pending_batches);
    163 
    164         hcd_init(&instance->generic, USB_SPEED_FULL,
    165             BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
    166         instance->generic.private_data = instance;
    167         instance->generic.schedule = hc_schedule;
    168         instance->generic.ep_add_hook = ohci_endpoint_init;
    169         instance->generic.ep_remove_hook = ohci_endpoint_fini;
    170162
    171163        ret = hc_init_memory(instance);
  • uspace/drv/bus/usb/ohci/hc.h

    r8de2cca rf51587f5  
    8989void hc_enqueue_endpoint(hc_t *instance, const endpoint_t *ep);
    9090void hc_dequeue_endpoint(hc_t *instance, const endpoint_t *ep);
     91int hc_schedule(hcd_t *hcd, usb_transfer_batch_t *batch);
    9192
    9293void hc_interrupt(hc_t *instance, uint32_t status);
  • uspace/drv/bus/usb/ohci/ohci.c

    r8de2cca rf51587f5  
    5656}
    5757
     58static inline hcd_t *dev_to_hcd(ddf_dev_t *dev)
     59{
     60        ohci_t *ohci = dev_to_ohci(dev);
     61        if (!ohci || !ohci->hc_fun) {
     62                usb_log_error("Invalid OHCI device.\n");
     63                return NULL;
     64        }
     65        return ddf_fun_data_get(ohci->hc_fun);
     66}
     67
     68static inline hc_t * dev_to_hc(ddf_dev_t *dev)
     69{
     70        hcd_t *hcd = dev_to_hcd(dev);
     71        if (!hcd) {
     72                usb_log_error("Invalid OHCI HCD");
     73                return NULL;
     74        }
     75        return hcd->private_data;
     76}
     77
    5878/** IRQ handling callback, identifies device
    5979 *
     
    6585{
    6686        assert(dev);
    67 
    68         ohci_t *ohci = dev_to_ohci(dev);
    69         if (!ohci) {
     87        hc_t *hc = dev_to_hc(dev);
     88        if (!hc) {
    7089                usb_log_warning("Interrupt on device that is not ready.\n");
    7190                return;
    7291        }
    73         hc_t *hc = ddf_fun_data_get(ohci->hc_fun);
    74         assert(hc);
    7592
    7693        const uint16_t status = IPC_GET_ARG1(*call);
     
    89106
    90107        if (address != NULL) {
    91                 hc_t *hc =
    92                     ddf_fun_data_get(dev_to_ohci(ddf_fun_get_dev(fun))->hc_fun);
     108                hc_t *hc = dev_to_hc(ddf_fun_get_dev(fun));
    93109                assert(hc);
    94110                *address = hc->rh.address;
     
    176192            "Failed to allocate HCD structure: %s.\n", str_error(ret));
    177193
     194        hcd_init(&hc->generic, USB_SPEED_FULL,
     195            BANDWIDTH_AVAILABLE_USB11, bandwidth_count_usb11);
     196
    178197        instance->rh_fun = ddf_fun_create(device, fun_inner, "ohci_rh");
    179198        ret = instance->rh_fun ? EOK : ENOMEM;
     
    232251            "Failed to init ohci_hcd: %s.\n", str_error(ret));
    233252
     253        hcd_set_implementation(&hc->generic, hc, hc_schedule,
     254            ohci_endpoint_init, ohci_endpoint_fini);
     255
    234256#define CHECK_RET_FINI_RETURN(ret, message...) \
    235257if (ret != EOK) { \
Note: See TracChangeset for help on using the changeset viewer.