Changeset 2f87aa6 in mainline


Ignore:
Timestamp:
2012-12-14T20:57:39Z (11 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f29931c
Parents:
5df69cb
Message:

ohci: minor cleanup, don't implant data

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

Legend:

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

    r5df69cb r2f87aa6  
    3434 */
    3535
    36 /* XXX Fix this */
    37 #define _DDF_DATA_IMPLANT
    38 
    3936#include <errno.h>
    4037#include <str_error.h>
     
    5249        ddf_fun_t *hc_fun;
    5350        ddf_fun_t *rh_fun;
    54 
    55         hc_t hc;
    5651} ohci_t;
    5752
     
    6055        return ddf_dev_data_get(dev);
    6156}
     57
    6258/** IRQ handling callback, identifies device
    6359 *
     
    7571                return;
    7672        }
     73        hc_t *hc = ddf_fun_data_get(ohci->hc_fun);
     74        assert(hc);
     75
    7776        const uint16_t status = IPC_GET_ARG1(*call);
    78         hc_interrupt(&ohci->hc, status);
     77        hc_interrupt(hc, status);
    7978}
    8079
     
    9089
    9190        if (address != NULL) {
    92                 *address = dev_to_ohci(ddf_fun_get_dev(fun))->hc.rh.address;
     91                hc_t *hc =
     92                    ddf_fun_data_get(dev_to_ohci(ddf_fun_get_dev(fun))->hc_fun);
     93                assert(hc);
     94                *address = hc->rh.address;
    9395        }
    9496
     
    102104 * @return Error code.
    103105 */
    104 static int rh_get_hc_handle(
    105     ddf_fun_t *fun, devman_handle_t *handle)
     106static int rh_get_hc_handle(ddf_fun_t *fun, devman_handle_t *handle)
    106107{
    107108        assert(fun);
    108         ddf_fun_t *hc_fun = dev_to_ohci(ddf_fun_get_dev(fun))->hc_fun;
    109         assert(hc_fun);
    110 
    111         if (handle != NULL)
     109
     110        if (handle != NULL) {
     111                ddf_fun_t *hc_fun = dev_to_ohci(ddf_fun_get_dev(fun))->hc_fun;
     112                assert(hc_fun);
    112113                *handle = ddf_fun_get_handle(hc_fun);
     114        }
    113115        return EOK;
    114116}
     
    146148                return EBADMEM;
    147149
    148         ohci_t *instance = ddf_dev_data_alloc(device,sizeof(ohci_t));
     150        ohci_t *instance = ddf_dev_data_alloc(device, sizeof(ohci_t));
    149151        if (instance == NULL) {
    150152                usb_log_error("Failed to allocate OHCI driver.\n");
     
    169171            "Failed to create OHCI HC function: %s.\n", str_error(ret));
    170172        ddf_fun_set_ops(instance->hc_fun, &hc_ops);
    171         ddf_fun_data_implant(instance->hc_fun, &instance->hc);
     173        hc_t *hc = ddf_fun_data_alloc(instance->hc_fun, sizeof(hc_t));
     174        ret = hc ? EOK : ENOMEM;
     175        CHECK_RET_DEST_FREE_RETURN(ret,
     176            "Failed to allocate HCD structure: %s.\n", str_error(ret));
    172177
    173178        instance->rh_fun = ddf_fun_create(device, fun_inner, "ohci_rh");
     
    223228        }
    224229
    225         ret = hc_init(&instance->hc, reg_base, reg_size, interrupts);
     230        ret = hc_init(hc, reg_base, reg_size, interrupts);
    226231        CHECK_RET_DEST_FREE_RETURN(ret,
    227232            "Failed to init ohci_hcd: %s.\n", str_error(ret));
     
    229234#define CHECK_RET_FINI_RETURN(ret, message...) \
    230235if (ret != EOK) { \
    231         hc_fini(&instance->hc); \
     236        hc_fini(hc); \
    232237        unregister_interrupt_handler(device, irq); \
    233238        CHECK_RET_DEST_FREE_RETURN(ret, message); \
     
    243248            "Failed to add OHCI to HC class: %s.\n", str_error(ret));
    244249
    245         ret = hc_register_hub(&instance->hc, instance->rh_fun);
     250        ret = hc_register_hub(hc, instance->rh_fun);
    246251        CHECK_RET_FINI_RETURN(ret,
    247252            "Failed to register OHCI root hub: %s.\n", str_error(ret));
  • uspace/drv/bus/usb/ohci/ohci.h

    r5df69cb r2f87aa6  
    3434#ifndef DRV_OHCI_OHCI_H
    3535#define DRV_OHCI_OHCI_H
    36 #include <ddi.h>
    3736#include <ddf/driver.h>
    3837
Note: See TracChangeset for help on using the changeset viewer.