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