usual-tables.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* Driver for USB Mass Storage devices
  2. * Usual Tables File for usb-storage and libusual
  3. *
  4. * Copyright (C) 2009 Alan Stern (stern@rowland.harvard.edu)
  5. *
  6. * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
  7. * information about this driver.
  8. *
  9. * This program is free software; you can redistribute it and/or modify it
  10. * under the terms of the GNU General Public License as published by the
  11. * Free Software Foundation; either version 2, or (at your option) any
  12. * later version.
  13. *
  14. * This program is distributed in the hope that it will be useful, but
  15. * WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU General Public License along
  20. * with this program; if not, write to the Free Software Foundation, Inc.,
  21. * 675 Mass Ave, Cambridge, MA 02139, USA.
  22. */
  23. #include <linux/kernel.h>
  24. #include <linux/module.h>
  25. #include <linux/usb.h>
  26. #include <linux/usb_usual.h>
  27. /*
  28. * The table of devices
  29. */
  30. #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
  31. vendorName, productName, useProtocol, useTransport, \
  32. initFunction, flags) \
  33. { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
  34. .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
  35. #define COMPLIANT_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
  36. vendorName, productName, useProtocol, useTransport, \
  37. initFunction, flags) \
  38. { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
  39. .driver_info = (flags) }
  40. #define USUAL_DEV(useProto, useTrans, useType) \
  41. { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \
  42. .driver_info = ((useType)<<24) }
  43. /* Define the device is matched with Vendor ID and interface descriptors */
  44. #define UNUSUAL_VENDOR_INTF(id_vendor, cl, sc, pr, \
  45. vendorName, productName, useProtocol, useTransport, \
  46. initFunction, flags) \
  47. { \
  48. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \
  49. | USB_DEVICE_ID_MATCH_VENDOR, \
  50. .idVendor = (id_vendor), \
  51. .bInterfaceClass = (cl), \
  52. .bInterfaceSubClass = (sc), \
  53. .bInterfaceProtocol = (pr), \
  54. .driver_info = (flags) \
  55. }
  56. struct usb_device_id usb_storage_usb_ids[] = {
  57. # include "unusual_devs.h"
  58. { } /* Terminating entry */
  59. };
  60. EXPORT_SYMBOL_GPL(usb_storage_usb_ids);
  61. MODULE_DEVICE_TABLE(usb, usb_storage_usb_ids);
  62. #undef UNUSUAL_DEV
  63. #undef COMPLIANT_DEV
  64. #undef USUAL_DEV
  65. #undef UNUSUAL_VENDOR_INTF
  66. /*
  67. * The table of devices to ignore
  68. */
  69. struct ignore_entry {
  70. u16 vid, pid, bcdmin, bcdmax;
  71. };
  72. #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
  73. vendorName, productName, useProtocol, useTransport, \
  74. initFunction, flags) \
  75. { \
  76. .vid = id_vendor, \
  77. .pid = id_product, \
  78. .bcdmin = bcdDeviceMin, \
  79. .bcdmax = bcdDeviceMax, \
  80. }
  81. static struct ignore_entry ignore_ids[] = {
  82. # include "unusual_alauda.h"
  83. # include "unusual_cypress.h"
  84. # include "unusual_datafab.h"
  85. # include "unusual_ene_ub6250.h"
  86. # include "unusual_freecom.h"
  87. # include "unusual_isd200.h"
  88. # include "unusual_jumpshot.h"
  89. # include "unusual_karma.h"
  90. # include "unusual_onetouch.h"
  91. # include "unusual_realtek.h"
  92. # include "unusual_sddr09.h"
  93. # include "unusual_sddr55.h"
  94. # include "unusual_usbat.h"
  95. { } /* Terminating entry */
  96. };
  97. #undef UNUSUAL_DEV
  98. /* Return an error if a device is in the ignore_ids list */
  99. int usb_usual_ignore_device(struct usb_interface *intf)
  100. {
  101. struct usb_device *udev;
  102. unsigned vid, pid, bcd;
  103. struct ignore_entry *p;
  104. udev = interface_to_usbdev(intf);
  105. vid = le16_to_cpu(udev->descriptor.idVendor);
  106. pid = le16_to_cpu(udev->descriptor.idProduct);
  107. bcd = le16_to_cpu(udev->descriptor.bcdDevice);
  108. for (p = ignore_ids; p->vid; ++p) {
  109. if (p->vid == vid && p->pid == pid &&
  110. p->bcdmin <= bcd && p->bcdmax >= bcd)
  111. return -ENXIO;
  112. }
  113. return 0;
  114. }
  115. EXPORT_SYMBOL_GPL(usb_usual_ignore_device);