Ignore:
File:
1 edited

Legend:

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

    r7de1988c r920d0fc  
    4848#define NAME "uhcirh"
    4949
    50 static int hc_get_my_registers(ddf_dev_t *dev, addr_range_t *io_regs);
     50static int hc_get_my_registers(ddf_dev_t *dev,
     51    uintptr_t *io_reg_address, size_t *io_reg_size);
    5152
    5253static int uhci_rh_dev_add(ddf_dev_t *device);
     
    8990            ddf_dev_get_handle(device));
    9091
    91         addr_range_t regs;
     92        uintptr_t io_regs = 0;
     93        size_t io_size = 0;
    9294        uhci_root_hub_t *rh = NULL;
    93         int rc;
     95        int ret = EOK;
    9496
    95         rc = hc_get_my_registers(device, &regs);
    96         if (rc != EOK) {
    97                 usb_log_error( "Failed to get registers from HC: %s.\n",
    98                     str_error(rc));
    99                 return rc;
    100         }
     97#define CHECK_RET_FREE_RH_RETURN(ret, message...) \
     98if (ret != EOK) { \
     99        usb_log_error(message); \
     100        return ret; \
     101} else (void)0
    101102
     103        ret = hc_get_my_registers(device, &io_regs, &io_size);
     104        CHECK_RET_FREE_RH_RETURN(ret,
     105            "Failed to get registers from HC: %s.\n", str_error(ret));
    102106        usb_log_debug("I/O regs at %p (size %zuB).\n",
    103             RNGABSPTR(regs), RNGSZ(regs));
     107            (void *) io_regs, io_size);
    104108
    105109        rh = ddf_dev_data_alloc(device, sizeof(uhci_root_hub_t));
    106         if (rh == NULL) {
    107                 usb_log_error("Failed to allocate rh driver instance.\n");
    108                 return ENOMEM;
    109         }
     110        ret = (rh == NULL) ? ENOMEM : EOK;
     111        CHECK_RET_FREE_RH_RETURN(ret,
     112            "Failed to allocate rh driver instance.\n");
    110113
    111         rc = uhci_root_hub_init(rh, &regs, device);
    112         if (rc != EOK) {
    113                 usb_log_error("Failed(%d) to initialize rh driver instance: "
    114                     "%s.\n", rc, str_error(rc));
    115                 return rc;
    116         }
     114        ret = uhci_root_hub_init(rh, (void*)io_regs, io_size, device);
     115        CHECK_RET_FREE_RH_RETURN(ret,
     116            "Failed(%d) to initialize rh driver instance: %s.\n",
     117            ret, str_error(ret));
    117118
    118119        usb_log_info("Controlling root hub '%s' (%" PRIun ").\n",
    119120            ddf_dev_get_name(device), ddf_dev_get_handle(device));
    120 
    121121        return EOK;
    122122}
     
    125125 *
    126126 * @param[in] dev Device asking for the addresses.
    127  * @param[out] io_regs_p Pointer to the device's register range.
     127 * @param[out] io_reg_address Base address of the memory range.
     128 * @param[out] io_reg_size Size of the memory range.
    128129 * @return Error code.
    129130 */
    130 int hc_get_my_registers(ddf_dev_t *dev, addr_range_t *io_regs_p)
     131int hc_get_my_registers(
     132    ddf_dev_t *dev, uintptr_t *io_reg_address, size_t *io_reg_size)
    131133{
    132134        async_sess_t *parent_sess =
     
    149151        }
    150152
    151         if (io_regs_p != NULL)
    152                 *io_regs_p = hw_res.io_ranges.ranges[0];
     153        if (io_reg_address != NULL)
     154                *io_reg_address = hw_res.io_ranges.ranges[0].address;
     155
     156        if (io_reg_size != NULL)
     157                *io_reg_size = hw_res.io_ranges.ranges[0].size;
    153158
    154159        hw_res_list_parsed_clean(&hw_res);
Note: See TracChangeset for help on using the changeset viewer.