Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset f5e39475 in mainline


Ignore:
Timestamp:
2010-12-09T10:10:50Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
2c5cefa
Parents:
11feca8
Message:

Refactoring of standard device requests wrappers

File:
1 edited

Legend:

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

    r11feca8 rf5e39475  
    6767        setup_packet.value = new_address;
    6868
    69         usb_handle_t handle;
    70         int rc;
     69        int rc = usb_drv_psync_control_write(phone, target,
     70            &setup_packet, sizeof(setup_packet), NULL, 0);
    7171
    72         /* Start the control write transfer. */
    73         rc = usb_drv_async_control_write_setup(phone, target,
    74             &setup_packet, sizeof(setup_packet), &handle);
    75         if (rc != EOK) {
    76                 return rc;
    77         }
    78         rc = usb_drv_async_wait_for(handle);
    79         if (rc != EOK) {
    80                 return rc;
    81         }
    82 
    83         /* Finish the control write transfer. */
    84         rc = usb_drv_async_control_write_status(phone, target, &handle);
    85         if (rc != EOK) {
    86                 return rc;
    87         }
    88         rc = usb_drv_async_wait_for(handle);
    89         if (rc != EOK) {
    90                 return rc;
    91         }
    92 
    93         return EOK;
     72        return rc;
    9473}
    9574
     
    125104        setup_packet.value_low = 0;
    126105
    127         usb_handle_t handle;
    128         int rc;
     106        /* Prepare local descriptor. */
     107        size_t actually_transferred = 0;
     108        usb_standard_device_descriptor_t descriptor_tmp;
    129109
    130         /* Start the control read transfer. */
    131         rc = usb_drv_async_control_read_setup(phone, target,
    132             &setup_packet, sizeof(usb_device_request_setup_packet_t), &handle);
    133         if (rc != EOK) {
    134                 return rc;
    135         }
    136         rc = usb_drv_async_wait_for(handle);
     110        /* Perform the control read transaction. */
     111        int rc = usb_drv_psync_control_read(phone, target,
     112            &setup_packet, sizeof(setup_packet),
     113            &descriptor_tmp, sizeof(descriptor_tmp), &actually_transferred);
     114
    137115        if (rc != EOK) {
    138116                return rc;
    139117        }
    140118
    141         /* Retrieve the descriptor. */
    142         size_t actually_transferred = 0;
    143         usb_standard_device_descriptor_t descriptor_tmp;
    144         rc = usb_drv_async_control_read_data(phone, target,
    145             &descriptor_tmp, sizeof(usb_standard_device_descriptor_t),
    146             &actually_transferred, &handle);
    147         if (rc != EOK) {
    148                 return rc;
    149         }
    150         rc = usb_drv_async_wait_for(handle);
    151         if (rc != EOK) {
    152                 return rc;
    153         }
    154 
    155         /* Finish the control read transfer. */
    156         rc = usb_drv_async_control_read_status(phone, target, &handle);
    157         if (rc != EOK) {
    158                 return rc;
    159         }
    160         rc = usb_drv_async_wait_for(handle);
    161         if (rc != EOK) {
    162                 return rc;
    163         }
    164 
    165         if (actually_transferred < sizeof(usb_standard_device_descriptor_t)) {
     119        /* Verify that all data has been transferred. */
     120        if (actually_transferred < sizeof(descriptor_tmp)) {
    166121                return ELIMIT;
    167122        }
    168123
    169         /*
    170          * Everything is okay, copy the descriptor.
    171          */
     124        /* Everything is okay, copy the descriptor. */
    172125        memcpy(descriptor, &descriptor_tmp,
    173             sizeof(usb_standard_device_descriptor_t));
     126            sizeof(descriptor_tmp));
    174127
    175128        return EOK;
Note: See TracChangeset for help on using the changeset viewer.