usual-tables.c 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. #include <linux/kernel.h>
  9. #include <linux/module.h>
  10. #include <linux/usb.h>
  11. #include <linux/usb_usual.h>
  12. /*
  13. * The table of devices
  14. */
  15. #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
  16. vendorName, productName, useProtocol, useTransport, \
  17. initFunction, flags) \
  18. { USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
  19. .driver_info = (flags) }
  20. #define COMPLIANT_DEV UNUSUAL_DEV
  21. #define USUAL_DEV(useProto, useTrans) \
  22. { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans) }
  23. /* Define the device is matched with Vendor ID and interface descriptors */
  24. #define UNUSUAL_VENDOR_INTF(id_vendor, cl, sc, pr, \
  25. vendorName, productName, useProtocol, useTransport, \
  26. initFunction, flags) \
  27. { \
  28. .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \
  29. | USB_DEVICE_ID_MATCH_VENDOR, \
  30. .idVendor = (id_vendor), \
  31. .bInterfaceClass = (cl), \
  32. .bInterfaceSubClass = (sc), \
  33. .bInterfaceProtocol = (pr), \
  34. .driver_info = (flags) \
  35. }
  36. struct usb_device_id usb_storage_usb_ids[] = {
  37. # include "unusual_devs.h"
  38. { } /* Terminating entry */
  39. };
  40. MODULE_DEVICE_TABLE(usb, usb_storage_usb_ids);
  41. #undef UNUSUAL_DEV
  42. #undef COMPLIANT_DEV
  43. #undef USUAL_DEV
  44. #undef UNUSUAL_VENDOR_INTF
  45. /*
  46. * The table of devices to ignore
  47. */
  48. struct ignore_entry {
  49. u16 vid, pid, bcdmin, bcdmax;
  50. };
  51. #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
  52. vendorName, productName, useProtocol, useTransport, \
  53. initFunction, flags) \
  54. { \
  55. .vid = id_vendor, \
  56. .pid = id_product, \
  57. .bcdmin = bcdDeviceMin, \
  58. .bcdmax = bcdDeviceMax, \
  59. }
  60. static struct ignore_entry ignore_ids[] = {
  61. # include "unusual_alauda.h"
  62. # include "unusual_cypress.h"
  63. # include "unusual_datafab.h"
  64. # include "unusual_ene_ub6250.h"
  65. # include "unusual_freecom.h"
  66. # include "unusual_isd200.h"
  67. # include "unusual_jumpshot.h"
  68. # include "unusual_karma.h"
  69. # include "unusual_onetouch.h"
  70. # include "unusual_realtek.h"
  71. # include "unusual_sddr09.h"
  72. # include "unusual_sddr55.h"
  73. # include "unusual_usbat.h"
  74. { } /* Terminating entry */
  75. };
  76. #undef UNUSUAL_DEV
  77. /* Return an error if a device is in the ignore_ids list */
  78. int usb_usual_ignore_device(struct usb_interface *intf)
  79. {
  80. struct usb_device *udev;
  81. unsigned vid, pid, bcd;
  82. struct ignore_entry *p;
  83. udev = interface_to_usbdev(intf);
  84. vid = le16_to_cpu(udev->descriptor.idVendor);
  85. pid = le16_to_cpu(udev->descriptor.idProduct);
  86. bcd = le16_to_cpu(udev->descriptor.bcdDevice);
  87. for (p = ignore_ids; p->vid; ++p) {
  88. if (p->vid == vid && p->pid == pid &&
  89. p->bcdmin <= bcd && p->bcdmax >= bcd)
  90. return -ENXIO;
  91. }
  92. return 0;
  93. }