Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/usb.h

    rfa9d3af r3e6a98c5  
    8484} usb_speed_t;
    8585
    86 static inline bool usb_speed_is_11(const usb_speed_t s)
    87 {
    88         return (s == USB_SPEED_FULL) || (s == USB_SPEED_LOW);
    89 }
    90 
    9186const char *usb_str_speed(usb_speed_t);
    9287
     
    115110#define USB_ADDRESS_DEFAULT 0
    116111/** Maximum address number in USB 1.1. */
    117 #define USB11_ADDRESS_MAX 127
    118 #define USB_ADDRESS_COUNT (USB11_ADDRESS_MAX + 1)
    119 
    120 /** Check USB address for allowed values.
    121  *
    122  * @param ep USB address.
    123  * @return True, if value is wihtin limits, false otherwise.
    124  */
    125 static inline bool usb_address_is_valid(usb_address_t a)
    126 {
    127         return (a >= USB_ADDRESS_DEFAULT) && (a <= USB11_ADDRESS_MAX);
    128 }
     112#define USB11_ADDRESS_MAX 128
    129113
    130114/** USB endpoint number type.
     
    133117typedef int16_t usb_endpoint_t;
    134118
    135 /** Default control endpoint */
    136 #define USB_ENDPOINT_DEFAULT_CONTROL 0
    137 /** Maximum endpoint number in USB 1.1. */
     119/** Maximum endpoint number in USB 1.1.
     120 */
    138121#define USB11_ENDPOINT_MAX 16
    139 
    140 /** Check USB endpoint for allowed values.
    141  *
    142  * @param ep USB endpoint number.
    143  * @return True, if value is wihtin limits, false otherwise.
    144  */
    145 static inline bool usb_endpoint_is_valid(usb_endpoint_t ep)
    146 {
    147         return (ep >= USB_ENDPOINT_DEFAULT_CONTROL) &&
    148             (ep < USB11_ENDPOINT_MAX);
    149 }
    150122
    151123
     
    161133} usb_target_t;
    162134
    163 
    164135/** Check USB target for allowed values (address and endpoint).
    165136 *
     
    169140static inline bool usb_target_is_valid(usb_target_t target)
    170141{
    171         return usb_address_is_valid(target.address) &&
    172             usb_endpoint_is_valid(target.endpoint);
     142        return !(target.endpoint > 15 || target.endpoint < 0
     143            || target.address >= USB11_ADDRESS_MAX || target.address < 0);
    173144}
    174145
Note: See TracChangeset for help on using the changeset viewer.