| #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_CODE < KERNEL_VERSION(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_CODE < KERNEL_VERSION(3,2,0) */ |
| |
| #endif /* __BACKPORT_USB_H */ |