usual-tables.c 3.3 KB

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