Changes in uspace/drv/bus/usb/uhci/uhci.c [d57122c:1dc4a5e] in mainline
- File:
-
- 1 edited
-
uspace/drv/bus/usb/uhci/uhci.c (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhci/uhci.c
rd57122c r1dc4a5e 41 41 42 42 #include "uhci.h" 43 #include "iface.h" 43 44 #include "pci.h" 44 45 … … 86 87 /** Operations supported by the HC driver */ 87 88 static ddf_dev_ops_t hc_ops = { 88 .interfaces[USBHC_DEV_IFACE] = &hcd_iface, /* see iface.h/c */ 89 }; 89 .interfaces[USBHC_DEV_IFACE] = &hc_iface, /* see iface.h/c */ 90 }; 91 /*----------------------------------------------------------------------------*/ 92 /** Get address of the device identified by handle. 93 * 94 * @param[in] fun DDF instance of the function to use. 95 * @param[in] handle DDF handle of the driver seeking its USB address. 96 * @param[out] address Found address. 97 */ 98 static int usb_iface_get_address( 99 ddf_fun_t *fun, devman_handle_t handle, usb_address_t *address) 100 { 101 assert(fun); 102 usb_device_keeper_t *manager = &dev_to_uhci(fun->dev)->hc.manager; 103 usb_address_t addr = usb_device_keeper_find(manager, handle); 104 105 if (addr < 0) { 106 return addr; 107 } 108 109 if (address != NULL) { 110 *address = addr; 111 } 112 113 return EOK; 114 } 90 115 /*----------------------------------------------------------------------------*/ 91 116 /** Gets handle of the respective hc. … … 109 134 static usb_iface_t usb_iface = { 110 135 .get_hc_handle = usb_iface_get_hc_handle, 136 .get_address = usb_iface_get_address 111 137 }; 112 138 /*----------------------------------------------------------------------------*/ … … 148 174 int device_setup_uhci(ddf_dev_t *device) 149 175 { 150 if (!device) 151 return EBADMEM; 152 153 uhci_t *instance = ddf_dev_data_alloc(device, sizeof(uhci_t)); 176 assert(device); 177 uhci_t *instance = malloc(sizeof(uhci_t)); 154 178 if (instance == NULL) { 155 179 usb_log_error("Failed to allocate OHCI driver.\n"); … … 160 184 if (ret != EOK) { \ 161 185 if (instance->hc_fun) \ 186 instance->hc_fun->ops = NULL; \ 162 187 instance->hc_fun->driver_data = NULL; \ 163 188 ddf_fun_destroy(instance->hc_fun); \ 164 189 if (instance->rh_fun) {\ 190 instance->rh_fun->ops = NULL; \ 165 191 instance->rh_fun->driver_data = NULL; \ 166 192 ddf_fun_destroy(instance->rh_fun); \ 167 193 } \ 194 free(instance); \ 195 device->driver_data = NULL; \ 168 196 usb_log_error(message); \ 169 197 return ret; \ … … 175 203 CHECK_RET_DEST_FREE_RETURN(ret, "Failed to create UHCI HC function.\n"); 176 204 instance->hc_fun->ops = &hc_ops; 177 instance->hc_fun->driver_data = &instance->hc .generic;205 instance->hc_fun->driver_data = &instance->hc; 178 206 179 207 instance->rh_fun = ddf_fun_create(device, fun_inner, "uhci_rh"); … … 198 226 "Failed to disable legacy USB: %s.\n", str_error(ret)); 199 227 200 const size_t ranges_count = hc_irq_pio_range_count(); 201 const size_t cmds_count = hc_irq_cmd_count(); 202 irq_pio_range_t irq_ranges[ranges_count]; 203 irq_cmd_t irq_cmds[cmds_count]; 204 ret = hc_get_irq_code(irq_ranges, sizeof(irq_ranges), irq_cmds, 205 sizeof(irq_cmds), reg_base, reg_size); 228 const size_t cmd_count = hc_irq_cmd_count(); 229 irq_cmd_t irq_cmds[cmd_count]; 230 ret = 231 hc_get_irq_commands(irq_cmds, sizeof(irq_cmds), reg_base, reg_size); 206 232 CHECK_RET_DEST_FREE_RETURN(ret, 207 233 "Failed to generate IRQ commands: %s.\n", str_error(ret)); 208 234 209 irq_code_t irq_code = { 210 .rangecount = ranges_count, 211 .ranges = irq_ranges, 212 .cmdcount = cmds_count, 213 .cmds = irq_cmds 214 }; 235 irq_code_t irq_code = { .cmdcount = cmd_count, .cmds = irq_cmds }; 215 236 216 237 /* Register handler to avoid interrupt lockup */ … … 233 254 "Failed to init uhci_hcd: %s.\n", str_error(ret)); 234 255 256 device->driver_data = instance; 257 235 258 #define CHECK_RET_FINI_RETURN(ret, message...) \ 236 259 if (ret != EOK) { \
Note:
See TracChangeset
for help on using the changeset viewer.
