Changeset 945d66c in mainline
- Timestamp:
- 2013-01-25T22:55:22Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9e79a2f
- Parents:
- c39e9fb
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/bus/usb/usbhid/usbhid.c
rc39e9fb r945d66c 114 114 const usb_hid_subdriver_mapping_t *mapping) 115 115 { 116 assert(hid_dev != NULL); 117 assert(hid_dev->usb_dev != NULL); 118 119 return (hid_dev->usb_dev->descriptors.device.vendor_id 120 == mapping->vendor_id 121 && hid_dev->usb_dev->descriptors.device.product_id 122 == mapping->product_id); 116 assert(hid_dev); 117 assert(hid_dev->usb_dev); 118 assert(mapping); 119 const usb_standard_device_descriptor_t *d = 120 usb_device_get_device_descriptor(hid_dev->usb_dev); 121 122 return (d->vendor_id == mapping->vendor_id) 123 && (d->product_id == mapping->product_id); 123 124 } 124 125 -
uspace/drv/bus/usb/usbmid/explore.c
rc39e9fb r945d66c 118 118 usbmid_interface_t *iface = NULL; 119 119 const int rc = usbmid_spawn_interface_child(usb_dev, &iface, 120 &usb_dev->descriptors.device, interface);120 usb_device_get_device_descriptor(usb_dev), interface); 121 121 if (rc != EOK) { 122 122 //TODO: Do something about that failure. … … 142 142 int usbmid_explore_device(usb_device_t *dev) 143 143 { 144 const unsigned dev_class = dev->descriptors.device.device_class; 144 const unsigned dev_class = 145 usb_device_get_device_descriptor(dev)->device_class; 145 146 if (dev_class != USB_CLASS_USE_INTERFACE) { 146 147 usb_log_warning( … … 152 153 } 153 154 154 /* Shortcuts to save on typing ;-). */ 155 const void *config_descriptor_raw = dev->descriptors.configuration; 156 size_t config_descriptor_size = dev->descriptors.configuration_size; 155 /* Get coonfiguration descriptor. */ 156 size_t config_descriptor_size = 0; 157 const void *config_descriptor_raw = 158 usb_device_get_configuration_descriptor(dev, 159 &config_descriptor_size); 157 160 const usb_standard_configuration_descriptor_t *config_descriptor = 158 161 config_descriptor_raw; -
uspace/lib/usbdev/include/usb/dev/driver.h
rc39e9fb r945d66c 42 42 #include <usb_iface.h> 43 43 44 /** Descriptors for USB device. */45 typedef struct {46 /** Standard device descriptor. */47 usb_standard_device_descriptor_t device;48 /** Full configuration descriptor of current configuration. */49 const uint8_t *configuration;50 size_t configuration_size;51 } usb_device_descriptors_t;52 44 53 45 /** Wrapper for data related to alternate interface setting. … … 84 76 /** The default control pipe. */ 85 77 usb_pipe_t ctrl_pipe; 78 86 79 /** Other endpoint pipes. 87 80 * This is an array of other endpoint pipes in the same order as … … 100 93 usb_alternate_interfaces_t alternate_interfaces; 101 94 102 /** Some useful descriptors. */ 103 usb_device_descriptors_t descriptors; 95 /** Some useful descriptors for USB device. */ 96 struct { 97 /** Standard device descriptor. */ 98 usb_standard_device_descriptor_t device; 99 /** Full configuration descriptor of current configuration. */ 100 const uint8_t *configuration; 101 size_t configuration_size; 102 } descriptors; 104 103 105 104 /** Generic DDF device backing this one. DO NOT TOUCH! */ … … 179 178 const usb_endpoint_description_t **); 180 179 181 int usb_device_retrieve_descriptors(usb_pipe_t *, usb_device_descriptors_t *);182 void usb_device_release_descriptors(usb_device_descriptors_t *);183 184 180 int usb_device_create_pipes(usb_device_connection_t *, 185 181 const usb_endpoint_description_t **, const uint8_t *, size_t, int, int, … … 188 184 usb_pipe_t *usb_device_get_default_pipe(usb_device_t *); 189 185 usb_pipe_t *usb_device_get_pipe(usb_device_t *, usb_endpoint_t, usb_direction_t); 186 187 const usb_standard_device_descriptor_t * 188 usb_device_get_device_descriptor(usb_device_t *); 189 const void * usb_device_get_configuration_descriptor(usb_device_t *, size_t *); 190 190 191 191 192 void * usb_device_data_alloc(usb_device_t *, size_t); -
uspace/lib/usbdev/src/devdrv.c
rc39e9fb r945d66c 233 233 * @return Error code. 234 234 */ 235 int usb_device_retrieve_descriptors(usb_pipe_t *ctrl_pipe, 236 usb_device_descriptors_t *descriptors) 237 { 238 assert(descriptors != NULL); 239 240 descriptors->configuration = NULL; 241 242 int rc; 235 static int usb_device_retrieve_descriptors(usb_device_t *usb_dev) 236 { 237 assert(usb_dev); 238 assert(usb_dev->descriptors.configuration == NULL); 243 239 244 240 /* It is worth to start a long transfer. */ 245 usb_pipe_start_long_transfer( ctrl_pipe);241 usb_pipe_start_long_transfer(&usb_dev->ctrl_pipe); 246 242 247 243 /* Get the device descriptor. */ 248 rc = usb_request_get_device_descriptor(ctrl_pipe, &descriptors->device); 244 int rc = usb_request_get_device_descriptor(&usb_dev->ctrl_pipe, 245 &usb_dev->descriptors.device); 249 246 if (rc != EOK) { 250 247 goto leave; … … 253 250 /* Get the full configuration descriptor. */ 254 251 rc = usb_request_get_full_configuration_descriptor_alloc( 255 ctrl_pipe, 0, (void **) &descriptors->configuration, 256 &descriptors->configuration_size); 252 &usb_dev->ctrl_pipe, 0, 253 (void **) &usb_dev->descriptors.configuration, 254 &usb_dev->descriptors.configuration_size); 257 255 258 256 leave: 259 usb_pipe_end_long_transfer( ctrl_pipe);257 usb_pipe_end_long_transfer(&usb_dev->ctrl_pipe); 260 258 261 259 return rc; … … 266 264 * @param[in] descriptors Where to store the descriptors. 267 265 */ 268 void usb_device_release_descriptors(usb_device_descriptors_t *descriptors) 269 { 270 assert(descriptors); 271 free(descriptors->configuration); 272 descriptors->configuration = NULL; 266 static void usb_device_release_descriptors(usb_device_t *usb_dev) 267 { 268 assert(usb_dev); 269 free(usb_dev->descriptors.configuration); 270 usb_dev->descriptors.configuration = NULL; 271 usb_dev->descriptors.configuration_size = 0; 273 272 } 274 273 … … 394 393 } 395 394 395 const usb_standard_device_descriptor_t * 396 usb_device_get_device_descriptor(usb_device_t *usb_dev) 397 { 398 assert(usb_dev); 399 return &usb_dev->descriptors.device; 400 } 401 402 const void * usb_device_get_configuration_descriptor( 403 usb_device_t *usb_dev, size_t *size) 404 { 405 assert(usb_dev); 406 if (size) 407 *size = usb_dev->descriptors.configuration_size; 408 return usb_dev->descriptors.configuration; 409 } 410 396 411 /** Initialize new instance of USB device. 397 412 * … … 462 477 463 478 /* Retrieve standard descriptors. */ 464 rc = usb_device_retrieve_descriptors( 465 &usb_dev->ctrl_pipe, &usb_dev->descriptors); 479 rc = usb_device_retrieve_descriptors(usb_dev); 466 480 if (rc != EOK) { 467 481 *errstr_ptr = "descriptor retrieval"; … … 489 503 usb_hc_connection_close(&usb_dev->hc_conn); 490 504 /* Full configuration descriptor is allocated. */ 491 usb_device_release_descriptors( &usb_dev->descriptors);505 usb_device_release_descriptors(usb_dev); 492 506 /* Alternate interfaces may be allocated */ 493 507 usb_alternate_interfaces_deinit(&usb_dev->alternate_interfaces); … … 515 529 usb_hc_connection_deinitialize(&dev->hc_conn); 516 530 usb_alternate_interfaces_deinit(&dev->alternate_interfaces); 517 usb_device_release_descriptors( &dev->descriptors);531 usb_device_release_descriptors(dev); 518 532 free(dev->driver_data); 519 533 dev->driver_data = NULL;
Note:
See TracChangeset
for help on using the changeset viewer.