Changes in uspace/drv/usbmid/usbmid.c [bc1c6fb:51f0e410] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbmid/usbmid.c
rbc1c6fb r51f0e410 45 45 46 46 /** Callback for DDF USB interface. */ 47 static int usb_iface_get_address_impl(d df_fun_t *fun, devman_handle_t handle,47 static int usb_iface_get_address_impl(device_t *device, devman_handle_t handle, 48 48 usb_address_t *address) 49 49 { 50 return usb_iface_get_address_hub_impl(fun, handle, address); 50 assert(device); 51 device_t *parent = device->parent; 52 53 /* Default error, device does not support this operation. */ 54 int rc = ENOTSUP; 55 56 if (parent && parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) { 57 usb_iface_t *usb_iface 58 = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE]; 59 assert(usb_iface != NULL); 60 61 if (usb_iface->get_address) { 62 rc = usb_iface->get_address(parent, parent->handle, 63 address); 64 } 65 } 66 67 return rc; 51 68 } 52 69 53 70 /** Callback for DDF USB interface. */ 54 static int usb_iface_get_interface_impl(d df_fun_t *fun, devman_handle_t handle,71 static int usb_iface_get_interface_impl(device_t *device, devman_handle_t handle, 55 72 int *iface_no) 56 73 { 57 assert( fun);58 59 usbmid_interface_t *iface = fun->driver_data;74 assert(device); 75 76 usbmid_interface_t *iface = device->driver_data; 60 77 assert(iface); 61 78 … … 67 84 } 68 85 69 /** DDF interface of the child - interface function. */70 86 static usb_iface_t child_usb_iface = { 71 87 .get_hc_handle = usb_iface_get_hc_handle_hub_child_impl, … … 74 90 }; 75 91 76 /** Operations for children - interface functions. */ 77 static d df_dev_ops_t child_device_ops = {92 93 static device_ops_t child_device_ops = { 78 94 .interfaces[USB_DEV_IFACE] = &child_usb_iface 79 95 }; 80 96 81 /** Operations of the device itself. */ 82 static ddf_dev_ops_t mid_device_ops = { 97 static device_ops_t mid_device_ops = { 83 98 .interfaces[USB_DEV_IFACE] = &usb_iface_hub_impl 84 99 }; … … 90 105 * @retval NULL Error occured. 91 106 */ 92 usbmid_device_t *usbmid_device_create(d df_dev_t *dev)107 usbmid_device_t *usbmid_device_create(device_t *dev) 93 108 { 94 109 usbmid_device_t *mid = malloc(sizeof(usbmid_device_t)); … … 118 133 119 134 mid->dev = dev; 120 (void)&mid_device_ops;135 dev->ops = &mid_device_ops; 121 136 122 137 return mid; … … 125 140 /** Create new interface for USB MID device. 126 141 * 127 * @param fun Backing generic DDF device function(representing interface).142 * @param dev Backing generic DDF child device (representing interface). 128 143 * @param iface_no Interface number. 129 144 * @return New interface. 130 145 * @retval NULL Error occured. 131 146 */ 132 usbmid_interface_t *usbmid_interface_create(d df_fun_t *fun, int iface_no)147 usbmid_interface_t *usbmid_interface_create(device_t *dev, int iface_no) 133 148 { 134 149 usbmid_interface_t *iface = malloc(sizeof(usbmid_interface_t)); … … 139 154 } 140 155 141 iface-> fun = fun;156 iface->dev = dev; 142 157 iface->interface_no = iface_no; 143 158 … … 157 172 const usb_standard_interface_descriptor_t *interface_descriptor) 158 173 { 159 d df_fun_t *child = NULL;174 device_t *child = NULL; 160 175 char *child_name = NULL; 161 176 usbmid_interface_t *child_as_interface = NULL; 162 177 int rc; 178 179 /* Create the device. */ 180 child = create_device(); 181 if (child == NULL) { 182 rc = ENOMEM; 183 goto error_leave; 184 } 163 185 164 186 /* … … 174 196 } 175 197 176 /* Create the device. */177 child = ddf_fun_create(parent->dev, fun_inner, child_name);178 if (child == NULL) {179 rc = ENOMEM;180 goto error_leave;181 }182 183 184 185 198 child_as_interface = usbmid_interface_create(child, 186 199 (int) interface_descriptor->interface_number); … … 191 204 192 205 child->driver_data = child_as_interface; 206 child->parent = parent->dev; 207 child->name = child_name; 193 208 child->ops = &child_device_ops; 194 209 … … 200 215 } 201 216 202 rc = ddf_fun_bind(child);217 rc = child_device_register(child, parent->dev); 203 218 if (rc != EOK) { 204 219 goto error_leave; … … 211 226 child->name = NULL; 212 227 /* This takes care of match_id deallocation as well. */ 213 d df_fun_destroy(child);228 delete_device(child); 214 229 } 215 230 if (child_name != NULL) {
Note:
See TracChangeset
for help on using the changeset viewer.