Changeset c9399c0 in mainline for uspace/lib/usbvirt


Ignore:
Timestamp:
2013-01-05T17:05:37Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2a6e2358
Parents:
d1974966
Message:

libusbvirt: Drop custom request type format.

use the one provided by libusb.

Location:
uspace/lib/usbvirt
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbvirt/include/usbvirt/device.h

    rd1974966 rc9399c0  
    9494 */
    9595typedef struct {
    96         /** Request direction (in or out). */
    97         usb_direction_t req_direction;
    98         /** Request recipient (device, interface or endpoint). */
    99         usb_request_recipient_t req_recipient;
    100         /** Request type (standard, class or vendor). */
    101         usb_request_type_t req_type;
     96        /* Request type. See usb/request.h */
     97        uint8_t request_type;
    10298        /** Actual request code. */
    10399        uint8_t request;
  • uspace/lib/usbvirt/src/ctrltransfer.c

    rd1974966 rc9399c0  
    6060                return EFORWARD;
    6161        }
    62 
    63         usb_direction_t direction = setup->request_type & 128 ?
    64             USB_DIRECTION_IN : USB_DIRECTION_OUT;
    65         usb_request_recipient_t req_recipient = setup->request_type & 31;
    66         usb_request_type_t req_type = (setup->request_type >> 5) & 3;
    67 
    6862        usbvirt_control_request_handler_t *handler = control_handlers;
    69         while (handler->callback != NULL) {
    70                 if (handler->req_direction != direction) {
    71                         goto next;
    72                 }
    73                 if (handler->req_recipient != req_recipient) {
    74                         goto next;
    75                 }
    76                 if (handler->req_type != req_type) {
    77                         goto next;
    78                 }
    79                 if (handler->request != setup->request) {
    80                         goto next;
     63        for (;handler->callback != NULL; ++handler) {
     64                if (handler->request != setup->request ||
     65                    handler->request_type != setup->request_type) {
     66                        continue;
    8167                }
    8268
     
    8470                    usb_debug_str_buffer((uint8_t*) setup, sizeof(*setup), 0));
    8571                int rc = handler->callback(dev, setup, data, data_sent_size);
    86                 if (rc == EFORWARD) {
    87                         goto next;
     72                if (rc != EFORWARD) {
     73                        return rc;
    8874                }
    8975
    90                 return rc;
    91 
    92 next:
    93                 handler++;
    9476        }
    9577
  • uspace/lib/usbvirt/src/stdreq.c

    rd1974966 rc9399c0  
    192192usbvirt_control_request_handler_t library_handlers[] = {
    193193        {
    194                 .req_direction = USB_DIRECTION_OUT,
    195                 .req_recipient = USB_REQUEST_RECIPIENT_DEVICE,
    196                 .req_type = USB_REQUEST_TYPE_STANDARD,
     194                .request_type = SETUP_REQUEST_TO_DEVICE(USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE),
    197195                .request = USB_DEVREQ_SET_ADDRESS,
    198196                .name = "SetAddress",
     
    200198        },
    201199        {
    202                 .req_direction = USB_DIRECTION_IN,
    203                 .req_recipient = USB_REQUEST_RECIPIENT_DEVICE,
    204                 .req_type = USB_REQUEST_TYPE_STANDARD,
     200                .request_type = SETUP_REQUEST_TO_HOST(USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE),
    205201                .request = USB_DEVREQ_GET_DESCRIPTOR,
    206202                .name = "GetDescriptor",
     
    208204        },
    209205        {
    210                 .req_direction = USB_DIRECTION_OUT,
    211                 .req_recipient = USB_REQUEST_RECIPIENT_DEVICE,
    212                 .req_type = USB_REQUEST_TYPE_STANDARD,
     206                .request_type = SETUP_REQUEST_TO_DEVICE(USB_REQUEST_TYPE_STANDARD, USB_REQUEST_RECIPIENT_DEVICE),
    213207                .request = USB_DEVREQ_SET_CONFIGURATION,
    214208                .name = "SetConfiguration",
    215209                .callback = req_set_configuration
    216210        },
    217 
    218211        { .callback = NULL }
    219212};
Note: See TracChangeset for help on using the changeset viewer.