Loading...
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Driver for USB Mass Storage devices
4 * Usual Tables File for usb-storage and libusual
5 *
6 * Copyright (C) 2009 Alan Stern (stern@rowland.harvard.edu)
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), \
22 .driver_info = (flags) }
23
24#define COMPLIANT_DEV UNUSUAL_DEV
25
26#define USUAL_DEV(useProto, useTrans) \
27{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans) }
28
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
43const struct usb_device_id usb_storage_usb_ids[] = {
44# include "unusual_devs.h"
45 { } /* Terminating entry */
46};
47MODULE_DEVICE_TABLE(usb, usb_storage_usb_ids);
48
49#undef UNUSUAL_DEV
50#undef COMPLIANT_DEV
51#undef USUAL_DEV
52#undef UNUSUAL_VENDOR_INTF
53
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
71static const struct ignore_entry ignore_ids[] = {
72# include "unusual_alauda.h"
73# include "unusual_cypress.h"
74# include "unusual_datafab.h"
75# include "unusual_ene_ub6250.h"
76# include "unusual_freecom.h"
77# include "unusual_isd200.h"
78# include "unusual_jumpshot.h"
79# include "unusual_karma.h"
80# include "unusual_onetouch.h"
81# include "unusual_realtek.h"
82# include "unusual_sddr09.h"
83# include "unusual_sddr55.h"
84# include "unusual_usbat.h"
85 { } /* Terminating entry */
86};
87
88#undef UNUSUAL_DEV
89
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;
95 const 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}
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
24#include <linux/kernel.h>
25#include <linux/module.h>
26#include <linux/usb.h>
27#include <linux/usb_usual.h>
28
29
30/*
31 * The table of devices
32 */
33#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
34 vendorName, productName, useProtocol, useTransport, \
35 initFunction, flags) \
36{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
37 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
38
39#define COMPLIANT_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
40 vendorName, productName, useProtocol, useTransport, \
41 initFunction, flags) \
42{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
43 .driver_info = (flags) }
44
45#define USUAL_DEV(useProto, useTrans, useType) \
46{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \
47 .driver_info = ((useType)<<24) }
48
49struct usb_device_id usb_storage_usb_ids[] = {
50# include "unusual_devs.h"
51 { } /* Terminating entry */
52};
53EXPORT_SYMBOL_GPL(usb_storage_usb_ids);
54
55MODULE_DEVICE_TABLE(usb, usb_storage_usb_ids);
56
57#undef UNUSUAL_DEV
58#undef COMPLIANT_DEV
59#undef USUAL_DEV
60
61
62/*
63 * The table of devices to ignore
64 */
65struct ignore_entry {
66 u16 vid, pid, bcdmin, bcdmax;
67};
68
69#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
70 vendorName, productName, useProtocol, useTransport, \
71 initFunction, flags) \
72{ \
73 .vid = id_vendor, \
74 .pid = id_product, \
75 .bcdmin = bcdDeviceMin, \
76 .bcdmax = bcdDeviceMax, \
77}
78
79static struct ignore_entry ignore_ids[] = {
80# include "unusual_alauda.h"
81# include "unusual_cypress.h"
82# include "unusual_datafab.h"
83# include "unusual_ene_ub6250.h"
84# include "unusual_freecom.h"
85# include "unusual_isd200.h"
86# include "unusual_jumpshot.h"
87# include "unusual_karma.h"
88# include "unusual_onetouch.h"
89# include "unusual_realtek.h"
90# include "unusual_sddr09.h"
91# include "unusual_sddr55.h"
92# include "unusual_usbat.h"
93 { } /* Terminating entry */
94};
95
96#undef UNUSUAL_DEV
97
98
99/* Return an error if a device is in the ignore_ids list */
100int usb_usual_ignore_device(struct usb_interface *intf)
101{
102 struct usb_device *udev;
103 unsigned vid, pid, bcd;
104 struct ignore_entry *p;
105
106 udev = interface_to_usbdev(intf);
107 vid = le16_to_cpu(udev->descriptor.idVendor);
108 pid = le16_to_cpu(udev->descriptor.idProduct);
109 bcd = le16_to_cpu(udev->descriptor.bcdDevice);
110
111 for (p = ignore_ids; p->vid; ++p) {
112 if (p->vid == vid && p->pid == pid &&
113 p->bcdmin <= bcd && p->bcdmax >= bcd)
114 return -ENXIO;
115 }
116 return 0;
117}
118EXPORT_SYMBOL_GPL(usb_usual_ignore_device);