Changes in uspace/lib/usb/src/usb.c [58563585:9d58539] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/src/usb.c
r58563585 r9d58539 34 34 */ 35 35 #include <usb/usb.h> 36 #include < usb/request.h>36 #include <errno.h> 37 37 38 #include <assert.h> 39 #include <byteorder.h> 40 #include <macros.h> 38 #define ARR_SIZE(arr) (sizeof(arr)/sizeof(arr[0])) 41 39 42 40 static const char *str_speed[] = { … … 73 71 const char *usb_str_transfer_type(usb_transfer_type_t t) 74 72 { 75 if (t >= ARR AY_SIZE(str_transfer_type)) {73 if (t >= ARR_SIZE(str_transfer_type)) { 76 74 return "invalid"; 77 75 } … … 86 84 const char *usb_str_transfer_type_short(usb_transfer_type_t t) 87 85 { 88 if (t >= ARR AY_SIZE(str_transfer_type_short)) {86 if (t >= ARR_SIZE(str_transfer_type_short)) { 89 87 return "invl"; 90 88 } … … 99 97 const char *usb_str_direction(usb_direction_t d) 100 98 { 101 if (d >= ARR AY_SIZE(str_direction)) {99 if (d >= ARR_SIZE(str_direction)) { 102 100 return "invalid"; 103 101 } … … 112 110 const char *usb_str_speed(usb_speed_t s) 113 111 { 114 if (s >= ARR AY_SIZE(str_speed)) {112 if (s >= ARR_SIZE(str_speed)) { 115 113 return "invalid"; 116 114 } … … 118 116 } 119 117 120 /** Check setup packet data for signs of toggle reset.121 *122 * @param[in] requst Setup requst data.123 *124 * @retval -1 No endpoints need reset.125 * @retval 0 All endpoints need reset.126 * @retval >0 Specified endpoint needs reset.127 *128 */129 int usb_request_needs_toggle_reset(130 const usb_device_request_setup_packet_t *request)131 {132 assert(request);133 switch (request->request)134 {135 /* Clear Feature ENPOINT_STALL */136 case USB_DEVREQ_CLEAR_FEATURE: /*resets only cleared ep */137 /* 0x2 ( HOST to device | STANDART | TO ENPOINT) */138 if ((request->request_type == 0x2) &&139 (request->value == USB_FEATURE_ENDPOINT_HALT))140 return uint16_usb2host(request->index);141 break;142 case USB_DEVREQ_SET_CONFIGURATION:143 case USB_DEVREQ_SET_INTERFACE:144 /* Recipient must be device, this resets all endpoints,145 * In fact there should be no endpoints but EP 0 registered146 * as different interfaces use different endpoints,147 * unless you're changing configuration or alternative148 * interface of an already setup device. */149 if (!(request->request_type & SETUP_REQUEST_TYPE_DEVICE_TO_HOST))150 return 0;151 break;152 default:153 break;154 }155 return -1;156 }157 158 118 /** 159 119 * @}
Note:
See TracChangeset
for help on using the changeset viewer.