Changeset 7aaed09 in mainline for uspace/lib/usbdev/src/request.c


Ignore:
Timestamp:
2011-12-18T14:02:30Z (12 years ago)
Author:
Jakub Jermar <jakub@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c868e2d
Parents:
3b71e84d (diff), 1761268 (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.
Message:

Merge mainline changes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbdev/src/request.c

    r3b71e84d r7aaed09  
    143143         */
    144144
    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),
    154155            data, data_size, actual_data_size);
    155 
    156         return rc;
    157156}
    158157
     
    248247
    249248        return rc;
    250 }
    251 
    252 /** Change address of connected device.
    253  * This function automatically updates the backing connection to point to
    254  * 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;
    284249}
    285250
     
    310275        }
    311276
    312         uint16_t wValue = descriptor_index | (descriptor_type << 8);
     277        const uint16_t wValue = descriptor_index | (descriptor_type << 8);
    313278
    314279        return usb_control_request_get(pipe,
Note: See TracChangeset for help on using the changeset viewer.