2017-11-03 18:28:30 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2016-04-18 18:09:11 +08:00
|
|
|
/*
|
|
|
|
* Driver for USB Mass Storage devices
|
usb-storage: prepare for subdriver separation
This patch (as1206) is the first step in converting usb-storage's
subdrivers into separate modules. It makes the following large-scale
changes:
Remove a bunch of unnecessary #ifdef's from usb_usual.h.
Not truly necessary, but it does clean things up.
Move the USB device-ID table (which is duplicated between
libusual and usb-storage) into its own source file,
usual-tables.c, and arrange for this to be linked with
either libusual or usb-storage according to whether
USB_LIBUSUAL is configured.
Add to usual-tables.c a new usb_usual_ignore_device()
function to detect whether a particular device needs to be
managed by a subdriver and not by the standard handlers
in usb-storage.
Export a whole bunch of functions in usb-storage, renaming
some of them because their names don't already begin with
"usb_stor_". These functions will be needed by the new
subdriver modules.
Split usb-storage's probe routine into two functions.
The subdrivers will call the probe1 routine, then fill in
their transport and protocol settings, and then call the
probe2 routine.
Take the default cases and error checking out of
get_transport() and get_protocol(), which run during
probe1, and instead put a check for invalid transport
or protocol values into the probe2 function.
Add a new probe routine to be used for standard devices,
i.e., those that don't need a subdriver. This new routine
checks whether the device should be ignored (because it
should be handled by ub or by a subdriver), and if not,
calls the probe1 and probe2 functions.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-02-13 03:47:44 +08:00
|
|
|
* Usual Tables File for usb-storage and libusual
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Alan Stern (stern@rowland.harvard.edu)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/usb.h>
|
|
|
|
#include <linux/usb_usual.h>
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* The table of devices
|
|
|
|
*/
|
|
|
|
#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
|
|
|
|
vendorName, productName, useProtocol, useTransport, \
|
|
|
|
initFunction, flags) \
|
|
|
|
{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax), \
|
|
|
|
.driver_info = (flags) }
|
|
|
|
|
2012-08-29 04:37:13 +08:00
|
|
|
#define COMPLIANT_DEV UNUSUAL_DEV
|
|
|
|
|
|
|
|
#define USUAL_DEV(useProto, useTrans) \
|
|
|
|
{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans) }
|
usb-storage: prepare for subdriver separation
This patch (as1206) is the first step in converting usb-storage's
subdrivers into separate modules. It makes the following large-scale
changes:
Remove a bunch of unnecessary #ifdef's from usb_usual.h.
Not truly necessary, but it does clean things up.
Move the USB device-ID table (which is duplicated between
libusual and usb-storage) into its own source file,
usual-tables.c, and arrange for this to be linked with
either libusual or usb-storage according to whether
USB_LIBUSUAL is configured.
Add to usual-tables.c a new usb_usual_ignore_device()
function to detect whether a particular device needs to be
managed by a subdriver and not by the standard handlers
in usb-storage.
Export a whole bunch of functions in usb-storage, renaming
some of them because their names don't already begin with
"usb_stor_". These functions will be needed by the new
subdriver modules.
Split usb-storage's probe routine into two functions.
The subdrivers will call the probe1 routine, then fill in
their transport and protocol settings, and then call the
probe2 routine.
Take the default cases and error checking out of
get_transport() and get_protocol(), which run during
probe1, and instead put a check for invalid transport
or protocol values into the probe2 function.
Add a new probe routine to be used for standard devices,
i.e., those that don't need a subdriver. This new routine
checks whether the device should be ignored (because it
should be handled by ub or by a subdriver), and if not,
calls the probe1 and probe2 functions.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-02-13 03:47:44 +08:00
|
|
|
|
2013-02-04 15:14:46 +08:00
|
|
|
/* Define the device is matched with Vendor ID and interface descriptors */
|
|
|
|
#define UNUSUAL_VENDOR_INTF(id_vendor, cl, sc, pr, \
|
|
|
|
vendorName, productName, useProtocol, useTransport, \
|
|
|
|
initFunction, flags) \
|
|
|
|
{ \
|
|
|
|
.match_flags = USB_DEVICE_ID_MATCH_INT_INFO \
|
|
|
|
| USB_DEVICE_ID_MATCH_VENDOR, \
|
|
|
|
.idVendor = (id_vendor), \
|
|
|
|
.bInterfaceClass = (cl), \
|
|
|
|
.bInterfaceSubClass = (sc), \
|
|
|
|
.bInterfaceProtocol = (pr), \
|
|
|
|
.driver_info = (flags) \
|
|
|
|
}
|
|
|
|
|
2020-02-18 08:59:54 +08:00
|
|
|
const struct usb_device_id usb_storage_usb_ids[] = {
|
usb-storage: prepare for subdriver separation
This patch (as1206) is the first step in converting usb-storage's
subdrivers into separate modules. It makes the following large-scale
changes:
Remove a bunch of unnecessary #ifdef's from usb_usual.h.
Not truly necessary, but it does clean things up.
Move the USB device-ID table (which is duplicated between
libusual and usb-storage) into its own source file,
usual-tables.c, and arrange for this to be linked with
either libusual or usb-storage according to whether
USB_LIBUSUAL is configured.
Add to usual-tables.c a new usb_usual_ignore_device()
function to detect whether a particular device needs to be
managed by a subdriver and not by the standard handlers
in usb-storage.
Export a whole bunch of functions in usb-storage, renaming
some of them because their names don't already begin with
"usb_stor_". These functions will be needed by the new
subdriver modules.
Split usb-storage's probe routine into two functions.
The subdrivers will call the probe1 routine, then fill in
their transport and protocol settings, and then call the
probe2 routine.
Take the default cases and error checking out of
get_transport() and get_protocol(), which run during
probe1, and instead put a check for invalid transport
or protocol values into the probe2 function.
Add a new probe routine to be used for standard devices,
i.e., those that don't need a subdriver. This new routine
checks whether the device should be ignored (because it
should be handled by ub or by a subdriver), and if not,
calls the probe1 and probe2 functions.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-02-13 03:47:44 +08:00
|
|
|
# include "unusual_devs.h"
|
|
|
|
{ } /* Terminating entry */
|
|
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(usb, usb_storage_usb_ids);
|
|
|
|
|
|
|
|
#undef UNUSUAL_DEV
|
|
|
|
#undef COMPLIANT_DEV
|
|
|
|
#undef USUAL_DEV
|
2013-02-04 15:14:46 +08:00
|
|
|
#undef UNUSUAL_VENDOR_INTF
|
usb-storage: prepare for subdriver separation
This patch (as1206) is the first step in converting usb-storage's
subdrivers into separate modules. It makes the following large-scale
changes:
Remove a bunch of unnecessary #ifdef's from usb_usual.h.
Not truly necessary, but it does clean things up.
Move the USB device-ID table (which is duplicated between
libusual and usb-storage) into its own source file,
usual-tables.c, and arrange for this to be linked with
either libusual or usb-storage according to whether
USB_LIBUSUAL is configured.
Add to usual-tables.c a new usb_usual_ignore_device()
function to detect whether a particular device needs to be
managed by a subdriver and not by the standard handlers
in usb-storage.
Export a whole bunch of functions in usb-storage, renaming
some of them because their names don't already begin with
"usb_stor_". These functions will be needed by the new
subdriver modules.
Split usb-storage's probe routine into two functions.
The subdrivers will call the probe1 routine, then fill in
their transport and protocol settings, and then call the
probe2 routine.
Take the default cases and error checking out of
get_transport() and get_protocol(), which run during
probe1, and instead put a check for invalid transport
or protocol values into the probe2 function.
Add a new probe routine to be used for standard devices,
i.e., those that don't need a subdriver. This new routine
checks whether the device should be ignored (because it
should be handled by ub or by a subdriver), and if not,
calls the probe1 and probe2 functions.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-02-13 03:47:44 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* The table of devices to ignore
|
|
|
|
*/
|
|
|
|
struct ignore_entry {
|
|
|
|
u16 vid, pid, bcdmin, bcdmax;
|
|
|
|
};
|
|
|
|
|
|
|
|
#define UNUSUAL_DEV(id_vendor, id_product, bcdDeviceMin, bcdDeviceMax, \
|
|
|
|
vendorName, productName, useProtocol, useTransport, \
|
|
|
|
initFunction, flags) \
|
|
|
|
{ \
|
|
|
|
.vid = id_vendor, \
|
|
|
|
.pid = id_product, \
|
|
|
|
.bcdmin = bcdDeviceMin, \
|
|
|
|
.bcdmax = bcdDeviceMax, \
|
|
|
|
}
|
|
|
|
|
2020-02-18 08:59:54 +08:00
|
|
|
static const struct ignore_entry ignore_ids[] = {
|
2009-02-13 03:48:22 +08:00
|
|
|
# include "unusual_alauda.h"
|
2009-02-13 03:48:04 +08:00
|
|
|
# include "unusual_cypress.h"
|
2009-02-13 03:48:15 +08:00
|
|
|
# include "unusual_datafab.h"
|
2011-03-04 10:56:18 +08:00
|
|
|
# include "unusual_ene_ub6250.h"
|
2009-02-13 03:48:11 +08:00
|
|
|
# include "unusual_freecom.h"
|
2009-02-13 03:47:54 +08:00
|
|
|
# include "unusual_isd200.h"
|
2009-02-13 03:48:19 +08:00
|
|
|
# include "unusual_jumpshot.h"
|
2009-02-13 03:48:26 +08:00
|
|
|
# include "unusual_karma.h"
|
2009-02-13 03:48:33 +08:00
|
|
|
# include "unusual_onetouch.h"
|
2011-01-14 16:53:34 +08:00
|
|
|
# include "unusual_realtek.h"
|
2009-02-13 03:47:49 +08:00
|
|
|
# include "unusual_sddr09.h"
|
2009-02-13 03:47:59 +08:00
|
|
|
# include "unusual_sddr55.h"
|
2009-02-13 03:48:08 +08:00
|
|
|
# include "unusual_usbat.h"
|
usb-storage: prepare for subdriver separation
This patch (as1206) is the first step in converting usb-storage's
subdrivers into separate modules. It makes the following large-scale
changes:
Remove a bunch of unnecessary #ifdef's from usb_usual.h.
Not truly necessary, but it does clean things up.
Move the USB device-ID table (which is duplicated between
libusual and usb-storage) into its own source file,
usual-tables.c, and arrange for this to be linked with
either libusual or usb-storage according to whether
USB_LIBUSUAL is configured.
Add to usual-tables.c a new usb_usual_ignore_device()
function to detect whether a particular device needs to be
managed by a subdriver and not by the standard handlers
in usb-storage.
Export a whole bunch of functions in usb-storage, renaming
some of them because their names don't already begin with
"usb_stor_". These functions will be needed by the new
subdriver modules.
Split usb-storage's probe routine into two functions.
The subdrivers will call the probe1 routine, then fill in
their transport and protocol settings, and then call the
probe2 routine.
Take the default cases and error checking out of
get_transport() and get_protocol(), which run during
probe1, and instead put a check for invalid transport
or protocol values into the probe2 function.
Add a new probe routine to be used for standard devices,
i.e., those that don't need a subdriver. This new routine
checks whether the device should be ignored (because it
should be handled by ub or by a subdriver), and if not,
calls the probe1 and probe2 functions.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-02-13 03:47:44 +08:00
|
|
|
{ } /* Terminating entry */
|
|
|
|
};
|
|
|
|
|
|
|
|
#undef UNUSUAL_DEV
|
|
|
|
|
|
|
|
/* Return an error if a device is in the ignore_ids list */
|
|
|
|
int usb_usual_ignore_device(struct usb_interface *intf)
|
|
|
|
{
|
|
|
|
struct usb_device *udev;
|
|
|
|
unsigned vid, pid, bcd;
|
2020-02-18 08:59:54 +08:00
|
|
|
const struct ignore_entry *p;
|
usb-storage: prepare for subdriver separation
This patch (as1206) is the first step in converting usb-storage's
subdrivers into separate modules. It makes the following large-scale
changes:
Remove a bunch of unnecessary #ifdef's from usb_usual.h.
Not truly necessary, but it does clean things up.
Move the USB device-ID table (which is duplicated between
libusual and usb-storage) into its own source file,
usual-tables.c, and arrange for this to be linked with
either libusual or usb-storage according to whether
USB_LIBUSUAL is configured.
Add to usual-tables.c a new usb_usual_ignore_device()
function to detect whether a particular device needs to be
managed by a subdriver and not by the standard handlers
in usb-storage.
Export a whole bunch of functions in usb-storage, renaming
some of them because their names don't already begin with
"usb_stor_". These functions will be needed by the new
subdriver modules.
Split usb-storage's probe routine into two functions.
The subdrivers will call the probe1 routine, then fill in
their transport and protocol settings, and then call the
probe2 routine.
Take the default cases and error checking out of
get_transport() and get_protocol(), which run during
probe1, and instead put a check for invalid transport
or protocol values into the probe2 function.
Add a new probe routine to be used for standard devices,
i.e., those that don't need a subdriver. This new routine
checks whether the device should be ignored (because it
should be handled by ub or by a subdriver), and if not,
calls the probe1 and probe2 functions.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2009-02-13 03:47:44 +08:00
|
|
|
|
|
|
|
udev = interface_to_usbdev(intf);
|
|
|
|
vid = le16_to_cpu(udev->descriptor.idVendor);
|
|
|
|
pid = le16_to_cpu(udev->descriptor.idProduct);
|
|
|
|
bcd = le16_to_cpu(udev->descriptor.bcdDevice);
|
|
|
|
|
|
|
|
for (p = ignore_ids; p->vid; ++p) {
|
|
|
|
if (p->vid == vid && p->pid == pid &&
|
|
|
|
p->bcdmin <= bcd && p->bcdmax >= bcd)
|
|
|
|
return -ENXIO;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|