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