usb.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. linux/usb.h compatibility header
  3. Copyright (C) 2003 Bernd Porr, Bernd.Porr@cn.stir.ac.uk
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  15. */
  16. #ifndef __COMPAT_LINUX_USB_H_
  17. #define __COMPAT_LINUX_USB_H_
  18. #include <linux/version.h>
  19. #include <linux/time.h>
  20. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,0)
  21. #define USB_ALLOC_URB(x) usb_alloc_urb(x)
  22. #define USB_SUBMIT_URB(x) usb_submit_urb(x)
  23. #define URB_ISO_ASAP USB_ISO_ASAP
  24. #define PROBE_ERR_RETURN(x) NULL
  25. #else
  26. #define USB_ALLOC_URB(x) usb_alloc_urb(x,GFP_KERNEL)
  27. #define USB_SUBMIT_URB(x) usb_submit_urb(x,GFP_ATOMIC)
  28. #define PROBE_ERR_RETURN(x) x
  29. #endif
  30. #include_next <linux/usb.h>
  31. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
  32. static inline int USB_CONTROL_MSG(struct usb_device *dev, unsigned int pipe,
  33. __u8 request, __u8 requesttype, __u16 value, __u16 index,
  34. void *data, __u16 size, int millisec_timeout)
  35. {
  36. return usb_control_msg(dev, pipe, request, requesttype, value, index,
  37. data, size, msecs_to_jiffies(millisec_timeout));
  38. }
  39. static inline int USB_BULK_MSG(struct usb_device *usb_dev, unsigned int pipe,
  40. void *data, int len, int *actual_length,
  41. int millisec_timeout)
  42. {
  43. return usb_bulk_msg(usb_dev, pipe, data, len, actual_length, msecs_to_jiffies(millisec_timeout));
  44. }
  45. #else
  46. #define USB_CONTROL_MSG usb_control_msg
  47. #define USB_BULK_MSG usb_bulk_msg
  48. #endif
  49. static inline uint16_t USBID_TO_CPU(uint16_t id)
  50. {
  51. #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
  52. return id;
  53. #else
  54. return le16_to_cpu(id);
  55. #endif // LINUX_VERSION_CODE < KERNEL_VERSION(2,6,11)
  56. };
  57. #endif