Changes in uspace/drv/bus/usb/usbmid/usbmid.c [56fd7cf:d3a1ad58] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbmid/usbmid.c
r56fd7cf rd3a1ad58 31 31 */ 32 32 33 /* XXX Fix this */34 #define _DDF_DATA_IMPLANT35 36 33 /** 37 34 * @file … … 42 39 #include <stdlib.h> 43 40 #include <usb_iface.h> 44 #include <usb/ddfiface.h>45 41 #include <usb/dev/pipes.h> 46 42 #include <usb/classes/classes.h> 47 43 #include <usb/dev/recognise.h> 48 44 #include "usbmid.h" 45 /** Get host controller handle by calling the parent usb_device_t. 46 * 47 * @param[in] fun Device function the operation is running on. 48 * @param[out] handle Storage for the host controller handle. 49 * @return Error code. 50 */ 51 static int usb_iface_device_hc_handle(ddf_fun_t *fun, devman_handle_t *handle) 52 { 53 assert(handle); 54 assert(fun); 55 usb_device_t *usb_dev = usb_device_get(ddf_fun_get_dev(fun)); 56 assert(usb_dev); 57 *handle = usb_device_hc_handle(usb_dev); 58 return EOK; 59 } 60 61 /** Get USB device address by calling the parent usb_device_t. 62 * 63 * @param[in] fun Device function the operation is running on. 64 * @param[in] handle Devman handle of USB device we want address of. 65 * @param[out] address Storage for USB address of device with handle @p handle. 66 * @return Error code. 67 */ 68 static int usb_iface_device_address(ddf_fun_t *fun, usb_address_t *address) 69 { 70 assert(address); 71 assert(fun); 72 usb_device_t *usb_dev = usb_device_get(ddf_fun_get_dev(fun)); 73 assert(usb_dev); 74 *address = usb_device_address(usb_dev); 75 return EOK; 76 } 49 77 50 78 /** Callback for DDF USB interface. */ 51 static int usb_iface_ get_interface_impl(ddf_fun_t *fun, int *iface_no)79 static int usb_iface_iface(ddf_fun_t *fun, int *iface_no) 52 80 { 53 81 usbmid_interface_t *iface = ddf_fun_data_get(fun); … … 61 89 } 62 90 91 static int usb_iface_register_endpoint(ddf_fun_t *fun, usb_endpoint_t ep, 92 usb_transfer_type_t type, usb_direction_t dir, size_t mps, unsigned inter) 93 { 94 usb_device_t *usb_dev = usb_device_get(ddf_fun_get_dev(fun)); 95 assert(usb_dev); 96 async_exch_t *exch = usb_device_bus_exchange_begin(usb_dev); 97 if (!exch) 98 return ENOMEM; 99 const int ret = usb_register_endpoint(exch, ep, type, dir, mps, inter); 100 usb_device_bus_exchange_end(exch); 101 return ret; 102 } 103 104 static int usb_iface_unregister_endpoint(ddf_fun_t *fun, usb_endpoint_t ep, 105 usb_direction_t dir) 106 { 107 usb_device_t *usb_dev = usb_device_get(ddf_fun_get_dev(fun)); 108 assert(usb_dev); 109 async_exch_t *exch = usb_device_bus_exchange_begin(usb_dev); 110 if (!exch) 111 return ENOMEM; 112 const int ret = usb_unregister_endpoint(exch, ep, dir); 113 usb_device_bus_exchange_end(exch); 114 return ret; 115 } 116 63 117 /** DDF interface of the child - interface function. */ 64 118 static usb_iface_t child_usb_iface = { 65 .get_hc_handle = usb_iface_get_hc_handle_device_impl, 66 .get_my_address = usb_iface_get_my_address_forward_impl, 67 .get_my_interface = usb_iface_get_interface_impl, 119 .get_hc_handle = usb_iface_device_hc_handle, 120 .get_my_address = usb_iface_device_address, 121 .get_my_interface = usb_iface_iface, 122 .register_endpoint = usb_iface_register_endpoint, 123 .unregister_endpoint = usb_iface_unregister_endpoint, 68 124 }; 69 125 … … 81 137 return ret; 82 138 } 83 /* NOTE: usbmid->interface points somewhere, but we did not84 * allocate that space, so don't touch */85 139 ddf_fun_destroy(mid_iface->fun); 86 /* NOTE: mid_iface is invalid at this point, it was assigned to87 * mid_iface->fun->driver_data and freed in ddf_fun_destroy */88 140 return EOK; 89 141 } … … 98 150 */ 99 151 int usbmid_spawn_interface_child(usb_device_t *parent, 100 usbmid_interface_t * iface,152 usbmid_interface_t **iface_ret, 101 153 const usb_standard_device_descriptor_t *device_descriptor, 102 154 const usb_standard_interface_descriptor_t *interface_descriptor) … … 119 171 120 172 /* Create the device. */ 121 child = ddf_fun_create(parent->ddf_dev, fun_inner, child_name);173 child = usb_device_ddf_fun_create(parent, fun_inner, child_name); 122 174 free(child_name); 123 175 if (child == NULL) { … … 145 197 } 146 198 clean_match_ids(&match_ids); 199 ddf_fun_set_ops(child, &child_device_ops); 200 201 usbmid_interface_t *iface = ddf_fun_data_alloc(child, sizeof(*iface)); 202 203 iface->fun = child; 204 iface->interface_no = interface_descriptor->interface_number; 205 link_initialize(&iface->link); 147 206 148 207 rc = ddf_fun_bind(child); … … 152 211 return rc; 153 212 } 154 155 iface->fun = child; 156 ddf_fun_data_implant(child, iface); 157 ddf_fun_set_ops(child, &child_device_ops); 213 *iface_ret = iface; 158 214 159 215 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.