Changes in uspace/drv/bus/usb/usbmid/usbmid.c [58563585:56fd7cf] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbmid/usbmid.c
r58563585 r56fd7cf 31 31 */ 32 32 33 /* XXX Fix this */ 34 #define _DDF_DATA_IMPLANT 35 33 36 /** 34 37 * @file 35 38 * Helper functions. 36 39 */ 37 38 40 #include <errno.h> 39 41 #include <str_error.h> 40 42 #include <stdlib.h> 41 43 #include <usb_iface.h> 44 #include <usb/ddfiface.h> 42 45 #include <usb/dev/pipes.h> 43 46 #include <usb/classes/classes.h> … … 45 48 #include "usbmid.h" 46 49 47 /** Get USB device handle by calling the parent usb_device_t. 48 * 49 * @param[in] fun Device function the operation is running on. 50 * @param[out] handle Device handle. 51 * @return Error code. 52 */ 53 static int usb_iface_device_handle(ddf_fun_t *fun, devman_handle_t *handle) 54 { 55 assert(fun); 56 assert(handle); 57 usb_device_t *usb_dev = usb_device_get(ddf_fun_get_dev(fun)); 58 *handle = usb_device_get_devman_handle(usb_dev); 59 return EOK; 60 } 61 62 /** Callback for DDF USB get interface. */ 63 static int usb_iface_iface_no(ddf_fun_t *fun, int *iface_no) 50 /** Callback for DDF USB interface. */ 51 static int usb_iface_get_interface_impl(ddf_fun_t *fun, int *iface_no) 64 52 { 65 53 usbmid_interface_t *iface = ddf_fun_data_get(fun); 66 54 assert(iface); 67 55 68 if (iface_no )56 if (iface_no != NULL) { 69 57 *iface_no = iface->interface_no; 58 } 70 59 71 60 return EOK; 72 61 } 73 62 74 /** DDF interface of the child - USB functions. */63 /** DDF interface of the child - interface function. */ 75 64 static usb_iface_t child_usb_iface = { 76 .get_my_device_handle = usb_iface_device_handle, 77 .get_my_interface = usb_iface_iface_no, 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, 78 68 }; 79 69 … … 91 81 return ret; 92 82 } 83 /* NOTE: usbmid->interface points somewhere, but we did not 84 * allocate that space, so don't touch */ 93 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 */ 94 88 return EOK; 95 89 } … … 104 98 */ 105 99 int usbmid_spawn_interface_child(usb_device_t *parent, 106 usbmid_interface_t * *iface_ret,100 usbmid_interface_t *iface, 107 101 const usb_standard_device_descriptor_t *device_descriptor, 108 102 const usb_standard_interface_descriptor_t *interface_descriptor) … … 125 119 126 120 /* Create the device. */ 127 child = usb_device_ddf_fun_create(parent, fun_inner, child_name);121 child = ddf_fun_create(parent->ddf_dev, fun_inner, child_name); 128 122 free(child_name); 129 123 if (child == NULL) { … … 141 135 } 142 136 143 list_foreach(match_ids.ids, link, match_id_t, match_id) { 137 list_foreach(match_ids.ids, link) { 138 match_id_t *match_id = list_get_instance(link, match_id_t, link); 144 139 rc = ddf_fun_add_match_id(child, match_id->id, match_id->score); 145 140 if (rc != EOK) { … … 150 145 } 151 146 clean_match_ids(&match_ids); 152 ddf_fun_set_ops(child, &child_device_ops);153 154 usbmid_interface_t *iface = ddf_fun_data_alloc(child, sizeof(*iface));155 156 iface->fun = child;157 iface->interface_no = interface_descriptor->interface_number;158 link_initialize(&iface->link);159 147 160 148 rc = ddf_fun_bind(child); … … 164 152 return rc; 165 153 } 166 *iface_ret = iface; 154 155 iface->fun = child; 156 ddf_fun_data_implant(child, iface); 157 ddf_fun_set_ops(child, &child_device_ops); 167 158 168 159 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.