usual-tables.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * Driver for USB Mass Storage devices
  4. * Usual Tables File for usb-storage and libusual
  5. *
  6. * Copyright (C) 2009 Alan Stern (stern@rowland.harvard.edu)
  7. *
  8. * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
  9. * information about this driver.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/module.h>
  13. #include <linux/usb.h>
  14. #include <linux/usb_usual.h>
  15. /*
  16. * The table of devices
  17. */
  18. #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
  19. vendorName, productName, useProtocol, useTransport, \
  20. initFunction, flags) \
  21. { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
  22. .driver_info = (flags) }
  23. #define COMPLIANT_DEV UNUSUAL_DEV
  24. #define USUAL_DEV(useProto, useTrans) \
  25. { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans) }
  26. /* Define the device is matched with Vendor ID and interface descriptors */
  27. #define UNUSUAL_VENDOR_INTF(id_vendor, cl, sc, pr, \
  28. vendorName, productName, useProtocol, useTransport, \
  29. initFunction, flags) \
  30. { \
  31. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \
  32. | USB_DEVICE_ID_MATCH_VENDOR, \
  33. .idVendor = (id_vendor), \
  34. .bInterfaceClass = (cl), \
  35. .bInterfaceSubClass = (sc), \
  36. .bInterfaceProtocol = (pr), \
  37. .driver_info = (flags) \
  38. }
  39. struct usb_device_id usb_storage_usb_ids[] = {
  40. # include "unusual_devs.h"
  41. { } /* Terminating entry */
  42. };
  43. MODULE_DEVICE_TABLE(usb, usb_storage_usb_ids);
  44. #undef UNUSUAL_DEV
  45. #undef COMPLIANT_DEV
  46. #undef USUAL_DEV
  47. #undef UNUSUAL_VENDOR_INTF
  48. /*
  49. * The table of devices to ignore
  50. */
  51. struct ignore_entry {
  52. u16 vid, pid, bcdmin, bcdmax;
  53. };
  54. #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
  55. vendorName, productName, useProtocol, useTransport, \
  56. initFunction, flags) \
  57. { \
  58. .vid = id_vendor, \
  59. .pid = id_product, \
  60. .bcdmin = bcdDeviceMin, \
  61. .bcdmax = bcdDeviceMax, \
  62. }
  63. static struct ignore_entry ignore_ids[] = {
  64. # include "unusual_alauda.h"
  65. # include "unusual_cypress.h"
  66. # include "unusual_datafab.h"
  67. # include "unusual_ene_ub6250.h"
  68. # include "unusual_freecom.h"
  69. # include "unusual_isd200.h"
  70. # include "unusual_jumpshot.h"
  71. # include "unusual_karma.h"
  72. # include "unusual_onetouch.h"
  73. # include "unusual_realtek.h"
  74. # include "unusual_sddr09.h"
  75. # include "unusual_sddr55.h"
  76. # include "unusual_usbat.h"
  77. { } /* Terminating entry */
  78. };
  79. #undef UNUSUAL_DEV
  80. /* Return an error if a device is in the ignore_ids list */
  81. int usb_usual_ignore_device(struct usb_interface *intf)
  82. {
  83. struct usb_device *udev;
  84. unsigned vid, pid, bcd;
  85. struct ignore_entry *p;
  86. udev = interface_to_usbdev(intf);
  87. vid = le16_to_cpu(udev->descriptor.idVendor);
  88. pid = le16_to_cpu(udev->descriptor.idProduct);
  89. bcd = le16_to_cpu(udev->descriptor.bcdDevice);
  90. for (p = ignore_ids; p->vid; ++p) {
  91. if (p->vid == vid && p->pid == pid &&
  92. p->bcdmin <= bcd && p->bcdmax >= bcd)
  93. return -ENXIO;
  94. }
  95. return 0;
  96. }