Merge branch 'core-objtool-for-linus' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-block.git] / drivers / usb / storage / usual-tables.c
CommitLineData
5fd54ace 1// SPDX-License-Identifier: GPL-2.0+
f0183a33
FB
2/*
3 * Driver for USB Mass Storage devices
e6e244b6
AS
4 * Usual Tables File for usb-storage and libusual
5 *
6 * Copyright (C) 2009 Alan Stern (stern@rowland.harvard.edu)
e6e244b6
AS
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) \
e6e244b6
AS
21{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
22 .driver_info = (flags) }
23
f61870ee
SAS
24#define COMPLIANT_DEV UNUSUAL_DEV
25
26#define USUAL_DEV(useProto, useTrans) \
27{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans) }
e6e244b6 28
07c7be3d 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
10892847 43const struct usb_device_id usb_storage_usb_ids[] = {
e6e244b6
AS
44# include "unusual_devs.h"
45 { } /* Terminating entry */
46};
e6e244b6
AS
47MODULE_DEVICE_TABLE(usb, usb_storage_usb_ids);
48
49#undef UNUSUAL_DEV
50#undef COMPLIANT_DEV
51#undef USUAL_DEV
07c7be3d 52#undef UNUSUAL_VENDOR_INTF
e6e244b6 53
e6e244b6
AS
54/*
55 * The table of devices to ignore
56 */
57struct 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
10892847 71static const struct ignore_entry ignore_ids[] = {
a74bba3b 72# include "unusual_alauda.h"
fcdb5140 73# include "unusual_cypress.h"
2cbbf357 74# include "unusual_datafab.h"
41e568d1 75# include "unusual_ene_ub6250.h"
0d62939f 76# include "unusual_freecom.h"
32d5493e 77# include "unusual_isd200.h"
a9fb6d05 78# include "unusual_jumpshot.h"
c1033784 79# include "unusual_karma.h"
9cfb95ef 80# include "unusual_onetouch.h"
50a6cb93 81# include "unusual_realtek.h"
0ff71883 82# include "unusual_sddr09.h"
70fcc005 83# include "unusual_sddr55.h"
26d6818f 84# include "unusual_usbat.h"
e6e244b6
AS
85 { } /* Terminating entry */
86};
87
88#undef UNUSUAL_DEV
89
e6e244b6
AS
90/* Return an error if a device is in the ignore_ids list */
91int usb_usual_ignore_device(struct usb_interface *intf)
92{
93 struct usb_device *udev;
94 unsigned vid, pid, bcd;
10892847 95 const struct ignore_entry *p;
e6e244b6
AS
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}