usual-tables.c 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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 = (kernel_ulong_t)(flags) }
  20. #define COMPLIANT_DEV UNUSUAL_DEV
  21. #define USUAL_DEV(useProto, useTrans) \
  22. { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans) }
  23. const struct usb_device_id usb_storage_usb_ids[] = {
  24. # include "unusual_devs.h"
  25. { } /* Terminating entry */
  26. };
  27. MODULE_DEVICE_TABLE(usb, usb_storage_usb_ids);
  28. #undef UNUSUAL_DEV
  29. #undef COMPLIANT_DEV
  30. #undef USUAL_DEV
  31. /*
  32. * The table of devices to ignore
  33. */
  34. struct ignore_entry {
  35. u16 vid, pid, bcdmin, bcdmax;
  36. };
  37. #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
  38. vendorName, productName, useProtocol, useTransport, \
  39. initFunction, flags) \
  40. { \
  41. .vid = id_vendor, \
  42. .pid = id_product, \
  43. .bcdmin = bcdDeviceMin, \
  44. .bcdmax = bcdDeviceMax, \
  45. }
  46. static const struct ignore_entry ignore_ids[] = {
  47. # include "unusual_alauda.h"
  48. # include "unusual_cypress.h"
  49. # include "unusual_datafab.h"
  50. # include "unusual_ene_ub6250.h"
  51. # include "unusual_freecom.h"
  52. # include "unusual_isd200.h"
  53. # include "unusual_jumpshot.h"
  54. # include "unusual_karma.h"
  55. # include "unusual_onetouch.h"
  56. # include "unusual_realtek.h"
  57. # include "unusual_sddr09.h"
  58. # include "unusual_sddr55.h"
  59. # include "unusual_usbat.h"
  60. { } /* Terminating entry */
  61. };
  62. #undef UNUSUAL_DEV
  63. /* Return an error if a device is in the ignore_ids list */
  64. int usb_usual_ignore_device(struct usb_interface *intf)
  65. {
  66. struct usb_device *udev;
  67. unsigned vid, pid, bcd;
  68. const struct ignore_entry *p;
  69. udev = interface_to_usbdev(intf);
  70. vid = le16_to_cpu(udev->descriptor.idVendor);
  71. pid = le16_to_cpu(udev->descriptor.idProduct);
  72. bcd = le16_to_cpu(udev->descriptor.bcdDevice);
  73. for (p = ignore_ids; p->vid; ++p) {
  74. if (p->vid == vid && p->pid == pid &&
  75. p->bcdmin <= bcd && p->bcdmax >= bcd)
  76. return -ENXIO;
  77. }
  78. return 0;
  79. }