usual-tables.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. struct usb_device_id usb_storage_usb_ids[] = {
  39. # include "unusual_devs.h"
  40. { } /* Terminating entry */
  41. };
  42. MODULE_DEVICE_TABLE(usb, usb_storage_usb_ids);
  43. #undef UNUSUAL_DEV
  44. #undef COMPLIANT_DEV
  45. #undef USUAL_DEV
  46. /*
  47. * The table of devices to ignore
  48. */
  49. struct ignore_entry {
  50. u16 vid, pid, bcdmin, bcdmax;
  51. };
  52. #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
  53. vendorName, productName, useProtocol, useTransport, \
  54. initFunction, flags) \
  55. { \
  56. .vid = id_vendor, \
  57. .pid = id_product, \
  58. .bcdmin = bcdDeviceMin, \
  59. .bcdmax = bcdDeviceMax, \
  60. }
  61. static struct ignore_entry ignore_ids[] = {
  62. # include "unusual_alauda.h"
  63. # include "unusual_cypress.h"
  64. # include "unusual_datafab.h"
  65. # include "unusual_ene_ub6250.h"
  66. # include "unusual_freecom.h"
  67. # include "unusual_isd200.h"
  68. # include "unusual_jumpshot.h"
  69. # include "unusual_karma.h"
  70. # include "unusual_onetouch.h"
  71. # include "unusual_realtek.h"
  72. # include "unusual_sddr09.h"
  73. # include "unusual_sddr55.h"
  74. # include "unusual_usbat.h"
  75. { } /* Terminating entry */
  76. };
  77. #undef UNUSUAL_DEV
  78. /* Return an error if a device is in the ignore_ids list */
  79. int usb_usual_ignore_device(struct usb_interface *intf)
  80. {
  81. struct usb_device *udev;
  82. unsigned vid, pid, bcd;
  83. struct ignore_entry *p;
  84. udev = interface_to_usbdev(intf);
  85. vid = le16_to_cpu(udev->descriptor.idVendor);
  86. pid = le16_to_cpu(udev->descriptor.idProduct);
  87. bcd = le16_to_cpu(udev->descriptor.bcdDevice);
  88. for (p = ignore_ids; p->vid; ++p) {
  89. if (p->vid == vid && p->pid == pid &&
  90. p->bcdmin <= bcd && p->bcdmax >= bcd)
  91. return -ENXIO;
  92. }
  93. return 0;
  94. }