Changeset a6afb4c in mainline for uspace/lib/usb/include
- Timestamp:
- 2018-01-23T14:02:35Z (7 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4db49344
- Parents:
- e7e1fd3
- git-author:
- Ondřej Hlavatý <aearsis@…> (2018-01-23 13:35:50)
- git-committer:
- Ondřej Hlavatý <aearsis@…> (2018-01-23 14:02:35)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/usb/include/usb/usb.h
re7e1fd3 ra6afb4c 63 63 } 64 64 65 static inline bool usb_speed_is_valid(const usb_speed_t s) 66 { 67 return (s >= USB_SPEED_LOW) && (s < USB_SPEED_MAX); 68 } 69 65 70 const char *usb_str_speed(usb_speed_t); 66 71 … … 97 102 static inline bool usb_address_is_valid(usb_address_t a) 98 103 { 99 return (a >= USB_ADDRESS_DEFAULT) && (a <= USB11_ADDRESS_MAX);104 return a <= USB11_ADDRESS_MAX; 100 105 } 101 106 … … 105 110 /** Maximum endpoint number in USB */ 106 111 #define USB_ENDPOINT_MAX 16 112 113 /** There might be two directions for every endpoint number (except 0) */ 114 #define USB_ENDPOINT_COUNT (2 * USB_ENDPOINT_MAX) 107 115 108 116 /** Check USB endpoint for allowed values. … … 115 123 static inline bool usb_endpoint_is_valid(usb_endpoint_t ep) 116 124 { 117 return (ep >= USB_ENDPOINT_DEFAULT_CONTROL) && 118 (ep < USB_ENDPOINT_MAX); 125 return ep < USB_ENDPOINT_MAX; 119 126 } 120 127 121 /** Check USB target for allowed values (address and endpoint). 128 /** 129 * Check USB target for allowed values (address, endpoint, stream). 122 130 * 123 131 * @param target. 124 132 * @return True, if values are wihtin limits, false otherwise. 125 133 */ 126 static inline bool usb_target_is_valid(usb_target_t target)134 static inline bool usb_target_is_valid(usb_target_t *target) 127 135 { 128 return usb_address_is_valid(target.address) && 129 usb_endpoint_is_valid(target.endpoint); 136 return usb_address_is_valid(target->address) && 137 usb_endpoint_is_valid(target->endpoint); 138 139 // A 16-bit Stream ID is always valid. 130 140 } 131 141 … … 136 146 * @return Whether @p a and @p b points to the same pipe on the same device. 137 147 */ 138 static inline intusb_target_same(usb_target_t a, usb_target_t b)148 static inline bool usb_target_same(usb_target_t a, usb_target_t b) 139 149 { 140 150 return (a.address == b.address) … … 142 152 } 143 153 144 /** General handle type. 145 * Used by various USB functions as opaque handle. 146 */ 147 typedef sysarg_t usb_handle_t; 154 static inline bool usb_transfer_type_is_valid(usb_transfer_type_t type) 155 { 156 return (type >= 0) && (type < USB_TRANSFER_COUNT); 157 } 158 159 static inline bool usb_direction_is_valid(usb_direction_t dir) 160 { 161 return (dir >= 0) && (dir < USB_DIRECTION_COUNT); 162 } 148 163 149 164 /** USB packet identifier. */
Note:
See TracChangeset
for help on using the changeset viewer.