Changeset 79e1abd in mainline for uspace/drv/usbmid/explore.c
- Timestamp:
- 2011-03-29T12:09:15Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d012590
- Parents:
- 841e6e5 (diff), 51e5608 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/usbmid/explore.c
r841e6e5 r79e1abd 40 40 #include <usb/request.h> 41 41 #include <usb/dp.h> 42 #include <usb/ddfiface.h> 42 43 #include "usbmid.h" 44 45 /** Operations of the device itself. */ 46 static ddf_dev_ops_t mid_device_ops = { 47 .interfaces[USB_DEV_IFACE] = &usb_iface_hub_impl 48 }; 43 49 44 50 /** Find starting indexes of all interface descriptors in a configuration. … … 105 111 * @return Whether to accept this device from devman. 106 112 */ 107 bool usbmid_explore_device(usb mid_device_t *dev)113 bool usbmid_explore_device(usb_device_t *dev) 108 114 { 109 usb_standard_device_descriptor_t device_descriptor; 110 int rc = usb_request_get_device_descriptor(&dev->ctrl_pipe, 111 &device_descriptor); 112 if (rc != EOK) { 113 usb_log_error("Getting device descriptor failed: %s.\n", 114 str_error(rc)); 115 return false; 116 } 117 118 if (device_descriptor.device_class != USB_CLASS_USE_INTERFACE) { 115 int rc; 116 117 int dev_class = dev->descriptors.device.device_class; 118 if (dev_class != USB_CLASS_USE_INTERFACE) { 119 119 usb_log_warning( 120 120 "Device class: %d (%s), but expected class 0.\n", 121 device_descriptor.device_class, 122 usb_str_class(device_descriptor.device_class)); 121 dev_class, usb_str_class(dev_class)); 123 122 usb_log_error("Not multi interface device, refusing.\n"); 124 123 return false; 125 124 } 126 125 127 size_t config_descriptor_size; 128 uint8_t *config_descriptor_raw = NULL; 129 rc = usb_request_get_full_configuration_descriptor_alloc( 130 &dev->ctrl_pipe, 0, 131 (void **) &config_descriptor_raw, &config_descriptor_size); 132 if (rc != EOK) { 133 usb_log_error("Failed getting full config descriptor: %s.\n", 134 str_error(rc)); 135 return false; 136 } 137 138 usb_standard_configuration_descriptor_t *config_descriptor 139 = (usb_standard_configuration_descriptor_t *) config_descriptor_raw; 126 /* Short cuts to save on typing ;-). */ 127 uint8_t *config_descriptor_raw = dev->descriptors.configuration; 128 size_t config_descriptor_size = dev->descriptors.configuration_size; 129 usb_standard_configuration_descriptor_t *config_descriptor = 130 (usb_standard_configuration_descriptor_t *) config_descriptor_raw; 140 131 141 132 size_t *interface_descriptors … … 154 145 if (interface_descriptors_count == (size_t) -1) { 155 146 usb_log_error("Problem parsing configuration descriptor.\n"); 156 free(config_descriptor_raw);157 147 free(interface_descriptors); 158 148 return false; … … 165 155 usb_log_error("Failed to set device configuration: %s.\n", 166 156 str_error(rc)); 167 free(config_descriptor_raw);168 157 free(interface_descriptors); 169 158 return false; … … 172 161 173 162 /* Create control function */ 174 ddf_fun_t *ctl_fun = ddf_fun_create(dev->d ev, fun_exposed, "ctl");163 ddf_fun_t *ctl_fun = ddf_fun_create(dev->ddf_dev, fun_exposed, "ctl"); 175 164 if (ctl_fun == NULL) { 176 165 usb_log_error("Failed to create control function.\n"); 177 free(config_descriptor_raw); 178 free(interface_descriptors); 179 return false; 180 } 166 free(interface_descriptors); 167 return false; 168 } 169 170 ctl_fun->ops = &mid_device_ops; 171 181 172 rc = ddf_fun_bind(ctl_fun); 182 173 if (rc != EOK) { 183 174 usb_log_error("Failed to bind control function: %s.\n", 184 175 str_error(rc)); 185 free(config_descriptor_raw);186 176 free(interface_descriptors); 187 177 return false; … … 199 189 (int) interface->interface_number, 200 190 usb_str_class(interface->interface_class)); 201 rc = usbmid_spawn_interface_child(dev, &dev ice_descriptor,191 rc = usbmid_spawn_interface_child(dev, &dev->descriptors.device, 202 192 interface); 203 193 if (rc != EOK) { … … 207 197 } 208 198 209 free(config_descriptor_raw);210 211 199 return true; 212 200 }
Note:
See TracChangeset
for help on using the changeset viewer.