blob: 90ac516c1f12d506d8d74687968e7a51836dd885 [file] [log] [blame]
Greg Kroah-Hartman5fd54ac2017-11-03 11:28:30 +01001// SPDX-License-Identifier: GPL-2.0+
Felipe Balbif0183a32016-04-18 13:09:11 +03002/*
3 * Driver for USB Mass Storage devices
Alan Sterne6e244b2009-02-12 14:47:44 -05004 * Usual Tables File for usb-storage and libusual
5 *
6 * Copyright (C) 2009 Alan Stern (stern@rowland.harvard.edu)
7 *
8 * Please see http://www.one-eyed-alien.net/~mdharm/linux-usb for more
9 * information about this driver.
10 *
11 * This program is free software; you can redistribute it and/or modify it
12 * under the terms of the GNU General Public License as published by the
13 * Free Software Foundation; either version 2, or (at your option) any
14 * later version.
15 *
16 * This program is distributed in the hope that it will be useful, but
17 * WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 * General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 675 Mass Ave, Cambridge, MA 02139, USA.
24 */
25
26#include <linux/kernel.h>
27#include <linux/module.h>
28#include <linux/usb.h>
29#include <linux/usb_usual.h>
30
31
32/*
33 * The table of devices
34 */
35#define UNUSUAL_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), \
Alan Sterne6e244b2009-02-12 14:47:44 -050039 .driver_info = (flags) }
40
Sebastian Andrzej Siewiorf61870e2012-08-28 22:37:13 +020041#define COMPLIANT_DEV UNUSUAL_DEV
42
43#define USUAL_DEV(useProto, useTrans) \
44{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans) }
Alan Sterne6e244b2009-02-12 14:47:44 -050045
fangxiaozhi07c7be32013-02-04 15:14:46 +080046/* Define the device is matched with Vendor ID and interface descriptors */
47#define UNUSUAL_VENDOR_INTF(id_vendor, cl, sc, pr, \
48 vendorName, productName, useProtocol, useTransport, \
49 initFunction, flags) \
50{ \
51 .match_flags = USB_DEVICE_ID_MATCH_INT_INFO \
52 | USB_DEVICE_ID_MATCH_VENDOR, \
53 .idVendor = (id_vendor), \
54 .bInterfaceClass = (cl), \
55 .bInterfaceSubClass = (sc), \
56 .bInterfaceProtocol = (pr), \
57 .driver_info = (flags) \
58}
59
Alan Sterne6e244b2009-02-12 14:47:44 -050060struct usb_device_id usb_storage_usb_ids[] = {
61# include "unusual_devs.h"
62 { } /* Terminating entry */
63};
Alan Sterne6e244b2009-02-12 14:47:44 -050064MODULE_DEVICE_TABLE(usb, usb_storage_usb_ids);
65
66#undef UNUSUAL_DEV
67#undef COMPLIANT_DEV
68#undef USUAL_DEV
fangxiaozhi07c7be32013-02-04 15:14:46 +080069#undef UNUSUAL_VENDOR_INTF
Alan Sterne6e244b2009-02-12 14:47:44 -050070
Alan Sterne6e244b2009-02-12 14:47:44 -050071/*
72 * The table of devices to ignore
73 */
74struct ignore_entry {
75 u16 vid, pid, bcdmin, bcdmax;
76};
77
78#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
79 vendorName, productName, useProtocol, useTransport, \
80 initFunction, flags) \
81{ \
82 .vid = id_vendor, \
83 .pid = id_product, \
84 .bcdmin = bcdDeviceMin, \
85 .bcdmax = bcdDeviceMax, \
86}
87
88static struct ignore_entry ignore_ids[] = {
Alan Sterna74bba32009-02-12 14:48:22 -050089# include "unusual_alauda.h"
Alan Sternfcdb5142009-02-12 14:48:04 -050090# include "unusual_cypress.h"
Alan Stern2cbbf352009-02-12 14:48:15 -050091# include "unusual_datafab.h"
huajun li41e568d2011-03-04 10:56:18 +080092# include "unusual_ene_ub6250.h"
Alan Stern0d629392009-02-12 14:48:11 -050093# include "unusual_freecom.h"
Alan Stern32d54932009-02-12 14:47:54 -050094# include "unusual_isd200.h"
Alan Sterna9fb6d02009-02-12 14:48:19 -050095# include "unusual_jumpshot.h"
Alan Sternc1033782009-02-12 14:48:26 -050096# include "unusual_karma.h"
Alan Stern9cfb95e2009-02-12 14:48:33 -050097# include "unusual_onetouch.h"
wwang50a6cb92011-01-14 16:53:34 +080098# include "unusual_realtek.h"
Alan Stern0ff71882009-02-12 14:47:49 -050099# include "unusual_sddr09.h"
Alan Stern70fcc002009-02-12 14:47:59 -0500100# include "unusual_sddr55.h"
Alan Stern26d68182009-02-12 14:48:08 -0500101# include "unusual_usbat.h"
Alan Sterne6e244b2009-02-12 14:47:44 -0500102 { } /* Terminating entry */
103};
104
105#undef UNUSUAL_DEV
106
Alan Sterne6e244b2009-02-12 14:47:44 -0500107/* Return an error if a device is in the ignore_ids list */
108int usb_usual_ignore_device(struct usb_interface *intf)
109{
110 struct usb_device *udev;
111 unsigned vid, pid, bcd;
112 struct ignore_entry *p;
113
114 udev = interface_to_usbdev(intf);
115 vid = le16_to_cpu(udev->descriptor.idVendor);
116 pid = le16_to_cpu(udev->descriptor.idProduct);
117 bcd = le16_to_cpu(udev->descriptor.bcdDevice);
118
119 for (p = ignore_ids; p->vid; ++p) {
120 if (p->vid == vid && p->pid == pid &&
121 p->bcdmin <= bcd && p->bcdmax >= bcd)
122 return -ENXIO;
123 }
124 return 0;
125}