usual-tables.c 3.5 KB

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