Changeset 96e01fbc in mainline for uspace/lib/usbdev
- Timestamp:
- 2012-08-31T17:30:29Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 2be2506a
- Parents:
- e0d5bc5 (diff), 0d57c3e (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. - Location:
- uspace/lib/usbdev
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usbdev/include/usb/dev/usb_device_connection.h
re0d5bc5 r96e01fbc 72 72 return EOK; 73 73 } 74 /*----------------------------------------------------------------------------*/ 74 75 75 /** Register endpoint on the device. 76 76 * @param instance device connection structure to use. … … 91 91 instance->address, ep, type, direction, packet_size, interval); 92 92 } 93 /*----------------------------------------------------------------------------*/ 93 94 94 /** Unregister endpoint on the device. 95 95 * @param instance device connection structure … … 105 105 instance->address, ep, dir); 106 106 } 107 /*----------------------------------------------------------------------------*/ 107 108 108 /** Get data from the device. 109 109 * @param[in] instance device connection structure to use. … … 122 122 instance->address, ep, setup, data, size, rsize); 123 123 } 124 /*----------------------------------------------------------------------------*/ 124 125 125 /** Send data to the device. 126 126 * @param instance device connection structure to use. … … 138 138 instance->address, ep, setup, data, size); 139 139 } 140 /*----------------------------------------------------------------------------*/ 140 141 141 /** Wrapper for read calls with no setup stage. 142 142 * @param[in] instance device connection structure. … … 153 153 return usb_device_control_read(instance, ep, 0, data, size, real_size); 154 154 } 155 /*----------------------------------------------------------------------------*/ 155 156 156 /** Wrapper for write calls with no setup stage. 157 157 * @param instance device connection structure. -
uspace/lib/usbdev/src/devdrv.c
re0d5bc5 r96e01fbc 74 74 return ddf_driver_main(&generic_driver); 75 75 } 76 /*----------------------------------------------------------------------------*/ 76 77 77 /** Count number of pipes the driver expects. 78 78 * … … 87 87 return count; 88 88 } 89 /*----------------------------------------------------------------------------*/ 89 90 90 /** Callback when a new device is supposed to be controlled by this driver. 91 91 * … … 105 105 if (dev == NULL) { 106 106 usb_log_error("USB device `%s' structure allocation failed.\n", 107 gen_dev->name);107 ddf_dev_get_name(gen_dev)); 108 108 return ENOMEM; 109 109 } … … 114 114 if (rc != EOK) { 115 115 usb_log_error("USB device `%s' init failed (%s): %s.\n", 116 gen_dev->name, err_msg, str_error(rc));116 ddf_dev_get_name(gen_dev), err_msg, str_error(rc)); 117 117 return rc; 118 118 } … … 124 124 return rc; 125 125 } 126 /*----------------------------------------------------------------------------*/ 126 127 127 /** Callback when a device is supposed to be removed from the system. 128 128 * … … 139 139 return ENOTSUP; 140 140 /* Just tell the driver to stop whatever it is doing */ 141 usb_device_t *usb_dev = gen_dev->driver_data;141 usb_device_t *usb_dev = ddf_dev_data_get(gen_dev); 142 142 const int ret = driver->ops->device_rem(usb_dev); 143 143 if (ret != EOK) … … 146 146 return EOK; 147 147 } 148 /*----------------------------------------------------------------------------*/ 148 149 149 /** Callback when a device was removed from the system. 150 150 * … … 160 160 if (driver->ops->device_gone == NULL) 161 161 return ENOTSUP; 162 usb_device_t *usb_dev = gen_dev->driver_data;162 usb_device_t *usb_dev = ddf_dev_data_get(gen_dev); 163 163 const int ret = driver->ops->device_gone(usb_dev); 164 164 if (ret == EOK) … … 167 167 return ret; 168 168 } 169 /*----------------------------------------------------------------------------*/ 169 170 170 /** Destroy existing pipes of a USB device. 171 171 * … … 178 178 dev->pipes_count = 0; 179 179 } 180 /*----------------------------------------------------------------------------*/ 180 181 181 /** Change interface setting of a device. 182 182 * This function selects new alternate setting of an interface by issuing … … 415 415 usb_address_t address; 416 416 417 int rc = usb_get_info_by_handle(ddf_dev ->handle,417 int rc = usb_get_info_by_handle(ddf_dev_get_handle(ddf_dev), 418 418 &hc_handle, &address, &usb_dev->interface_no); 419 419 if (rc != EOK) { -
uspace/lib/usbdev/src/devpoll.c
re0d5bc5 r96e01fbc 80 80 usb_log_debug("Poll%p: started polling of `%s' - " \ 81 81 "interface %d (%s,%d,%d), %zuB/%zu.\n", 82 data, d ata->dev->ddf_dev->name,82 data, ddf_dev_get_name(data->dev->ddf_dev), 83 83 (int) mapping->interface->interface_number, 84 84 usb_str_class(mapping->interface->interface_class), … … 159 159 if (failed) { 160 160 usb_log_error("Polling of device `%s' terminated: " 161 "recurring failures.\n", data->dev->ddf_dev->name); 161 "recurring failures.\n", ddf_dev_get_name( 162 data->dev->ddf_dev)); 162 163 } else { 163 164 usb_log_debug("Polling of device `%s' terminated: " 164 "driver request.\n", data->dev->ddf_dev->name); 165 "driver request.\n", ddf_dev_get_name( 166 data->dev->ddf_dev)); 165 167 } 166 168 } -
uspace/lib/usbdev/src/hub.c
re0d5bc5 r96e01fbc 63 63 return EBADMEM; 64 64 return usb_hc_bind_address(connection, 65 attached_device->address, attached_device->fun->handle);65 attached_device->address, ddf_fun_get_handle(attached_device->fun)); 66 66 } 67 67 … … 287 287 rc = usb_hub_register_device(hc_conn, &new_device); 288 288 if (rc != EOK) { 289 /* We know nothing about that data. */290 if (new_dev_data)291 child_fun->driver_data = NULL;292 289 /* The child function is already created. */ 293 290 ddf_fun_destroy(child_fun); -
uspace/lib/usbdev/src/pipes.c
re0d5bc5 r96e01fbc 54 54 return usb_hc_connection_open(pipe->wire->hc_connection); 55 55 } 56 /*----------------------------------------------------------------------------*/ 56 57 57 /** Terminate a long transfer on a pipe. 58 58 * @param pipe Pipe where to end the long transfer. … … 67 67 return usb_hc_connection_close(pipe->wire->hc_connection); 68 68 } 69 /*----------------------------------------------------------------------------*/ 69 70 70 /** Try to clear endpoint halt of default control pipe. 71 71 * … … 85 85 pipe->auto_reset_halt = true; 86 86 } 87 /*----------------------------------------------------------------------------*/ 87 88 88 /** Request a control read transfer on an endpoint pipe. 89 89 * … … 135 135 return rc; 136 136 } 137 /*----------------------------------------------------------------------------*/ 137 138 138 /** Request a control write transfer on an endpoint pipe. 139 139 * … … 182 182 return rc; 183 183 } 184 /*----------------------------------------------------------------------------*/ 184 185 185 /** Request a read (in) transfer on an endpoint pipe. 186 186 * … … 227 227 return rc; 228 228 } 229 /*----------------------------------------------------------------------------*/ 229 230 230 /** Request a write (out) transfer on an endpoint pipe. 231 231 * … … 259 259 pipe->endpoint_no, buffer, size); 260 260 } 261 /*----------------------------------------------------------------------------*/ 261 262 262 /** Initialize USB endpoint pipe. 263 263 * … … 287 287 return EOK; 288 288 } 289 /*----------------------------------------------------------------------------*/ 289 290 290 /** Initialize USB endpoint pipe as the default zero control pipe. 291 291 * … … 307 307 return rc; 308 308 } 309 /*----------------------------------------------------------------------------*/ 309 310 310 /** Register endpoint with the host controller. 311 311 * … … 323 323 pipe->direction, pipe->max_packet_size, interval); 324 324 } 325 /*----------------------------------------------------------------------------*/ 325 326 326 /** Revert endpoint registration with the host controller. 327 327 * -
uspace/lib/usbdev/src/pipesinit.c
re0d5bc5 r96e01fbc 154 154 usb_endpoint_mapping_t *mapping, size_t mapping_count, 155 155 usb_standard_interface_descriptor_t *interface, 156 usb_standard_endpoint_descriptor_t *endpoint ,156 usb_standard_endpoint_descriptor_t *endpoint_desc, 157 157 usb_device_connection_t *wire) 158 158 { … … 163 163 164 164 /* Actual endpoint number is in bits 0..3 */ 165 const usb_endpoint_t ep_no = endpoint ->endpoint_address & 0x0F;165 const usb_endpoint_t ep_no = endpoint_desc->endpoint_address & 0x0F; 166 166 167 167 const usb_endpoint_description_t description = { 168 168 /* Endpoint direction is set by bit 7 */ 169 .direction = (endpoint ->endpoint_address & 128)169 .direction = (endpoint_desc->endpoint_address & 128) 170 170 ? USB_DIRECTION_IN : USB_DIRECTION_OUT, 171 171 /* Transfer type is in bits 0..2 and 172 172 * the enum values corresponds 1:1 */ 173 .transfer_type = endpoint ->attributes & 3,173 .transfer_type = endpoint_desc->attributes & 3, 174 174 175 175 /* Get interface characteristics. */ … … 194 194 195 195 int rc = usb_pipe_initialize(&ep_mapping->pipe, wire, 196 ep_no, description.transfer_type, endpoint->max_packet_size, 196 ep_no, description.transfer_type, 197 uint16_usb2host(endpoint_desc->max_packet_size), 197 198 description.direction); 198 199 if (rc != EOK) { … … 201 202 202 203 ep_mapping->present = true; 203 ep_mapping->descriptor = endpoint ;204 ep_mapping->descriptor = endpoint_desc; 204 205 ep_mapping->interface = interface; 205 206 -
uspace/lib/usbdev/src/recognise.c
re0d5bc5 r96e01fbc 33 33 * Functions for recognition of attached devices. 34 34 */ 35 36 /** XXX Fix this */ 37 #define _DDF_DATA_IMPLANT 35 38 36 39 #include <sys/types.h> … … 352 355 353 356 if (dev_ops != NULL) 354 child->ops = dev_ops;357 ddf_fun_set_ops(child, dev_ops); 355 358 else 356 child->ops = &child_ops; 357 358 child->driver_data = dev_data; 359 ddf_fun_set_ops(child, &child_ops); 360 361 ddf_fun_data_implant(child, dev_data); 362 359 363 /* 360 364 * Store the attached device in fun … … 373 377 } 374 378 375 rc = usb_device_create_match_ids(ctrl_pipe, &child->match_ids); 379 match_id_list_t match_ids; 380 init_match_ids(&match_ids); 381 rc = usb_device_create_match_ids(ctrl_pipe, &match_ids); 376 382 if (rc != EOK) 377 383 goto failure; 384 385 list_foreach(match_ids.ids, id_link) { 386 match_id_t *match_id = list_get_instance(id_link, match_id_t, link); 387 rc = ddf_fun_add_match_id(child, match_id->id, match_id->score); 388 if (rc != EOK) { 389 clean_match_ids(&match_ids); 390 goto failure; 391 } 392 } 393 394 clean_match_ids(&match_ids); 378 395 379 396 rc = ddf_fun_bind(child); … … 386 403 failure: 387 404 if (child != NULL) { 388 /* We know nothing about the data if it came from outside. */389 if (dev_data)390 child->driver_data = NULL;391 392 405 /* This takes care of match_id deallocation as well. */ 393 406 ddf_fun_destroy(child); -
uspace/lib/usbdev/src/request.c
re0d5bc5 r96e01fbc 114 114 * (in native endianness). 115 115 * @param actual_data_size Actual size of transfered data 116 * 116 * (in native endianness). 117 117 * @return Error code. 118 118 * @retval EBADMEM @p pipe is NULL. … … 147 147 | (request_type << 5) | recipient, 148 148 .request = request, 149 .value = value,150 .index = index,151 .length = (uint16_t) data_size,149 .value = uint16_host2usb(value), 150 .index = uint16_host2usb(index), 151 .length = uint16_host2usb(data_size), 152 152 }; 153 153 … … 375 375 usb_standard_device_descriptor_t descriptor_tmp; 376 376 int rc = usb_request_get_descriptor(pipe, 377 USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE, 377 USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE, 378 378 USB_DESCTYPE_DEVICE, 0, 0, 379 379 &descriptor_tmp, sizeof(descriptor_tmp), … … 435 435 /* Everything is okay, copy the descriptor. */ 436 436 memcpy(descriptor, &descriptor_tmp, sizeof(descriptor_tmp)); 437 438 437 return EOK; 439 438 } … … 495 494 return ENOENT; 496 495 } 497 if (bare_config.total_length < sizeof(bare_config)) { 496 497 const size_t total_length = uint16_usb2host(bare_config.total_length); 498 if (total_length < sizeof(bare_config)) { 498 499 return ELIMIT; 499 500 } 500 501 501 void *buffer = malloc( bare_config.total_length);502 void *buffer = malloc(total_length); 502 503 if (buffer == NULL) { 503 504 return ENOMEM; … … 506 507 size_t transferred = 0; 507 508 rc = usb_request_get_full_configuration_descriptor(pipe, index, 508 buffer, bare_config.total_length, &transferred);509 buffer, total_length, &transferred); 509 510 if (rc != EOK) { 510 511 free(buffer); … … 512 513 } 513 514 514 if (transferred != bare_config.total_length) {515 if (transferred != total_length) { 515 516 free(buffer); 516 517 return ELIMIT; … … 522 523 523 524 if (descriptor_size != NULL) { 524 *descriptor_size = bare_config.total_length;525 *descriptor_size = total_length; 525 526 } 526 527
Note:
See TracChangeset
for help on using the changeset viewer.