Changeset 00aece0 in mainline for uspace/lib/usbdev/src/request.c
- Timestamp:
- 2012-02-18T16:47:38Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4449c6c
- Parents:
- bd5f3b7 (diff), f943dd3 (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/lib/usbdev/src/request.c
rbd5f3b7 r00aece0 143 143 */ 144 144 145 usb_device_request_setup_packet_t setup_packet; 146 setup_packet.request_type = 128 | (request_type << 5) | recipient; 147 setup_packet.request = request; 148 setup_packet.value = value; 149 setup_packet.index = index; 150 setup_packet.length = (uint16_t) data_size; 151 152 int rc = usb_pipe_control_read(pipe, 153 &setup_packet, sizeof(setup_packet), 145 const usb_device_request_setup_packet_t setup_packet = { 146 .request_type = SETUP_REQUEST_TYPE_DEVICE_TO_HOST 147 | (request_type << 5) | recipient, 148 .request = request, 149 .value = value, 150 .index = index, 151 .length = (uint16_t) data_size, 152 }; 153 154 return usb_pipe_control_read(pipe, &setup_packet, sizeof(setup_packet), 154 155 data, data_size, actual_data_size); 155 156 return rc;157 156 } 158 157 … … 248 247 249 248 return rc; 250 }251 252 /** Change address of connected device.253 * This function automatically updates the backing connection to point to254 * the new address.255 *256 * @param pipe Control endpoint pipe (session must be already started).257 * @param new_address New USB address to be set (in native endianness).258 * @return Error code.259 */260 int usb_request_set_address(usb_pipe_t *pipe,261 usb_address_t new_address)262 {263 if ((new_address < 0) || (new_address >= USB11_ADDRESS_MAX)) {264 return EINVAL;265 }266 267 uint16_t addr = uint16_host2usb((uint16_t)new_address);268 269 int rc = usb_control_request_set(pipe,270 USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE,271 USB_DEVREQ_SET_ADDRESS,272 addr, 0,273 NULL, 0);274 275 if (rc != EOK) {276 return rc;277 }278 279 assert(pipe->wire != NULL);280 /* TODO: prevent other from accessing wire now. */281 pipe->wire->address = new_address;282 283 return EOK;284 249 } 285 250 … … 310 275 } 311 276 312 uint16_t wValue = descriptor_index | (descriptor_type << 8);277 const uint16_t wValue = descriptor_index | (descriptor_type << 8); 313 278 314 279 return usb_control_request_get(pipe, … … 425 390 426 391 /* Everything is okay, copy the descriptor. */ 427 memcpy(descriptor, &descriptor_tmp, 428 sizeof(descriptor_tmp)); 392 memcpy(descriptor, &descriptor_tmp, sizeof(descriptor_tmp)); 429 393 430 394 return EOK; … … 470 434 471 435 /* Everything is okay, copy the descriptor. */ 472 memcpy(descriptor, &descriptor_tmp, 473 sizeof(descriptor_tmp)); 436 memcpy(descriptor, &descriptor_tmp, sizeof(descriptor_tmp)); 474 437 475 438 return EOK;
Note:
See TracChangeset
for help on using the changeset viewer.