Changes in uspace/drv/bus/usb/usbmid/usbmid.c [d3a1ad58:56fd7cf] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbmid/usbmid.c
rd3a1ad58 r56fd7cf 31 31 */ 32 32 33 /* XXX Fix this */ 34 #define _DDF_DATA_IMPLANT 35 33 36 /** 34 37 * @file … … 39 42 #include <stdlib.h> 40 43 #include <usb_iface.h> 44 #include <usb/ddfiface.h> 41 45 #include <usb/dev/pipes.h> 42 46 #include <usb/classes/classes.h> 43 47 #include <usb/dev/recognise.h> 44 48 #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 }77 49 78 50 /** Callback for DDF USB interface. */ 79 static int usb_iface_ iface(ddf_fun_t *fun, int *iface_no)51 static int usb_iface_get_interface_impl(ddf_fun_t *fun, int *iface_no) 80 52 { 81 53 usbmid_interface_t *iface = ddf_fun_data_get(fun); … … 89 61 } 90 62 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 117 63 /** DDF interface of the child - interface function. */ 118 64 static usb_iface_t child_usb_iface = { 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, 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, 124 68 }; 125 69 … … 137 81 return ret; 138 82 } 83 /* NOTE: usbmid->interface points somewhere, but we did not 84 * allocate that space, so don't touch */ 139 85 ddf_fun_destroy(mid_iface->fun); 86 /* NOTE: mid_iface is invalid at this point, it was assigned to 87 * mid_iface->fun->driver_data and freed in ddf_fun_destroy */ 140 88 return EOK; 141 89 } … … 150 98 */ 151 99 int usbmid_spawn_interface_child(usb_device_t *parent, 152 usbmid_interface_t * *iface_ret,100 usbmid_interface_t *iface, 153 101 const usb_standard_device_descriptor_t *device_descriptor, 154 102 const usb_standard_interface_descriptor_t *interface_descriptor) … … 171 119 172 120 /* Create the device. */ 173 child = usb_device_ddf_fun_create(parent, fun_inner, child_name);121 child = ddf_fun_create(parent->ddf_dev, fun_inner, child_name); 174 122 free(child_name); 175 123 if (child == NULL) { … … 197 145 } 198 146 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);206 147 207 148 rc = ddf_fun_bind(child); … … 211 152 return rc; 212 153 } 213 *iface_ret = iface; 154 155 iface->fun = child; 156 ddf_fun_data_implant(child, iface); 157 ddf_fun_set_ops(child, &child_device_ops); 214 158 215 159 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.