Changeset 9b95dbcf in mainline


Ignore:
Timestamp:
2011-01-07T16:33:39Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
56184b2, a523af4
Parents:
97bfba1
Message:

Code refactoring

File:
1 edited

Legend:

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

    r97bfba1 r9b95dbcf  
    130130                return EBADMEM;
    131131        }
    132 
    133         /* Prepare the target. */
    134         usb_target_t target = {
    135                 .address = address,
    136                 .endpoint = 0
    137         };
    138 
    139         /* Prepare the setup packet. */
    140         usb_device_request_setup_packet_t setup_packet = {
    141                 .request_type = 128,
    142                 .request = USB_DEVREQ_GET_DESCRIPTOR,
    143                 .index = 0,
    144                 .length = sizeof(usb_standard_device_descriptor_t)
    145         };
    146         setup_packet.value_high = USB_DESCTYPE_DEVICE;
    147         setup_packet.value_low = 0;
    148 
    149         /* Prepare local descriptor. */
     132       
    150133        size_t actually_transferred = 0;
    151134        usb_standard_device_descriptor_t descriptor_tmp;
    152 
    153         /* Perform the control read transaction. */
    154         int rc = usb_drv_psync_control_read(phone, target,
    155             &setup_packet, sizeof(setup_packet),
    156             &descriptor_tmp, sizeof(descriptor_tmp), &actually_transferred);
     135        int rc = usb_drv_req_get_descriptor(phone, address,
     136            USB_REQUEST_TYPE_STANDARD,
     137            USB_DESCTYPE_DEVICE, 0,
     138            0,
     139            &descriptor_tmp, sizeof(descriptor_tmp),
     140            &actually_transferred);
    157141
    158142        if (rc != EOK) {
     
    193177                return EBADMEM;
    194178        }
    195 
    196         /* Prepare the target. */
    197         usb_target_t target = {
    198                 .address = address,
    199                 .endpoint = 0
    200         };
    201 
    202         /* Prepare the setup packet. */
    203         usb_device_request_setup_packet_t setup_packet = {
    204                 .request_type = 128,
    205                 .request = USB_DEVREQ_GET_DESCRIPTOR,
    206                 .index = 0,
    207                 .length = sizeof(usb_standard_configuration_descriptor_t)
    208         };
    209         setup_packet.value_high = USB_DESCTYPE_CONFIGURATION;
    210         setup_packet.value_low = index;
    211 
    212         /* Prepare local descriptor. */
     179       
    213180        size_t actually_transferred = 0;
    214181        usb_standard_configuration_descriptor_t descriptor_tmp;
    215 
    216         /* Perform the control read transaction. */
    217         int rc = usb_drv_psync_control_read(phone, target,
    218             &setup_packet, sizeof(setup_packet),
    219             &descriptor_tmp, sizeof(descriptor_tmp), &actually_transferred);
     182        int rc = usb_drv_req_get_descriptor(phone, address,
     183            USB_REQUEST_TYPE_STANDARD,
     184            USB_DESCTYPE_CONFIGURATION, 0,
     185            0,
     186            &descriptor_tmp, sizeof(descriptor_tmp),
     187            &actually_transferred);
    220188
    221189        if (rc != EOK) {
     
    257225        }
    258226
    259         /* Prepare the target. */
    260         usb_target_t target = {
    261                 .address = address,
    262                 .endpoint = 0
    263         };
    264 
    265         /* Prepare the setup packet. */
    266         usb_device_request_setup_packet_t setup_packet = {
    267                 .request_type = 128,
    268                 .request = USB_DEVREQ_GET_DESCRIPTOR,
    269                 .index = 0,
    270                 .length = buffer_size
    271         };
    272         setup_packet.value_high = USB_DESCTYPE_CONFIGURATION;
    273         setup_packet.value_low = index;
    274 
    275         /* Perform the control read transaction. */
    276         int rc = usb_drv_psync_control_read(phone, target,
    277             &setup_packet, sizeof(setup_packet),
    278             buffer, buffer_size, actual_buffer_size);
     227        int rc = usb_drv_req_get_descriptor(phone, address,
     228            USB_REQUEST_TYPE_STANDARD,
     229            USB_DESCTYPE_CONFIGURATION, 0,
     230            0,
     231            buffer, buffer_size,
     232            actual_buffer_size);
    279233
    280234        return rc;
Note: See TracChangeset for help on using the changeset viewer.