Changes in uspace/drv/bus/usb/uhci/uhci.c [56fd7cf:795448f] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/uhci/uhci.c
r56fd7cf r795448f 33 33 * @brief UHCI driver 34 34 */ 35 36 /* XXX Fix this */37 #define _DDF_DATA_IMPLANT38 39 35 #include <errno.h> 40 36 #include <str_error.h> … … 64 60 } uhci_t; 65 61 66 static inline uhci_t *dev_to_uhci(ddf_dev_t *dev) 67 { 68 return ddf_dev_data_get(dev); 69 } 70 62 static inline uhci_t * dev_to_uhci(const ddf_dev_t *dev) 63 { 64 assert(dev); 65 return dev->driver_data; 66 } 67 /*----------------------------------------------------------------------------*/ 71 68 /** IRQ handling callback, forward status from call to diver structure. 72 69 * … … 86 83 hc_interrupt(&uhci->hc, status); 87 84 } 88 85 /*----------------------------------------------------------------------------*/ 89 86 /** Operations supported by the HC driver */ 90 87 static ddf_dev_ops_t hc_ops = { 91 88 .interfaces[USBHC_DEV_IFACE] = &hcd_iface, /* see iface.h/c */ 92 89 }; 93 90 /*----------------------------------------------------------------------------*/ 94 91 /** Gets handle of the respective hc. 95 92 * … … 100 97 static int usb_iface_get_hc_handle(ddf_fun_t *fun, devman_handle_t *handle) 101 98 { 102 ddf_fun_t *hc_fun = dev_to_uhci(ddf_fun_get_dev(fun))->hc_fun; 99 assert(fun); 100 ddf_fun_t *hc_fun = dev_to_uhci(fun->dev)->hc_fun; 103 101 assert(hc_fun); 104 102 105 103 if (handle != NULL) 106 *handle = ddf_fun_get_handle(hc_fun);104 *handle = hc_fun->handle; 107 105 return EOK; 108 106 } 109 107 /*----------------------------------------------------------------------------*/ 110 108 /** USB interface implementation used by RH */ 111 109 static usb_iface_t usb_iface = { 112 110 .get_hc_handle = usb_iface_get_hc_handle, 113 111 }; 114 112 /*----------------------------------------------------------------------------*/ 115 113 /** Get root hub hw resources (I/O registers). 116 114 * … … 120 118 static hw_resource_list_t *get_resource_list(ddf_fun_t *fun) 121 119 { 122 rh_t *rh = ddf_fun_data_get(fun); 120 assert(fun); 121 rh_t *rh = fun->driver_data; 123 122 assert(rh); 124 123 return &rh->resource_list; 125 124 } 126 125 /*----------------------------------------------------------------------------*/ 127 126 /** Interface to provide the root hub driver with hw info */ 128 127 static hw_res_ops_t hw_res_iface = { … … 130 129 .enable_interrupt = NULL, 131 130 }; 132 131 /*----------------------------------------------------------------------------*/ 133 132 /** RH function support for uhci_rhd */ 134 133 static ddf_dev_ops_t rh_ops = { … … 136 135 .interfaces[HW_RES_DEV_IFACE] = &hw_res_iface 137 136 }; 138 137 /*----------------------------------------------------------------------------*/ 139 138 /** Initialize hc and rh DDF structures and their respective drivers. 140 139 * … … 161 160 if (ret != EOK) { \ 162 161 if (instance->hc_fun) \ 162 instance->hc_fun->driver_data = NULL; \ 163 163 ddf_fun_destroy(instance->hc_fun); \ 164 164 if (instance->rh_fun) {\ 165 instance->rh_fun->driver_data = NULL; \ 165 166 ddf_fun_destroy(instance->rh_fun); \ 166 167 } \ … … 173 174 int ret = (instance->hc_fun == NULL) ? ENOMEM : EOK; 174 175 CHECK_RET_DEST_FREE_RETURN(ret, "Failed to create UHCI HC function.\n"); 175 ddf_fun_set_ops(instance->hc_fun, &hc_ops);176 ddf_fun_data_implant(instance->hc_fun, &instance->hc.generic);176 instance->hc_fun->ops = &hc_ops; 177 instance->hc_fun->driver_data = &instance->hc.generic; 177 178 178 179 instance->rh_fun = ddf_fun_create(device, fun_inner, "uhci_rh"); 179 180 ret = (instance->rh_fun == NULL) ? ENOMEM : EOK; 180 181 CHECK_RET_DEST_FREE_RETURN(ret, "Failed to create UHCI RH function.\n"); 181 ddf_fun_set_ops(instance->rh_fun, &rh_ops);182 ddf_fun_data_implant(instance->rh_fun, &instance->rh);182 instance->rh_fun->ops = &rh_ops; 183 instance->rh_fun->driver_data = &instance->rh; 183 184 184 185 uintptr_t reg_base = 0; … … 189 190 CHECK_RET_DEST_FREE_RETURN(ret, 190 191 "Failed to get I/O addresses for %" PRIun ": %s.\n", 191 d df_dev_get_handle(device), str_error(ret));192 device->handle, str_error(ret)); 192 193 usb_log_debug("I/O regs at 0x%p (size %zu), IRQ %d.\n", 193 194 (void *) reg_base, reg_size, irq);
Note:
See TracChangeset
for help on using the changeset viewer.