usual-tables.c 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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) }
  35. #define COMPLIANT_DEV UNUSUAL_DEV
  36. #define USUAL_DEV(useProto, useTrans) \
  37. { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans) }
  38. /* Define the device is matched with Vendor ID and interface descriptors */
  39. #define UNUSUAL_VENDOR_INTF(id_vendor, cl, sc, pr, \
  40. vendorName, productName, useProtocol, useTransport, \
  41. initFunction, flags) \
  42. { \
  43. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \
  44. | USB_DEVICE_ID_MATCH_VENDOR, \
  45. .idVendor = (id_vendor), \
  46. .bInterfaceClass = (cl), \
  47. .bInterfaceSubClass = (sc), \
  48. .bInterfaceProtocol = (pr), \
  49. .driver_info = (flags) \
  50. }
  51. struct usb_device_id usb_storage_usb_ids[] = {
  52. # include "unusual_devs.h"
  53. { } /* Terminating entry */
  54. };
  55. MODULE_DEVICE_TABLE(usb, usb_storage_usb_ids);
  56. #undef UNUSUAL_DEV
  57. #undef COMPLIANT_DEV
  58. #undef USUAL_DEV
  59. #undef UNUSUAL_VENDOR_INTF
  60. /*
  61. * The table of devices to ignore
  62. */
  63. struct ignore_entry {
  64. u16 vid, pid, bcdmin, bcdmax;
  65. };
  66. #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
  67. vendorName, productName, useProtocol, useTransport, \
  68. initFunction, flags) \
  69. { \
  70. .vid = id_vendor, \
  71. .pid = id_product, \
  72. .bcdmin = bcdDeviceMin, \
  73. .bcdmax = bcdDeviceMax, \
  74. }
  75. static struct ignore_entry ignore_ids[] = {
  76. # include "unusual_alauda.h"
  77. # include "unusual_cypress.h"
  78. # include "unusual_datafab.h"
  79. # include "unusual_ene_ub6250.h"
  80. # include "unusual_freecom.h"
  81. # include "unusual_isd200.h"
  82. # include "unusual_jumpshot.h"
  83. # include "unusual_karma.h"
  84. # include "unusual_onetouch.h"
  85. # include "unusual_realtek.h"
  86. # include "unusual_sddr09.h"
  87. # include "unusual_sddr55.h"
  88. # include "unusual_usbat.h"
  89. { } /* Terminating entry */
  90. };
  91. #undef UNUSUAL_DEV
  92. /* Return an error if a device is in the ignore_ids list */
  93. int usb_usual_ignore_device(struct usb_interface *intf)
  94. {
  95. struct usb_device *udev;
  96. unsigned vid, pid, bcd;
  97. struct ignore_entry *p;
  98. udev = interface_to_usbdev(intf);
  99. vid = le16_to_cpu(udev->descriptor.idVendor);
  100. pid = le16_to_cpu(udev->descriptor.idProduct);
  101. bcd = le16_to_cpu(udev->descriptor.bcdDevice);
  102. for (p = ignore_ids; p->vid; ++p) {
  103. if (p->vid == vid && p->pid == pid &&
  104. p->bcdmin <= bcd && p->bcdmax >= bcd)
  105. return -ENXIO;
  106. }
  107. return 0;
  108. }