Greg Kroah-Hartman | 5fd54ac | 2017-11-03 11:28:30 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Felipe Balbi | f0183a3 | 2016-04-18 13:09:11 +0300 | [diff] [blame] | 2 | /* |
| 3 | * Driver for USB Mass Storage devices |
Alan Stern | e6e244b | 2009-02-12 14:47:44 -0500 | [diff] [blame] | 4 | * Usual Tables File for usb-storage and libusual |
| 5 | * |
| 6 | * Copyright (C) 2009 Alan Stern (stern@rowland.harvard.edu) |
Alan Stern | e6e244b | 2009-02-12 14:47:44 -0500 | [diff] [blame] | 7 | */ |
| 8 | |
| 9 | #include <linux/kernel.h> |
| 10 | #include <linux/module.h> |
| 11 | #include <linux/usb.h> |
| 12 | #include <linux/usb_usual.h> |
| 13 | |
| 14 | |
| 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), \ |
Alan Stern | e6e244b | 2009-02-12 14:47:44 -0500 | [diff] [blame] | 22 | .driver_info = (flags) } |
| 23 | |
Sebastian Andrzej Siewior | f61870e | 2012-08-28 22:37:13 +0200 | [diff] [blame] | 24 | #define COMPLIANT_DEV UNUSUAL_DEV |
| 25 | |
| 26 | #define USUAL_DEV(useProto, useTrans) \ |
| 27 | { USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans) } |
Alan Stern | e6e244b | 2009-02-12 14:47:44 -0500 | [diff] [blame] | 28 | |
fangxiaozhi | 07c7be3 | 2013-02-04 15:14:46 +0800 | [diff] [blame] | 29 | /* Define the device is matched with Vendor ID and interface descriptors */ |
| 30 | #define UNUSUAL_VENDOR_INTF(id_vendor, cl, sc, pr, \ |
| 31 | vendorName, productName, useProtocol, useTransport, \ |
| 32 | initFunction, flags) \ |
| 33 | { \ |
| 34 | .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \ |
| 35 | | USB_DEVICE_ID_MATCH_VENDOR, \ |
| 36 | .idVendor = (id_vendor), \ |
| 37 | .bInterfaceClass = (cl), \ |
| 38 | .bInterfaceSubClass = (sc), \ |
| 39 | .bInterfaceProtocol = (pr), \ |
| 40 | .driver_info = (flags) \ |
| 41 | } |
| 42 | |
Alan Stern | e6e244b | 2009-02-12 14:47:44 -0500 | [diff] [blame] | 43 | struct usb_device_id usb_storage_usb_ids[] = { |
| 44 | # include "unusual_devs.h" |
| 45 | { } /* Terminating entry */ |
| 46 | }; |
Alan Stern | e6e244b | 2009-02-12 14:47:44 -0500 | [diff] [blame] | 47 | MODULE_DEVICE_TABLE(usb, usb_storage_usb_ids); |
| 48 | |
| 49 | #undef UNUSUAL_DEV |
| 50 | #undef COMPLIANT_DEV |
| 51 | #undef USUAL_DEV |
fangxiaozhi | 07c7be3 | 2013-02-04 15:14:46 +0800 | [diff] [blame] | 52 | #undef UNUSUAL_VENDOR_INTF |
Alan Stern | e6e244b | 2009-02-12 14:47:44 -0500 | [diff] [blame] | 53 | |
Alan Stern | e6e244b | 2009-02-12 14:47:44 -0500 | [diff] [blame] | 54 | /* |
| 55 | * The table of devices to ignore |
| 56 | */ |
| 57 | struct ignore_entry { |
| 58 | u16 vid, pid, bcdmin, bcdmax; |
| 59 | }; |
| 60 | |
| 61 | #define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \ |
| 62 | vendorName, productName, useProtocol, useTransport, \ |
| 63 | initFunction, flags) \ |
| 64 | { \ |
| 65 | .vid = id_vendor, \ |
| 66 | .pid = id_product, \ |
| 67 | .bcdmin = bcdDeviceMin, \ |
| 68 | .bcdmax = bcdDeviceMax, \ |
| 69 | } |
| 70 | |
| 71 | static struct ignore_entry ignore_ids[] = { |
Alan Stern | a74bba3 | 2009-02-12 14:48:22 -0500 | [diff] [blame] | 72 | # include "unusual_alauda.h" |
Alan Stern | fcdb514 | 2009-02-12 14:48:04 -0500 | [diff] [blame] | 73 | # include "unusual_cypress.h" |
Alan Stern | 2cbbf35 | 2009-02-12 14:48:15 -0500 | [diff] [blame] | 74 | # include "unusual_datafab.h" |
huajun li | 41e568d | 2011-03-04 10:56:18 +0800 | [diff] [blame] | 75 | # include "unusual_ene_ub6250.h" |
Alan Stern | 0d62939 | 2009-02-12 14:48:11 -0500 | [diff] [blame] | 76 | # include "unusual_freecom.h" |
Alan Stern | 32d5493 | 2009-02-12 14:47:54 -0500 | [diff] [blame] | 77 | # include "unusual_isd200.h" |
Alan Stern | a9fb6d0 | 2009-02-12 14:48:19 -0500 | [diff] [blame] | 78 | # include "unusual_jumpshot.h" |
Alan Stern | c103378 | 2009-02-12 14:48:26 -0500 | [diff] [blame] | 79 | # include "unusual_karma.h" |
Alan Stern | 9cfb95e | 2009-02-12 14:48:33 -0500 | [diff] [blame] | 80 | # include "unusual_onetouch.h" |
wwang | 50a6cb9 | 2011-01-14 16:53:34 +0800 | [diff] [blame] | 81 | # include "unusual_realtek.h" |
Alan Stern | 0ff7188 | 2009-02-12 14:47:49 -0500 | [diff] [blame] | 82 | # include "unusual_sddr09.h" |
Alan Stern | 70fcc00 | 2009-02-12 14:47:59 -0500 | [diff] [blame] | 83 | # include "unusual_sddr55.h" |
Alan Stern | 26d6818 | 2009-02-12 14:48:08 -0500 | [diff] [blame] | 84 | # include "unusual_usbat.h" |
Alan Stern | e6e244b | 2009-02-12 14:47:44 -0500 | [diff] [blame] | 85 | { } /* Terminating entry */ |
| 86 | }; |
| 87 | |
| 88 | #undef UNUSUAL_DEV |
| 89 | |
Alan Stern | e6e244b | 2009-02-12 14:47:44 -0500 | [diff] [blame] | 90 | /* Return an error if a device is in the ignore_ids list */ |
| 91 | int usb_usual_ignore_device(struct usb_interface *intf) |
| 92 | { |
| 93 | struct usb_device *udev; |
| 94 | unsigned vid, pid, bcd; |
| 95 | struct ignore_entry *p; |
| 96 | |
| 97 | udev = interface_to_usbdev(intf); |
| 98 | vid = le16_to_cpu(udev->descriptor.idVendor); |
| 99 | pid = le16_to_cpu(udev->descriptor.idProduct); |
| 100 | bcd = le16_to_cpu(udev->descriptor.bcdDevice); |
| 101 | |
| 102 | for (p = ignore_ids; p->vid; ++p) { |
| 103 | if (p->vid == vid && p->pid == pid && |
| 104 | p->bcdmin <= bcd && p->bcdmax >= bcd) |
| 105 | return -ENXIO; |
| 106 | } |
| 107 | return 0; |
| 108 | } |