Changeset 263a9f1 in mainline


Ignore:
Timestamp:
2011-01-10T11:35:53Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
863d45e
Parents:
276aeda
Message:

A bit of refactoring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/src/usbdrvreq.c

    r276aeda r263a9f1  
    164164    usb_address_t new_address)
    165165{
    166         /* Prepare the target. */
    167         usb_target_t target = {
    168                 .address = old_address,
    169                 .endpoint = 0
    170         };
    171 
    172         /* Prepare the setup packet. */
    173         usb_device_request_setup_packet_t setup_packet = {
    174                 .request_type = 0,
    175                 .request = USB_DEVREQ_SET_ADDRESS,
    176                 .index = 0,
    177                 .length = 0,
    178         };
    179         setup_packet.value = new_address;
     166        PREPARE_TARGET(target, old_address);
     167
     168        PREPARE_SETUP_PACKET(setup_packet, USB_DIRECTION_OUT,
     169            USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE,
     170            USB_DEVREQ_SET_ADDRESS, new_address, 0, 0);
    180171
    181172        int rc = usb_drv_psync_control_write(phone, target,
     
    211202        }
    212203
    213         /* Prepare the target. */
    214         usb_target_t target = {
    215                 .address = address,
    216                 .endpoint = 0
    217         };
    218 
    219         /* Prepare the setup packet. */
    220         usb_device_request_setup_packet_t setup_packet = {
    221                 .request_type = 128 | (request_type << 5),
    222                 .request = USB_DEVREQ_GET_DESCRIPTOR,
    223                 .index = language,
    224                 .length = (uint16_t) size,
    225         };
    226         setup_packet.value_high = descriptor_type;
    227         setup_packet.value_low = descriptor_index;
    228        
    229         /* Perform CONTROL READ */
     204        // FIXME: check that size is not too big
     205
     206        PREPARE_TARGET(target, address);
     207
     208        PREPARE_SETUP_PACKET_LOHI(setup_packet, USB_DIRECTION_IN,
     209            request_type, USB_REQUEST_RECIPIENT_DEVICE,
     210            USB_DEVREQ_GET_DESCRIPTOR, descriptor_index, descriptor_type,
     211            language, size);
     212
    230213        int rc = usb_drv_psync_control_read(hc_phone, target,
    231214            &setup_packet, sizeof(setup_packet),
Note: See TracChangeset for help on using the changeset viewer.