diff options
author | Dominik Sliwa <dominik.sliwa@toradex.com> | 2017-07-02 16:41:37 +0200 |
---|---|---|
committer | Dominik Sliwa <dominik.sliwa@toradex.com> | 2017-07-02 16:41:37 +0200 |
commit | 52409fae3e4b8d16b68b61902fc09075cd97b75d (patch) | |
tree | e67110145c5843b3f199d872ae285e2546c9ebe2 /backport-include/linux/usb.h |
Backports generated from 4.11 kernel
Initial commit.
Signed-off-by: Dominik Sliwa <dominik.sliwa@toradex.com>
Diffstat (limited to 'backport-include/linux/usb.h')
-rw-r--r-- | backport-include/linux/usb.h | 95 |
1 files changed, 95 insertions, 0 deletions
diff --git a/backport-include/linux/usb.h b/backport-include/linux/usb.h new file mode 100644 index 0000000..1873a33 --- /dev/null +++ b/backport-include/linux/usb.h @@ -0,0 +1,95 @@ +#ifndef __BACKPORT_USB_H +#define __BACKPORT_USB_H + +#include_next <linux/usb.h> +#include <linux/version.h> + +#ifndef module_usb_driver +/** + * module_usb_driver() - Helper macro for registering a USB driver + * @__usb_driver: usb_driver struct + * + * Helper macro for USB drivers which do not do anything special in module + * init/exit. This eliminates a lot of boilerplate. Each module may only + * use this macro once, and calling it replaces module_init() and module_exit() + */ +#define module_usb_driver(__usb_driver) \ + module_driver(__usb_driver, usb_register, \ + usb_deregister) +#endif + +#ifndef USB_VENDOR_AND_INTERFACE_INFO +/** + * Backports + * + * commit d81a5d1956731c453b85c141458d4ff5d6cc5366 + * Author: Gustavo Padovan <gustavo.padovan@collabora.co.uk> + * Date: Tue Jul 10 19:10:06 2012 -0300 + * + * USB: add USB_VENDOR_AND_INTERFACE_INFO() macro + */ +#define USB_VENDOR_AND_INTERFACE_INFO(vend, cl, sc, pr) \ + .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \ + | USB_DEVICE_ID_MATCH_VENDOR, \ + .idVendor = (vend), \ + .bInterfaceClass = (cl), \ + .bInterfaceSubClass = (sc), \ + .bInterfaceProtocol = (pr) +#endif /* USB_VENDOR_AND_INTERFACE_INFO */ + +#ifndef USB_DEVICE_INTERFACE_NUMBER +/** + * USB_DEVICE_INTERFACE_NUMBER - describe a usb device with a specific interface number + * @vend: the 16 bit USB Vendor ID + * @prod: the 16 bit USB Product ID + * @num: bInterfaceNumber value + * + * This macro is used to create a struct usb_device_id that matches a + * specific interface number of devices. + */ +#define USB_DEVICE_INTERFACE_NUMBER(vend, prod, num) \ + .match_flags = USB_DEVICE_ID_MATCH_DEVICE, \ + .idVendor = (vend), \ + .idProduct = (prod) +#endif /* USB_DEVICE_INTERFACE_NUMBER */ + +#ifndef USB_DEVICE_INTERFACE_CLASS +/** + * USB_DEVICE_INTERFACE_CLASS - describe a usb device with a specific interface class + * @vend: the 16 bit USB Vendor ID + * @prod: the 16 bit USB Product ID + * @cl: bInterfaceClass value + * + * This macro is used to create a struct usb_device_id that matches a + * specific interface class of devices. + */ +#define USB_DEVICE_INTERFACE_CLASS(vend, prod, cl) \ + .match_flags = USB_DEVICE_ID_MATCH_DEVICE | \ + USB_DEVICE_ID_MATCH_INT_CLASS, \ + .idVendor = (vend), \ + .idProduct = (prod), \ + .bInterfaceClass = (cl) +#endif /* USB_DEVICE_INTERFACE_CLASS */ + +#ifndef USB_SUBCLASS_VENDOR_SPEC +/* this is defined in usb/ch9.h, but we only need it through here */ +#define USB_SUBCLASS_VENDOR_SPEC 0xff +#endif + +#if LINUX_VERSION_IS_LESS(3,2,0) +#define usb_translate_errors LINUX_BACKPORT(usb_translate_errors) +static inline int usb_translate_errors(int error_code) +{ + switch (error_code) { + case 0: + case -ENOMEM: + case -ENODEV: + case -EOPNOTSUPP: + return error_code; + default: + return -EIO; + } +} +#endif /* LINUX_VERSION_IS_LESS(3,2,0) */ + +#endif /* __BACKPORT_USB_H */ |