Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/uhcirh/main.c

    r89e061d rc53007f  
    4848#define NAME "uhcirh"
    4949
    50 static int hc_get_my_registers(const ddf_dev_t *dev,
     50static int hc_get_my_registers(ddf_dev_t *dev,
    5151    uintptr_t *io_reg_address, size_t *io_reg_size);
    5252
     
    7373{
    7474        printf(NAME ": HelenOS UHCI root hub driver.\n");
    75         usb_log_enable(USB_LOG_LEVEL_DEFAULT, NAME);
     75        log_init(NAME);
    7676        return ddf_driver_main(&uhci_rh_driver);
    7777}
     
    8888
    8989        usb_log_debug2("uhci_rh_dev_add(handle=%" PRIun ")\n",
    90             device->handle);
     90            ddf_dev_get_handle(device));
    9191
    9292        uintptr_t io_regs = 0;
    9393        size_t io_size = 0;
    9494        uhci_root_hub_t *rh = NULL;
    95         int ret = EOK;
     95        int rc;
    9696
    97 #define CHECK_RET_FREE_RH_RETURN(ret, message...) \
    98 if (ret != EOK) { \
    99         usb_log_error(message); \
    100         if (rh) \
    101                 free(rh); \
    102         return ret; \
    103 } else (void)0
     97        rc = hc_get_my_registers(device, &io_regs, &io_size);
     98        if (rc != EOK) {
     99                usb_log_error( "Failed to get registers from HC: %s.\n",
     100                    str_error(rc));
     101                return rc;
     102        }
    104103
    105         ret = hc_get_my_registers(device, &io_regs, &io_size);
    106         CHECK_RET_FREE_RH_RETURN(ret,
    107             "Failed to get registers from HC: %s.\n", str_error(ret));
    108104        usb_log_debug("I/O regs at %p (size %zuB).\n",
    109105            (void *) io_regs, io_size);
    110106
    111         rh = malloc(sizeof(uhci_root_hub_t));
    112         ret = (rh == NULL) ? ENOMEM : EOK;
    113         CHECK_RET_FREE_RH_RETURN(ret,
    114             "Failed to allocate rh driver instance.\n");
     107        rh = ddf_dev_data_alloc(device, sizeof(uhci_root_hub_t));
     108        if (rh == NULL) {
     109                usb_log_error("Failed to allocate rh driver instance.\n");
     110                return ENOMEM;
     111        }
    115112
    116         ret = uhci_root_hub_init(rh, (void*)io_regs, io_size, device);
    117         CHECK_RET_FREE_RH_RETURN(ret,
    118             "Failed(%d) to initialize rh driver instance: %s.\n",
    119             ret, str_error(ret));
     113        rc = uhci_root_hub_init(rh, (void*)io_regs, io_size, device);
     114        if (rc != EOK) {
     115                usb_log_error("Failed(%d) to initialize rh driver instance: "
     116                    "%s.\n", rc, str_error(rc));
     117                return rc;
     118        }
    120119
    121         device->driver_data = rh;
    122120        usb_log_info("Controlling root hub '%s' (%" PRIun ").\n",
    123             device->name, device->handle);
     121            ddf_dev_get_name(device), ddf_dev_get_handle(device));
     122
    124123        return EOK;
    125124}
     
    133132 */
    134133int hc_get_my_registers(
    135     const ddf_dev_t *dev, uintptr_t *io_reg_address, size_t *io_reg_size)
     134    ddf_dev_t *dev, uintptr_t *io_reg_address, size_t *io_reg_size)
    136135{
    137         assert(dev);
    138 
    139136        async_sess_t *parent_sess =
    140             devman_parent_device_connect(EXCHANGE_SERIALIZE, dev->handle,
    141             IPC_FLAG_BLOCKING);
     137            devman_parent_device_connect(EXCHANGE_SERIALIZE,
     138            ddf_dev_get_handle(dev), IPC_FLAG_BLOCKING);
    142139        if (!parent_sess)
    143140                return ENOMEM;
Note: See TracChangeset for help on using the changeset viewer.