2017-11-03 10:28:30 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0+
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
|
|
|
* Driver for USB Mass Storage compliant devices
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Current development and maintenance by:
|
|
|
|
* (c) 1999-2003 Matthew Dharm (mdharm-usb@one-eyed-alien.net)
|
|
|
|
*
|
|
|
|
* Developed with the assistance of:
|
|
|
|
* (c) 2000 David L. Brown, Jr. (usb-storage@davidb.org)
|
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-12 19:47:44 +00:00
|
|
|
* (c) 2003-2009 Alan Stern (stern@rowland.harvard.edu)
|
2005-04-16 22:20:36 +00:00
|
|
|
*
|
|
|
|
* Initial work by:
|
|
|
|
* (c) 1999 Michael Gee (michael@linuxspecific.com)
|
|
|
|
*
|
|
|
|
* usb_device_id support by Adam J. Richter (adam@yggdrasil.com):
|
|
|
|
* (c) 2000 Yggdrasil Computing, Inc.
|
|
|
|
*
|
|
|
|
* This driver is based on the 'USB Mass Storage Class' document. This
|
|
|
|
* describes in detail the protocol used to communicate with such
|
|
|
|
* devices. Clearly, the designers had SCSI and ATAPI commands in
|
|
|
|
* mind when they created this document. The commands are all very
|
|
|
|
* similar to commands in the SCSI-II and ATAPI specifications.
|
|
|
|
*
|
|
|
|
* It is important to note that in a number of cases this class
|
|
|
|
* exhibits class-specific exemptions from the USB specification.
|
|
|
|
* Notably the usage of NAK, STALL and ACK differs from the norm, in
|
|
|
|
* that they are used to communicate wait, failed and OK on commands.
|
|
|
|
*
|
|
|
|
* Also, for certain devices, the interrupt endpoint is used to convey
|
|
|
|
* status of a command.
|
|
|
|
*/
|
|
|
|
|
2009-09-24 22:19:49 +00:00
|
|
|
#ifdef CONFIG_USB_STORAGE_DEBUG
|
|
|
|
#define DEBUG
|
|
|
|
#endif
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <linux/sched.h>
|
|
|
|
#include <linux/errno.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/slab.h>
|
2005-10-24 02:43:36 +00:00
|
|
|
#include <linux/kthread.h>
|
2006-01-11 14:55:29 +00:00
|
|
|
#include <linux/mutex.h>
|
2007-03-05 08:30:55 +00:00
|
|
|
#include <linux/utsname.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#include <scsi/scsi.h>
|
|
|
|
#include <scsi/scsi_cmnd.h>
|
|
|
|
#include <scsi/scsi_device.h>
|
|
|
|
|
|
|
|
#include "usb.h"
|
|
|
|
#include "scsiglue.h"
|
|
|
|
#include "transport.h"
|
|
|
|
#include "protocol.h"
|
|
|
|
#include "debug.h"
|
|
|
|
#include "initializers.h"
|
|
|
|
|
2008-07-10 21:14:57 +00:00
|
|
|
#include "sierra_ms.h"
|
2008-12-14 17:39:22 +00:00
|
|
|
#include "option_ms.h"
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2013-10-21 08:40:48 +00:00
|
|
|
#if IS_ENABLED(CONFIG_USB_UAS)
|
|
|
|
#include "uas-detect.h"
|
|
|
|
#endif
|
|
|
|
|
2015-05-06 09:24:21 +00:00
|
|
|
#define DRV_NAME "usb-storage"
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Some informational data */
|
|
|
|
MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>");
|
|
|
|
MODULE_DESCRIPTION("USB Mass Storage driver for Linux");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
2010-02-26 18:03:22 +00:00
|
|
|
static unsigned int delay_use = 1;
|
2005-04-16 22:20:36 +00:00
|
|
|
module_param(delay_use, uint, S_IRUGO | S_IWUSR);
|
|
|
|
MODULE_PARM_DESC(delay_use, "seconds to delay before using a new device");
|
|
|
|
|
2008-12-15 15:40:06 +00:00
|
|
|
static char quirks[128];
|
|
|
|
module_param_string(quirks, quirks, sizeof(quirks), S_IRUGO | S_IWUSR);
|
2008-11-10 19:07:45 +00:00
|
|
|
MODULE_PARM_DESC(quirks, "supplemental list of device IDs and their quirks");
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-10-23 03:15:09 +00:00
|
|
|
/*
|
|
|
|
* The entries in this table correspond, line for line,
|
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-12 19:47:44 +00:00
|
|
|
* with the entries in usb_storage_usb_ids[], defined in usual-tables.c.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
|
|
|
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
|
|
|
*The vendor name should be kept at eight characters or less, and
|
2005-04-16 22:20:36 +00:00
|
|
|
* the product name should be kept at 16 characters or less. If a device
|
|
|
|
* has the US_FL_FIX_INQUIRY flag, then the vendor and product names
|
2014-09-18 09:25:04 +00:00
|
|
|
* normally generated by a device through the INQUIRY response will be
|
2005-04-16 22:20:36 +00:00
|
|
|
* taken from this list, and this is the reason for the above size
|
|
|
|
* restriction. However, if the flag is not present, then you
|
|
|
|
* are free to use as many characters as you like.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define UNUSUAL_DEV(idVendor, idProduct, bcdDeviceMin, bcdDeviceMax, \
|
|
|
|
vendor_name, product_name, use_protocol, use_transport, \
|
|
|
|
init_function, Flags) \
|
|
|
|
{ \
|
|
|
|
.vendorName = vendor_name, \
|
|
|
|
.productName = product_name, \
|
|
|
|
.useProtocol = use_protocol, \
|
|
|
|
.useTransport = use_transport, \
|
|
|
|
.initFunction = init_function, \
|
2005-10-23 03:15:09 +00:00
|
|
|
}
|
|
|
|
|
USB: storage: add last-sector hacks
This patch (as1189b) adds some hacks to usb-storage for dealing with
the growing problems involving bad capacity values and last-sector
accesses:
A new flag, US_FL_CAPACITY_OK, is created to indicate that
the device is known to report its capacity correctly. An
unusual_devs entry for Linux's own File-backed Storage Gadget
is added with this flag set, since g_file_storage always
reports the correct capacity and since the capacity need
not be even (it is determined by the size of the backing
file).
An entry in unusual_devs.h which has only the CAPACITY_OK
flag set shouldn't prejudice libusual, since the device will
work perfectly well with either usb-storage or ub. So a
new macro, COMPLIANT_DEV, is added to let libusual know
about these entries.
When a last-sector access succeeds and the total number of
sectors is odd (the unexpected case, in which guessing that
the number is even might cause trouble), a WARN is triggered.
The kerneloops.org project will collect these warnings,
allowing us to add CAPACITY_OK flags for the devices in
question before implementing the default-to-even heuristic.
If users want to prevent the stack dump produced by the WARN,
they can disable the hack by adding an unusual_devs entry
for their device with the CAPACITY_OK flag.
When a last-sector access fails three times in a row and
neither the FIX_CAPACITY nor the CAPACITY_OK flag is set,
we assume the last-sector bug is present. We replace the
existing status and sense data with values that will cause
the SCSI core to fail the access immediately rather than
retry indefinitely. This should fix the difficulties
people have been having with Nokia phones.
Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Cc: stable <stable@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2008-12-15 17:43:41 +00:00
|
|
|
#define COMPLIANT_DEV UNUSUAL_DEV
|
|
|
|
|
2012-08-28 20:37:13 +00:00
|
|
|
#define USUAL_DEV(use_protocol, use_transport) \
|
2005-10-23 03:15:09 +00:00
|
|
|
{ \
|
|
|
|
.useProtocol = use_protocol, \
|
|
|
|
.useTransport = use_transport, \
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2020-02-18 00:59:54 +00:00
|
|
|
static const struct us_unusual_dev us_unusual_dev_list[] = {
|
2012-05-16 19:03:36 +00:00
|
|
|
# include "unusual_devs.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-12 19:47:44 +00:00
|
|
|
{ } /* Terminating entry */
|
2005-04-16 22:20:36 +00:00
|
|
|
};
|
|
|
|
|
2020-02-18 00:59:54 +00:00
|
|
|
static const struct us_unusual_dev for_dynamic_ids =
|
2012-08-28 20:37:13 +00:00
|
|
|
USUAL_DEV(USB_SC_SCSI, USB_PR_BULK);
|
2012-01-14 02:16:40 +00:00
|
|
|
|
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-12 19:47:44 +00:00
|
|
|
#undef UNUSUAL_DEV
|
|
|
|
#undef COMPLIANT_DEV
|
|
|
|
#undef USUAL_DEV
|
|
|
|
|
2012-03-19 07:20:57 +00:00
|
|
|
#ifdef CONFIG_LOCKDEP
|
|
|
|
|
|
|
|
static struct lock_class_key us_interface_key[USB_MAXINTERFACES];
|
|
|
|
|
|
|
|
static void us_set_lock_class(struct mutex *mutex,
|
|
|
|
struct usb_interface *intf)
|
|
|
|
{
|
|
|
|
struct usb_device *udev = interface_to_usbdev(intf);
|
|
|
|
struct usb_host_config *config = udev->actconfig;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0; i < config->desc.bNumInterfaces; i++) {
|
|
|
|
if (config->interface[i] == intf)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
BUG_ON(i == config->desc.bNumInterfaces);
|
|
|
|
|
|
|
|
lockdep_set_class(mutex, &us_interface_key[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
static void us_set_lock_class(struct mutex *mutex,
|
|
|
|
struct usb_interface *intf)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
2005-10-24 02:41:39 +00:00
|
|
|
|
|
|
|
#ifdef CONFIG_PM /* Minimal support for suspend and resume */
|
|
|
|
|
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-12 19:47:44 +00:00
|
|
|
int usb_stor_suspend(struct usb_interface *iface, pm_message_t message)
|
2005-10-24 02:41:39 +00:00
|
|
|
{
|
|
|
|
struct us_data *us = usb_get_intfdata(iface);
|
|
|
|
|
|
|
|
/* Wait until no command is running */
|
2006-01-11 14:55:29 +00:00
|
|
|
mutex_lock(&us->dev_mutex);
|
2005-10-24 02:41:39 +00:00
|
|
|
|
2005-12-05 05:56:51 +00:00
|
|
|
if (us->suspend_resume_hook)
|
|
|
|
(us->suspend_resume_hook)(us, US_SUSPEND);
|
2005-10-24 02:41:39 +00:00
|
|
|
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
|
|
|
* When runtime PM is working, we'll set a flag to indicate
|
|
|
|
* whether we should autoresume when a SCSI request arrives.
|
|
|
|
*/
|
2007-09-13 13:01:24 +00:00
|
|
|
|
2006-01-11 14:55:29 +00:00
|
|
|
mutex_unlock(&us->dev_mutex);
|
2005-10-24 02:41:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
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-12 19:47:44 +00:00
|
|
|
EXPORT_SYMBOL_GPL(usb_stor_suspend);
|
2005-10-24 02:41:39 +00:00
|
|
|
|
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-12 19:47:44 +00:00
|
|
|
int usb_stor_resume(struct usb_interface *iface)
|
2005-10-24 02:41:39 +00:00
|
|
|
{
|
|
|
|
struct us_data *us = usb_get_intfdata(iface);
|
|
|
|
|
2007-09-13 13:01:24 +00:00
|
|
|
mutex_lock(&us->dev_mutex);
|
2007-07-06 18:24:27 +00:00
|
|
|
|
2005-12-05 05:56:51 +00:00
|
|
|
if (us->suspend_resume_hook)
|
|
|
|
(us->suspend_resume_hook)(us, US_RESUME);
|
2005-10-24 02:41:39 +00:00
|
|
|
|
2007-09-13 13:01:24 +00:00
|
|
|
mutex_unlock(&us->dev_mutex);
|
2005-10-24 02:41:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
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-12 19:47:44 +00:00
|
|
|
EXPORT_SYMBOL_GPL(usb_stor_resume);
|
2005-10-24 02:41:39 +00:00
|
|
|
|
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-12 19:47:44 +00:00
|
|
|
int usb_stor_reset_resume(struct usb_interface *iface)
|
2007-05-30 19:38:16 +00:00
|
|
|
{
|
|
|
|
struct us_data *us = usb_get_intfdata(iface);
|
|
|
|
|
|
|
|
/* Report the reset to the SCSI core */
|
|
|
|
usb_stor_report_bus_reset(us);
|
|
|
|
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
2017-11-30 08:54:07 +00:00
|
|
|
* If any of the subdrivers implemented a reinitialization scheme,
|
|
|
|
* this is where the callback would be invoked.
|
2016-04-18 10:09:11 +00:00
|
|
|
*/
|
2007-05-30 19:38:16 +00:00
|
|
|
return 0;
|
|
|
|
}
|
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-12 19:47:44 +00:00
|
|
|
EXPORT_SYMBOL_GPL(usb_stor_reset_resume);
|
2007-05-30 19:38:16 +00:00
|
|
|
|
2005-10-24 02:41:39 +00:00
|
|
|
#endif /* CONFIG_PM */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-06-01 17:52:56 +00:00
|
|
|
/*
|
|
|
|
* The next two routines get called just before and just after
|
|
|
|
* a USB port reset, whether from this driver or a different one.
|
|
|
|
*/
|
|
|
|
|
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-12 19:47:44 +00:00
|
|
|
int usb_stor_pre_reset(struct usb_interface *iface)
|
2006-06-01 17:52:56 +00:00
|
|
|
{
|
|
|
|
struct us_data *us = usb_get_intfdata(iface);
|
|
|
|
|
|
|
|
/* Make sure no command runs during the reset */
|
|
|
|
mutex_lock(&us->dev_mutex);
|
2007-05-30 19:38:16 +00:00
|
|
|
return 0;
|
2006-06-01 17:52:56 +00:00
|
|
|
}
|
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-12 19:47:44 +00:00
|
|
|
EXPORT_SYMBOL_GPL(usb_stor_pre_reset);
|
2006-06-01 17:52:56 +00:00
|
|
|
|
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-12 19:47:44 +00:00
|
|
|
int usb_stor_post_reset(struct usb_interface *iface)
|
2006-06-01 17:52:56 +00:00
|
|
|
{
|
|
|
|
struct us_data *us = usb_get_intfdata(iface);
|
|
|
|
|
|
|
|
/* Report the reset to the SCSI core */
|
|
|
|
usb_stor_report_bus_reset(us);
|
|
|
|
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
2017-11-30 08:54:07 +00:00
|
|
|
* If any of the subdrivers implemented a reinitialization scheme,
|
|
|
|
* this is where the callback would be invoked.
|
2016-04-18 10:09:11 +00:00
|
|
|
*/
|
2007-05-04 15:52:20 +00:00
|
|
|
|
2007-05-30 19:38:16 +00:00
|
|
|
mutex_unlock(&us->dev_mutex);
|
|
|
|
return 0;
|
2006-06-01 17:52:56 +00:00
|
|
|
}
|
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-12 19:47:44 +00:00
|
|
|
EXPORT_SYMBOL_GPL(usb_stor_post_reset);
|
2006-06-01 17:52:56 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* fill_inquiry_response takes an unsigned char array (which must
|
|
|
|
* be at least 36 characters) and populates the vendor name,
|
|
|
|
* product name, and revision fields. Then the array is copied
|
|
|
|
* into the SCSI command's response buffer (oddly enough
|
|
|
|
* called request_buffer). data_len contains the length of the
|
|
|
|
* data array, which again must be at least 36.
|
|
|
|
*/
|
|
|
|
|
|
|
|
void fill_inquiry_response(struct us_data *us, unsigned char *data,
|
|
|
|
unsigned int data_len)
|
|
|
|
{
|
2012-05-16 19:03:36 +00:00
|
|
|
if (data_len < 36) /* You lose. */
|
2005-04-16 22:20:36 +00:00
|
|
|
return;
|
|
|
|
|
2009-12-07 21:47:43 +00:00
|
|
|
memset(data+8, ' ', 28);
|
2016-04-18 10:09:11 +00:00
|
|
|
if (data[0]&0x20) { /*
|
|
|
|
* USB device currently not connected. Return
|
|
|
|
* peripheral qualifier 001b ("...however, the
|
|
|
|
* physical device is not currently connected
|
|
|
|
* to this logical unit") and leave vendor and
|
|
|
|
* product identification empty. ("If the target
|
|
|
|
* does store some of the INQUIRY data on the
|
|
|
|
* device, it may return zeros or ASCII spaces
|
|
|
|
* (20h) in those fields until the data is
|
|
|
|
* available from the device.").
|
|
|
|
*/
|
2005-04-16 22:20:36 +00:00
|
|
|
} else {
|
|
|
|
u16 bcdDevice = le16_to_cpu(us->pusb_dev->descriptor.bcdDevice);
|
2009-12-07 21:47:43 +00:00
|
|
|
int n;
|
|
|
|
|
|
|
|
n = strlen(us->unusual_dev->vendorName);
|
|
|
|
memcpy(data+8, us->unusual_dev->vendorName, min(8, n));
|
|
|
|
n = strlen(us->unusual_dev->productName);
|
|
|
|
memcpy(data+16, us->unusual_dev->productName, min(16, n));
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
data[32] = 0x30 + ((bcdDevice>>12) & 0x0F);
|
|
|
|
data[33] = 0x30 + ((bcdDevice>>8) & 0x0F);
|
|
|
|
data[34] = 0x30 + ((bcdDevice>>4) & 0x0F);
|
|
|
|
data[35] = 0x30 + ((bcdDevice) & 0x0F);
|
|
|
|
}
|
|
|
|
|
|
|
|
usb_stor_set_xfer_buf(data, data_len, us->srb);
|
|
|
|
}
|
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-12 19:47:44 +00:00
|
|
|
EXPORT_SYMBOL_GPL(fill_inquiry_response);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
static int usb_stor_control_thread(void * __us)
|
|
|
|
{
|
|
|
|
struct us_data *us = (struct us_data *)__us;
|
|
|
|
struct Scsi_Host *host = us_to_host(us);
|
2017-07-26 15:49:19 +00:00
|
|
|
struct scsi_cmnd *srb;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-05-16 19:04:28 +00:00
|
|
|
for (;;) {
|
2013-04-19 18:44:00 +00:00
|
|
|
usb_stor_dbg(us, "*** thread sleeping\n");
|
2008-05-01 19:36:13 +00:00
|
|
|
if (wait_for_completion_interruptible(&us->cmnd_ready))
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
2008-05-01 19:36:13 +00:00
|
|
|
|
2013-04-19 18:44:00 +00:00
|
|
|
usb_stor_dbg(us, "*** thread awakened\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* lock the device pointers */
|
2006-01-11 14:55:29 +00:00
|
|
|
mutex_lock(&(us->dev_mutex));
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-05-08 15:55:59 +00:00
|
|
|
/* lock access to the state */
|
|
|
|
scsi_lock(host);
|
|
|
|
|
|
|
|
/* When we are called with no command pending, we're done */
|
2017-07-26 15:49:19 +00:00
|
|
|
srb = us->srb;
|
2017-10-25 14:40:05 +00:00
|
|
|
if (srb == NULL) {
|
2008-05-08 15:55:59 +00:00
|
|
|
scsi_unlock(host);
|
2006-01-11 14:55:29 +00:00
|
|
|
mutex_unlock(&us->dev_mutex);
|
2013-04-19 18:44:00 +00:00
|
|
|
usb_stor_dbg(us, "-- exiting\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* has the command timed out *already* ? */
|
2008-05-01 19:35:18 +00:00
|
|
|
if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
|
2017-10-25 14:40:05 +00:00
|
|
|
srb->result = DID_ABORT << 16;
|
2005-04-16 22:20:36 +00:00
|
|
|
goto SkipForAbort;
|
|
|
|
}
|
|
|
|
|
|
|
|
scsi_unlock(host);
|
|
|
|
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
|
|
|
* reject the command if the direction indicator
|
2005-04-16 22:20:36 +00:00
|
|
|
* is UNKNOWN
|
|
|
|
*/
|
2017-10-25 14:40:05 +00:00
|
|
|
if (srb->sc_data_direction == DMA_BIDIRECTIONAL) {
|
2013-04-19 18:44:00 +00:00
|
|
|
usb_stor_dbg(us, "UNKNOWN data direction\n");
|
2017-10-25 14:40:05 +00:00
|
|
|
srb->result = DID_ERROR << 16;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
|
|
|
* reject if target != 0 or if LUN is higher than
|
2005-04-16 22:20:36 +00:00
|
|
|
* the maximum known LUN
|
|
|
|
*/
|
2017-10-25 14:40:05 +00:00
|
|
|
else if (srb->device->id &&
|
2008-05-01 19:35:18 +00:00
|
|
|
!(us->fflags & US_FL_SCM_MULT_TARG)) {
|
2014-06-25 13:27:36 +00:00
|
|
|
usb_stor_dbg(us, "Bad target number (%d:%llu)\n",
|
2017-10-25 14:40:05 +00:00
|
|
|
srb->device->id,
|
|
|
|
srb->device->lun);
|
|
|
|
srb->result = DID_BAD_TARGET << 16;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2017-10-25 14:40:05 +00:00
|
|
|
else if (srb->device->lun > us->max_lun) {
|
2014-06-25 13:27:36 +00:00
|
|
|
usb_stor_dbg(us, "Bad LUN (%d:%llu)\n",
|
2017-10-25 14:40:05 +00:00
|
|
|
srb->device->id,
|
|
|
|
srb->device->lun);
|
|
|
|
srb->result = DID_BAD_TARGET << 16;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
|
|
|
* Handle those devices which need us to fake
|
|
|
|
* their inquiry data
|
|
|
|
*/
|
2017-10-25 14:40:05 +00:00
|
|
|
else if ((srb->cmnd[0] == INQUIRY) &&
|
2008-05-01 19:35:18 +00:00
|
|
|
(us->fflags & US_FL_FIX_INQUIRY)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
unsigned char data_ptr[36] = {
|
|
|
|
0x00, 0x80, 0x02, 0x02,
|
|
|
|
0x1F, 0x00, 0x00, 0x00};
|
|
|
|
|
2013-04-19 18:44:00 +00:00
|
|
|
usb_stor_dbg(us, "Faking INQUIRY command\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
fill_inquiry_response(us, data_ptr, 36);
|
2017-10-25 14:40:05 +00:00
|
|
|
srb->result = SAM_STAT_GOOD;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* we've got a command, let's do it! */
|
|
|
|
else {
|
2017-10-25 14:40:05 +00:00
|
|
|
US_DEBUG(usb_stor_show_command(us, srb));
|
|
|
|
us->proto_handler(srb, us);
|
2010-07-28 21:12:39 +00:00
|
|
|
usb_mark_last_busy(us->pusb_dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* lock access to the state */
|
|
|
|
scsi_lock(host);
|
|
|
|
|
2017-07-26 15:49:19 +00:00
|
|
|
/* was the command aborted? */
|
2017-10-25 14:40:05 +00:00
|
|
|
if (srb->result == DID_ABORT << 16) {
|
2005-04-16 22:20:36 +00:00
|
|
|
SkipForAbort:
|
2013-04-19 18:44:00 +00:00
|
|
|
usb_stor_dbg(us, "scsi command aborted\n");
|
2021-10-07 20:46:10 +00:00
|
|
|
srb = NULL; /* Don't call scsi_done() */
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
|
|
|
* If an abort request was received we need to signal that
|
2005-04-16 22:20:36 +00:00
|
|
|
* the abort has finished. The proper test for this is
|
|
|
|
* the TIMED_OUT flag, not srb->result == DID_ABORT, because
|
2005-08-26 03:03:50 +00:00
|
|
|
* the timeout might have occurred after the command had
|
2016-04-18 10:09:11 +00:00
|
|
|
* already completed with a different result code.
|
|
|
|
*/
|
2008-05-01 19:35:18 +00:00
|
|
|
if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
|
2005-04-16 22:20:36 +00:00
|
|
|
complete(&(us->notify));
|
|
|
|
|
2005-08-26 03:03:50 +00:00
|
|
|
/* Allow USB transfers to resume */
|
2008-05-01 19:35:18 +00:00
|
|
|
clear_bit(US_FLIDX_ABORTING, &us->dflags);
|
|
|
|
clear_bit(US_FLIDX_TIMED_OUT, &us->dflags);
|
2005-08-26 03:03:50 +00:00
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* finished working on this command */
|
|
|
|
us->srb = NULL;
|
|
|
|
scsi_unlock(host);
|
|
|
|
|
|
|
|
/* unlock the device pointers */
|
2006-01-11 14:55:29 +00:00
|
|
|
mutex_unlock(&us->dev_mutex);
|
2017-07-26 15:49:19 +00:00
|
|
|
|
|
|
|
/* now that the locks are released, notify the SCSI core */
|
|
|
|
if (srb) {
|
|
|
|
usb_stor_dbg(us, "scsi cmd done, result=0x%x\n",
|
|
|
|
srb->result);
|
2022-02-01 21:09:54 +00:00
|
|
|
scsi_done_direct(srb);
|
2017-07-26 15:49:19 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
} /* for (;;) */
|
|
|
|
|
2007-06-07 21:12:25 +00:00
|
|
|
/* Wait until we are told to stop */
|
|
|
|
for (;;) {
|
|
|
|
set_current_state(TASK_INTERRUPTIBLE);
|
|
|
|
if (kthread_should_stop())
|
|
|
|
break;
|
|
|
|
schedule();
|
|
|
|
}
|
|
|
|
__set_current_state(TASK_RUNNING);
|
|
|
|
return 0;
|
2012-05-16 19:03:36 +00:00
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* Device probing and disconnecting
|
|
|
|
***********************************************************************/
|
|
|
|
|
|
|
|
/* Associate our private data with the USB device */
|
|
|
|
static int associate_dev(struct us_data *us, struct usb_interface *intf)
|
|
|
|
{
|
|
|
|
/* Fill in the device-related fields */
|
|
|
|
us->pusb_dev = interface_to_usbdev(intf);
|
|
|
|
us->pusb_intf = intf;
|
|
|
|
us->ifnum = intf->cur_altsetting->desc.bInterfaceNumber;
|
2013-04-19 18:44:00 +00:00
|
|
|
usb_stor_dbg(us, "Vendor: 0x%04x, Product: 0x%04x, Revision: 0x%04x\n",
|
|
|
|
le16_to_cpu(us->pusb_dev->descriptor.idVendor),
|
|
|
|
le16_to_cpu(us->pusb_dev->descriptor.idProduct),
|
|
|
|
le16_to_cpu(us->pusb_dev->descriptor.bcdDevice));
|
|
|
|
usb_stor_dbg(us, "Interface Subclass: 0x%02x, Protocol: 0x%02x\n",
|
|
|
|
intf->cur_altsetting->desc.bInterfaceSubClass,
|
|
|
|
intf->cur_altsetting->desc.bInterfaceProtocol);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Store our private data in the interface */
|
|
|
|
usb_set_intfdata(intf, us);
|
|
|
|
|
2010-03-05 20:10:17 +00:00
|
|
|
/* Allocate the control/setup and DMA-mapped buffers */
|
|
|
|
us->cr = kmalloc(sizeof(*us->cr), GFP_KERNEL);
|
2013-04-19 18:44:00 +00:00
|
|
|
if (!us->cr)
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2010-04-12 11:17:25 +00:00
|
|
|
us->iobuf = usb_alloc_coherent(us->pusb_dev, US_IOBUF_SIZE,
|
2005-04-16 22:20:36 +00:00
|
|
|
GFP_KERNEL, &us->iobuf_dma);
|
|
|
|
if (!us->iobuf) {
|
2013-04-19 18:44:00 +00:00
|
|
|
usb_stor_dbg(us, "I/O buffer allocation failed\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2008-12-15 15:40:06 +00:00
|
|
|
/* Works only for digits and letters, but small and fast */
|
|
|
|
#define TOLOWER(x) ((x) | 0x20)
|
|
|
|
|
2008-11-10 19:07:45 +00:00
|
|
|
/* Adjust device flags based on the "quirks=" module parameter */
|
2023-10-16 07:25:59 +00:00
|
|
|
void usb_stor_adjust_quirks(struct usb_device *udev, u64 *fflags)
|
2008-11-10 19:07:45 +00:00
|
|
|
{
|
2008-12-15 15:40:06 +00:00
|
|
|
char *p;
|
2013-11-16 11:09:39 +00:00
|
|
|
u16 vid = le16_to_cpu(udev->descriptor.idVendor);
|
|
|
|
u16 pid = le16_to_cpu(udev->descriptor.idProduct);
|
2023-10-16 07:25:59 +00:00
|
|
|
u64 f = 0;
|
|
|
|
u64 mask = (US_FL_SANE_SENSE | US_FL_BAD_SENSE |
|
2013-11-16 11:09:39 +00:00
|
|
|
US_FL_FIX_CAPACITY | US_FL_IGNORE_UAS |
|
2008-12-15 15:40:06 +00:00
|
|
|
US_FL_CAPACITY_HEURISTICS | US_FL_IGNORE_DEVICE |
|
2008-11-10 19:07:45 +00:00
|
|
|
US_FL_NOT_LOCKABLE | US_FL_MAX_SECTORS_64 |
|
2008-12-15 15:40:06 +00:00
|
|
|
US_FL_CAPACITY_OK | US_FL_IGNORE_RESIDUE |
|
2011-05-18 20:42:34 +00:00
|
|
|
US_FL_SINGLE_LUN | US_FL_NO_WP_DETECT |
|
2011-06-07 15:35:52 +00:00
|
|
|
US_FL_NO_READ_DISC_INFO | US_FL_NO_READ_CAPACITY_16 |
|
2014-09-15 14:04:12 +00:00
|
|
|
US_FL_INITIAL_READ10 | US_FL_WRITE_CACHE |
|
2015-04-21 09:20:31 +00:00
|
|
|
US_FL_NO_ATA_1X | US_FL_NO_REPORT_OPCODES |
|
2016-09-12 13:19:41 +00:00
|
|
|
US_FL_MAX_SECTORS_240 | US_FL_NO_REPORT_LUNS |
|
|
|
|
US_FL_ALWAYS_SYNC);
|
2008-12-15 15:40:06 +00:00
|
|
|
|
|
|
|
p = quirks;
|
|
|
|
while (*p) {
|
|
|
|
/* Each entry consists of VID:PID:flags */
|
|
|
|
if (vid == simple_strtoul(p, &p, 16) &&
|
|
|
|
*p == ':' &&
|
|
|
|
pid == simple_strtoul(p+1, &p, 16) &&
|
|
|
|
*p == ':')
|
2008-11-10 19:07:45 +00:00
|
|
|
break;
|
2008-12-15 15:40:06 +00:00
|
|
|
|
|
|
|
/* Move forward to the next entry */
|
|
|
|
while (*p) {
|
|
|
|
if (*p++ == ',')
|
|
|
|
break;
|
2008-11-10 19:07:45 +00:00
|
|
|
}
|
|
|
|
}
|
2008-12-15 15:40:06 +00:00
|
|
|
if (!*p) /* No match */
|
|
|
|
return;
|
|
|
|
|
|
|
|
/* Collect the flags */
|
|
|
|
while (*++p && *p != ',') {
|
|
|
|
switch (TOLOWER(*p)) {
|
|
|
|
case 'a':
|
|
|
|
f |= US_FL_SANE_SENSE;
|
|
|
|
break;
|
2009-12-07 21:39:16 +00:00
|
|
|
case 'b':
|
|
|
|
f |= US_FL_BAD_SENSE;
|
|
|
|
break;
|
2008-12-15 15:40:06 +00:00
|
|
|
case 'c':
|
|
|
|
f |= US_FL_FIX_CAPACITY;
|
|
|
|
break;
|
2011-05-18 20:42:34 +00:00
|
|
|
case 'd':
|
|
|
|
f |= US_FL_NO_READ_DISC_INFO;
|
|
|
|
break;
|
|
|
|
case 'e':
|
|
|
|
f |= US_FL_NO_READ_CAPACITY_16;
|
|
|
|
break;
|
2014-09-16 16:36:52 +00:00
|
|
|
case 'f':
|
|
|
|
f |= US_FL_NO_REPORT_OPCODES;
|
|
|
|
break;
|
2015-04-21 09:20:31 +00:00
|
|
|
case 'g':
|
|
|
|
f |= US_FL_MAX_SECTORS_240;
|
|
|
|
break;
|
2008-12-15 15:40:06 +00:00
|
|
|
case 'h':
|
|
|
|
f |= US_FL_CAPACITY_HEURISTICS;
|
|
|
|
break;
|
|
|
|
case 'i':
|
|
|
|
f |= US_FL_IGNORE_DEVICE;
|
|
|
|
break;
|
2016-04-12 10:27:09 +00:00
|
|
|
case 'j':
|
|
|
|
f |= US_FL_NO_REPORT_LUNS;
|
|
|
|
break;
|
2020-12-09 15:26:39 +00:00
|
|
|
case 'k':
|
|
|
|
f |= US_FL_NO_SAME;
|
|
|
|
break;
|
2008-12-15 15:40:06 +00:00
|
|
|
case 'l':
|
|
|
|
f |= US_FL_NOT_LOCKABLE;
|
|
|
|
break;
|
|
|
|
case 'm':
|
|
|
|
f |= US_FL_MAX_SECTORS_64;
|
|
|
|
break;
|
2011-06-07 15:35:52 +00:00
|
|
|
case 'n':
|
|
|
|
f |= US_FL_INITIAL_READ10;
|
|
|
|
break;
|
2008-12-15 15:40:06 +00:00
|
|
|
case 'o':
|
|
|
|
f |= US_FL_CAPACITY_OK;
|
|
|
|
break;
|
2012-07-08 03:05:28 +00:00
|
|
|
case 'p':
|
|
|
|
f |= US_FL_WRITE_CACHE;
|
|
|
|
break;
|
2008-12-15 15:40:06 +00:00
|
|
|
case 'r':
|
|
|
|
f |= US_FL_IGNORE_RESIDUE;
|
|
|
|
break;
|
|
|
|
case 's':
|
|
|
|
f |= US_FL_SINGLE_LUN;
|
|
|
|
break;
|
2014-09-15 14:04:12 +00:00
|
|
|
case 't':
|
|
|
|
f |= US_FL_NO_ATA_1X;
|
|
|
|
break;
|
2013-11-16 11:09:39 +00:00
|
|
|
case 'u':
|
|
|
|
f |= US_FL_IGNORE_UAS;
|
|
|
|
break;
|
2008-12-15 15:40:06 +00:00
|
|
|
case 'w':
|
|
|
|
f |= US_FL_NO_WP_DETECT;
|
|
|
|
break;
|
2016-09-12 13:19:41 +00:00
|
|
|
case 'y':
|
|
|
|
f |= US_FL_ALWAYS_SYNC;
|
|
|
|
break;
|
2008-12-15 15:40:06 +00:00
|
|
|
/* Ignore unrecognized flag characters */
|
|
|
|
}
|
|
|
|
}
|
2013-11-16 11:09:39 +00:00
|
|
|
*fflags = (*fflags & ~mask) | f;
|
2008-11-10 19:07:45 +00:00
|
|
|
}
|
2013-11-16 11:09:39 +00:00
|
|
|
EXPORT_SYMBOL_GPL(usb_stor_adjust_quirks);
|
2008-11-10 19:07:45 +00:00
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Get the unusual_devs entries and the string descriptors */
|
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-12 19:47:44 +00:00
|
|
|
static int get_device_info(struct us_data *us, const struct usb_device_id *id,
|
2020-02-18 00:59:54 +00:00
|
|
|
const struct us_unusual_dev *unusual_dev)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct usb_device *dev = us->pusb_dev;
|
|
|
|
struct usb_interface_descriptor *idesc =
|
|
|
|
&us->pusb_intf->cur_altsetting->desc;
|
2010-05-16 20:31:06 +00:00
|
|
|
struct device *pdev = &us->pusb_intf->dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Store the entries */
|
|
|
|
us->unusual_dev = unusual_dev;
|
2010-10-07 11:05:21 +00:00
|
|
|
us->subclass = (unusual_dev->useProtocol == USB_SC_DEVICE) ?
|
2005-04-16 22:20:36 +00:00
|
|
|
idesc->bInterfaceSubClass :
|
|
|
|
unusual_dev->useProtocol;
|
2010-10-07 11:05:21 +00:00
|
|
|
us->protocol = (unusual_dev->useTransport == USB_PR_DEVICE) ?
|
2005-04-16 22:20:36 +00:00
|
|
|
idesc->bInterfaceProtocol :
|
|
|
|
unusual_dev->useTransport;
|
2012-08-28 20:37:13 +00:00
|
|
|
us->fflags = id->driver_info;
|
2013-11-16 11:09:39 +00:00
|
|
|
usb_stor_adjust_quirks(us->pusb_dev, &us->fflags);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-05-01 19:35:18 +00:00
|
|
|
if (us->fflags & US_FL_IGNORE_DEVICE) {
|
2010-05-16 20:31:06 +00:00
|
|
|
dev_info(pdev, "device ignored\n");
|
2006-07-26 12:59:23 +00:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* This flag is only needed when we're in high-speed, so let's
|
|
|
|
* disable it if we're in full-speed
|
|
|
|
*/
|
|
|
|
if (dev->speed != USB_SPEED_HIGH)
|
2008-05-01 19:35:18 +00:00
|
|
|
us->fflags &= ~US_FL_GO_SLOW;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-05-16 20:31:07 +00:00
|
|
|
if (us->fflags)
|
2023-10-16 07:25:59 +00:00
|
|
|
dev_info(pdev, "Quirks match for vid %04x pid %04x: %llx\n",
|
2010-05-16 20:31:07 +00:00
|
|
|
le16_to_cpu(dev->descriptor.idVendor),
|
|
|
|
le16_to_cpu(dev->descriptor.idProduct),
|
|
|
|
us->fflags);
|
|
|
|
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
|
|
|
* Log a message if a non-generic unusual_dev entry contains an
|
2005-04-16 22:20:36 +00:00
|
|
|
* unnecessary subclass or protocol override. This may stimulate
|
|
|
|
* reports from users that will help us remove unneeded entries
|
|
|
|
* from the unusual_devs.h table.
|
|
|
|
*/
|
|
|
|
if (id->idVendor || id->idProduct) {
|
2005-11-29 08:43:42 +00:00
|
|
|
static const char *msgs[3] = {
|
2005-04-16 22:20:36 +00:00
|
|
|
"an unneeded SubClass entry",
|
|
|
|
"an unneeded Protocol entry",
|
|
|
|
"unneeded SubClass and Protocol entries"};
|
|
|
|
struct usb_device_descriptor *ddesc = &dev->descriptor;
|
|
|
|
int msg = -1;
|
|
|
|
|
2010-10-07 11:05:21 +00:00
|
|
|
if (unusual_dev->useProtocol != USB_SC_DEVICE &&
|
2005-04-16 22:20:36 +00:00
|
|
|
us->subclass == idesc->bInterfaceSubClass)
|
|
|
|
msg += 1;
|
2010-10-07 11:05:21 +00:00
|
|
|
if (unusual_dev->useTransport != USB_PR_DEVICE &&
|
2005-04-16 22:20:36 +00:00
|
|
|
us->protocol == idesc->bInterfaceProtocol)
|
|
|
|
msg += 2;
|
2008-05-01 19:35:18 +00:00
|
|
|
if (msg >= 0 && !(us->fflags & US_FL_NEED_OVERRIDE))
|
2010-05-16 20:31:06 +00:00
|
|
|
dev_notice(pdev, "This device "
|
|
|
|
"(%04x,%04x,%04x S %02x P %02x)"
|
|
|
|
" has %s in unusual_devs.h (kernel"
|
|
|
|
" %s)\n"
|
|
|
|
" Please send a copy of this message to "
|
|
|
|
"<linux-usb@vger.kernel.org> and "
|
|
|
|
"<usb-storage@lists.one-eyed-alien.net>\n",
|
|
|
|
le16_to_cpu(ddesc->idVendor),
|
|
|
|
le16_to_cpu(ddesc->idProduct),
|
|
|
|
le16_to_cpu(ddesc->bcdDevice),
|
|
|
|
idesc->bInterfaceSubClass,
|
|
|
|
idesc->bInterfaceProtocol,
|
|
|
|
msgs[msg],
|
|
|
|
utsname()->release);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2006-07-26 12:59:23 +00:00
|
|
|
|
|
|
|
return 0;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the transport settings */
|
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-12 19:47:44 +00:00
|
|
|
static void get_transport(struct us_data *us)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
switch (us->protocol) {
|
2010-10-07 11:05:21 +00:00
|
|
|
case USB_PR_CB:
|
2005-04-16 22:20:36 +00:00
|
|
|
us->transport_name = "Control/Bulk";
|
|
|
|
us->transport = usb_stor_CB_transport;
|
|
|
|
us->transport_reset = usb_stor_CB_reset;
|
|
|
|
us->max_lun = 7;
|
|
|
|
break;
|
|
|
|
|
2010-10-07 11:05:21 +00:00
|
|
|
case USB_PR_CBI:
|
2005-04-16 22:20:36 +00:00
|
|
|
us->transport_name = "Control/Bulk/Interrupt";
|
2008-11-20 19:20:03 +00:00
|
|
|
us->transport = usb_stor_CB_transport;
|
2005-04-16 22:20:36 +00:00
|
|
|
us->transport_reset = usb_stor_CB_reset;
|
|
|
|
us->max_lun = 7;
|
|
|
|
break;
|
|
|
|
|
2010-10-07 11:05:21 +00:00
|
|
|
case USB_PR_BULK:
|
2005-04-16 22:20:36 +00:00
|
|
|
us->transport_name = "Bulk";
|
|
|
|
us->transport = usb_stor_Bulk_transport;
|
|
|
|
us->transport_reset = usb_stor_Bulk_reset;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the protocol settings */
|
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-12 19:47:44 +00:00
|
|
|
static void get_protocol(struct us_data *us)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
switch (us->subclass) {
|
2010-10-07 11:05:21 +00:00
|
|
|
case USB_SC_RBC:
|
2005-04-16 22:20:36 +00:00
|
|
|
us->protocol_name = "Reduced Block Commands (RBC)";
|
|
|
|
us->proto_handler = usb_stor_transparent_scsi_command;
|
|
|
|
break;
|
|
|
|
|
2010-10-07 11:05:21 +00:00
|
|
|
case USB_SC_8020:
|
2005-04-16 22:20:36 +00:00
|
|
|
us->protocol_name = "8020i";
|
2008-11-20 19:22:18 +00:00
|
|
|
us->proto_handler = usb_stor_pad12_command;
|
2005-04-16 22:20:36 +00:00
|
|
|
us->max_lun = 0;
|
|
|
|
break;
|
|
|
|
|
2010-10-07 11:05:21 +00:00
|
|
|
case USB_SC_QIC:
|
2005-04-16 22:20:36 +00:00
|
|
|
us->protocol_name = "QIC-157";
|
2008-11-20 19:22:18 +00:00
|
|
|
us->proto_handler = usb_stor_pad12_command;
|
2005-04-16 22:20:36 +00:00
|
|
|
us->max_lun = 0;
|
|
|
|
break;
|
|
|
|
|
2010-10-07 11:05:21 +00:00
|
|
|
case USB_SC_8070:
|
2005-04-16 22:20:36 +00:00
|
|
|
us->protocol_name = "8070i";
|
2008-11-20 19:22:18 +00:00
|
|
|
us->proto_handler = usb_stor_pad12_command;
|
2005-04-16 22:20:36 +00:00
|
|
|
us->max_lun = 0;
|
|
|
|
break;
|
|
|
|
|
2010-10-07 11:05:21 +00:00
|
|
|
case USB_SC_SCSI:
|
2005-04-16 22:20:36 +00:00
|
|
|
us->protocol_name = "Transparent SCSI";
|
|
|
|
us->proto_handler = usb_stor_transparent_scsi_command;
|
|
|
|
break;
|
|
|
|
|
2010-10-07 11:05:21 +00:00
|
|
|
case USB_SC_UFI:
|
2005-04-16 22:20:36 +00:00
|
|
|
us->protocol_name = "Uniform Floppy Interface (UFI)";
|
|
|
|
us->proto_handler = usb_stor_ufi_command;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the pipe settings */
|
|
|
|
static int get_pipes(struct us_data *us)
|
|
|
|
{
|
2017-03-17 10:35:49 +00:00
|
|
|
struct usb_host_interface *alt = us->pusb_intf->cur_altsetting;
|
|
|
|
struct usb_endpoint_descriptor *ep_in;
|
|
|
|
struct usb_endpoint_descriptor *ep_out;
|
|
|
|
struct usb_endpoint_descriptor *ep_int;
|
|
|
|
int res;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
2007-01-22 16:58:34 +00:00
|
|
|
* Find the first endpoint of each type we need.
|
2005-04-16 22:20:36 +00:00
|
|
|
* We are expecting a minimum of 2 endpoints - in and out (bulk).
|
2007-01-22 16:58:34 +00:00
|
|
|
* An optional interrupt-in is OK (necessary for CBI protocol).
|
2005-04-16 22:20:36 +00:00
|
|
|
* We will ignore any others.
|
|
|
|
*/
|
2017-03-17 10:35:49 +00:00
|
|
|
res = usb_find_common_endpoints(alt, &ep_in, &ep_out, NULL, NULL);
|
|
|
|
if (res) {
|
|
|
|
usb_stor_dbg(us, "bulk endpoints not found\n");
|
|
|
|
return res;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2017-03-17 10:35:49 +00:00
|
|
|
res = usb_find_int_in_endpoint(alt, &ep_int);
|
|
|
|
if (res && us->protocol == USB_PR_CBI) {
|
|
|
|
usb_stor_dbg(us, "interrupt endpoint not found\n");
|
|
|
|
return res;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Calculate and store the pipe values */
|
|
|
|
us->send_ctrl_pipe = usb_sndctrlpipe(us->pusb_dev, 0);
|
|
|
|
us->recv_ctrl_pipe = usb_rcvctrlpipe(us->pusb_dev, 0);
|
|
|
|
us->send_bulk_pipe = usb_sndbulkpipe(us->pusb_dev,
|
2008-12-29 10:22:14 +00:00
|
|
|
usb_endpoint_num(ep_out));
|
2012-05-16 19:03:36 +00:00
|
|
|
us->recv_bulk_pipe = usb_rcvbulkpipe(us->pusb_dev,
|
2008-12-29 10:22:14 +00:00
|
|
|
usb_endpoint_num(ep_in));
|
2005-04-16 22:20:36 +00:00
|
|
|
if (ep_int) {
|
|
|
|
us->recv_intr_pipe = usb_rcvintpipe(us->pusb_dev,
|
2008-12-29 10:22:14 +00:00
|
|
|
usb_endpoint_num(ep_int));
|
2005-04-16 22:20:36 +00:00
|
|
|
us->ep_bInterval = ep_int->bInterval;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize all the dynamic resources we need */
|
|
|
|
static int usb_stor_acquire_resources(struct us_data *us)
|
|
|
|
{
|
|
|
|
int p;
|
2005-10-24 02:43:36 +00:00
|
|
|
struct task_struct *th;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
us->current_urb = usb_alloc_urb(0, GFP_KERNEL);
|
2016-08-11 21:14:46 +00:00
|
|
|
if (!us->current_urb)
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
|
|
|
* Just before we start our control thread, initialize
|
|
|
|
* the device if it needs initialization
|
|
|
|
*/
|
2005-10-24 02:38:56 +00:00
|
|
|
if (us->unusual_dev->initFunction) {
|
|
|
|
p = us->unusual_dev->initFunction(us);
|
|
|
|
if (p)
|
|
|
|
return p;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Start up our control thread */
|
2007-06-07 21:12:25 +00:00
|
|
|
th = kthread_run(usb_stor_control_thread, us, "usb-storage");
|
2005-10-24 02:43:36 +00:00
|
|
|
if (IS_ERR(th)) {
|
2010-05-16 20:31:06 +00:00
|
|
|
dev_warn(&us->pusb_intf->dev,
|
|
|
|
"Unable to start control thread\n");
|
2005-10-24 02:43:36 +00:00
|
|
|
return PTR_ERR(th);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2007-06-07 21:12:25 +00:00
|
|
|
us->ctl_thread = th;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Release all our dynamic resources */
|
|
|
|
static void usb_stor_release_resources(struct us_data *us)
|
|
|
|
{
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
|
|
|
* Tell the control thread to exit. The SCSI host must
|
2008-05-08 15:55:59 +00:00
|
|
|
* already have been removed and the DISCONNECTING flag set
|
|
|
|
* so that we won't accept any more commands.
|
2005-04-16 22:20:36 +00:00
|
|
|
*/
|
2013-04-19 18:44:00 +00:00
|
|
|
usb_stor_dbg(us, "-- sending exit command to thread\n");
|
2008-05-01 19:36:13 +00:00
|
|
|
complete(&us->cmnd_ready);
|
2007-06-07 21:12:25 +00:00
|
|
|
if (us->ctl_thread)
|
|
|
|
kthread_stop(us->ctl_thread);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Call the destructor routine, if it exists */
|
|
|
|
if (us->extra_destructor) {
|
2013-04-19 18:44:00 +00:00
|
|
|
usb_stor_dbg(us, "-- calling extra_destructor()\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
us->extra_destructor(us->extra);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free the extra data and the URB */
|
|
|
|
kfree(us->extra);
|
|
|
|
usb_free_urb(us->current_urb);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Dissociate from the USB device */
|
|
|
|
static void dissociate_dev(struct us_data *us)
|
|
|
|
{
|
2010-03-05 20:10:17 +00:00
|
|
|
/* Free the buffers */
|
|
|
|
kfree(us->cr);
|
2010-04-12 11:17:25 +00:00
|
|
|
usb_free_coherent(us->pusb_dev, US_IOBUF_SIZE, us->iobuf, us->iobuf_dma);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Remove our private data from the interface */
|
|
|
|
usb_set_intfdata(us->pusb_intf, NULL);
|
|
|
|
}
|
|
|
|
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
|
|
|
* First stage of disconnect processing: stop SCSI scanning,
|
2008-05-08 15:55:59 +00:00
|
|
|
* remove the host, and stop accepting new commands
|
|
|
|
*/
|
2005-07-28 21:44:29 +00:00
|
|
|
static void quiesce_and_remove_host(struct us_data *us)
|
|
|
|
{
|
2006-06-19 18:50:15 +00:00
|
|
|
struct Scsi_Host *host = us_to_host(us);
|
|
|
|
|
2008-05-08 15:55:59 +00:00
|
|
|
/* If the device is really gone, cut short reset delays */
|
2012-02-21 18:16:32 +00:00
|
|
|
if (us->pusb_dev->state == USB_STATE_NOTATTACHED) {
|
2008-05-08 15:55:59 +00:00
|
|
|
set_bit(US_FLIDX_DISCONNECTING, &us->dflags);
|
2012-02-21 18:16:32 +00:00
|
|
|
wake_up(&us->delay_wait);
|
|
|
|
}
|
2005-07-28 21:44:29 +00:00
|
|
|
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
|
|
|
* Prevent SCSI scanning (if it hasn't started yet)
|
2012-02-21 18:16:32 +00:00
|
|
|
* or wait for the SCSI-scanning routine to stop.
|
2008-05-08 15:55:59 +00:00
|
|
|
*/
|
2012-02-21 18:16:32 +00:00
|
|
|
cancel_delayed_work_sync(&us->scan_dwork);
|
|
|
|
|
|
|
|
/* Balance autopm calls if scanning was cancelled */
|
|
|
|
if (test_bit(US_FLIDX_SCAN_PENDING, &us->dflags))
|
|
|
|
usb_autopm_put_interface_no_suspend(us->pusb_intf);
|
2005-07-28 21:45:50 +00:00
|
|
|
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
|
|
|
* Removing the host will perform an orderly shutdown: caches
|
2008-05-08 15:55:59 +00:00
|
|
|
* synchronized, disks spun down, etc.
|
|
|
|
*/
|
2006-06-19 18:50:15 +00:00
|
|
|
scsi_remove_host(host);
|
2007-08-16 20:16:00 +00:00
|
|
|
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
|
|
|
* Prevent any new commands from being accepted and cut short
|
2008-05-08 15:55:59 +00:00
|
|
|
* reset delays.
|
|
|
|
*/
|
|
|
|
scsi_lock(host);
|
|
|
|
set_bit(US_FLIDX_DISCONNECTING, &us->dflags);
|
|
|
|
scsi_unlock(host);
|
|
|
|
wake_up(&us->delay_wait);
|
2005-07-28 21:44:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Second stage of disconnect processing: deallocate all resources */
|
|
|
|
static void release_everything(struct us_data *us)
|
|
|
|
{
|
|
|
|
usb_stor_release_resources(us);
|
|
|
|
dissociate_dev(us);
|
|
|
|
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
|
|
|
* Drop our reference to the host; the SCSI core will free it
|
|
|
|
* (and "us" along with it) when the refcount becomes 0.
|
|
|
|
*/
|
2005-07-28 21:44:29 +00:00
|
|
|
scsi_host_put(us_to_host(us));
|
|
|
|
}
|
|
|
|
|
2012-02-21 18:16:32 +00:00
|
|
|
/* Delayed-work routine to carry out SCSI-device scanning */
|
|
|
|
static void usb_stor_scan_dwork(struct work_struct *work)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2012-02-21 18:16:32 +00:00
|
|
|
struct us_data *us = container_of(work, struct us_data,
|
|
|
|
scan_dwork.work);
|
2010-05-16 20:31:06 +00:00
|
|
|
struct device *dev = &us->pusb_intf->dev;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-02-21 18:16:32 +00:00
|
|
|
dev_dbg(dev, "starting scan\n");
|
2011-11-21 20:32:26 +00:00
|
|
|
|
2012-02-21 18:16:32 +00:00
|
|
|
/* For bulk-only devices, determine the max LUN value */
|
2014-11-08 21:39:55 +00:00
|
|
|
if (us->protocol == USB_PR_BULK &&
|
|
|
|
!(us->fflags & US_FL_SINGLE_LUN) &&
|
|
|
|
!(us->fflags & US_FL_SCM_MULT_TARG)) {
|
2012-02-21 18:16:32 +00:00
|
|
|
mutex_lock(&us->dev_mutex);
|
|
|
|
us->max_lun = usb_stor_Bulk_max_lun(us);
|
2015-02-10 08:27:59 +00:00
|
|
|
/*
|
|
|
|
* Allow proper scanning of devices that present more than 8 LUNs
|
2016-04-18 10:09:11 +00:00
|
|
|
* While not affecting other devices that may need the previous
|
|
|
|
* behavior
|
2015-02-10 08:27:59 +00:00
|
|
|
*/
|
|
|
|
if (us->max_lun >= 8)
|
|
|
|
us_to_host(us)->max_lun = us->max_lun+1;
|
2012-02-21 18:16:32 +00:00
|
|
|
mutex_unlock(&us->dev_mutex);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2012-02-21 18:16:32 +00:00
|
|
|
scsi_scan_host(us_to_host(us));
|
|
|
|
dev_dbg(dev, "scan complete\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-02-21 18:16:32 +00:00
|
|
|
/* Should we unbind if no devices were detected? */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2010-07-28 21:12:39 +00:00
|
|
|
usb_autopm_put_interface(us->pusb_intf);
|
2012-02-21 18:16:32 +00:00
|
|
|
clear_bit(US_FLIDX_SCAN_PENDING, &us->dflags);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2009-08-24 13:44:30 +00:00
|
|
|
static unsigned int usb_stor_sg_tablesize(struct usb_interface *intf)
|
|
|
|
{
|
|
|
|
struct usb_device *usb_dev = interface_to_usbdev(intf);
|
|
|
|
|
|
|
|
if (usb_dev->bus->sg_tablesize) {
|
|
|
|
return usb_dev->bus->sg_tablesize;
|
|
|
|
}
|
|
|
|
return SG_ALL;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
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-12 19:47:44 +00:00
|
|
|
/* First part of general USB mass-storage probing */
|
|
|
|
int usb_stor_probe1(struct us_data **pus,
|
|
|
|
struct usb_interface *intf,
|
|
|
|
const struct usb_device_id *id,
|
2020-02-18 00:59:54 +00:00
|
|
|
const struct us_unusual_dev *unusual_dev,
|
2023-03-22 19:55:15 +00:00
|
|
|
const struct scsi_host_template *sht)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct Scsi_Host *host;
|
|
|
|
struct us_data *us;
|
|
|
|
int result;
|
2005-10-23 03:15:09 +00:00
|
|
|
|
2013-04-19 18:44:00 +00:00
|
|
|
dev_info(&intf->dev, "USB Mass Storage device detected\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Ask the SCSI layer to allocate a host structure, with extra
|
|
|
|
* space at the end for our private us_data structure.
|
|
|
|
*/
|
2015-05-06 09:24:21 +00:00
|
|
|
host = scsi_host_alloc(sht, sizeof(*us));
|
2005-04-16 22:20:36 +00:00
|
|
|
if (!host) {
|
2013-04-19 18:44:00 +00:00
|
|
|
dev_warn(&intf->dev, "Unable to allocate the scsi host\n");
|
2005-04-16 22:20:36 +00:00
|
|
|
return -ENOMEM;
|
|
|
|
}
|
|
|
|
|
2007-10-10 17:56:28 +00:00
|
|
|
/*
|
|
|
|
* Allow 16-byte CDBs and thus > 2TB
|
|
|
|
*/
|
|
|
|
host->max_cmd_len = 16;
|
2009-08-24 13:44:30 +00:00
|
|
|
host->sg_tablesize = usb_stor_sg_tablesize(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-12 19:47:44 +00:00
|
|
|
*pus = us = host_to_us(host);
|
2006-01-11 14:55:29 +00:00
|
|
|
mutex_init(&(us->dev_mutex));
|
2012-03-19 07:20:57 +00:00
|
|
|
us_set_lock_class(&us->dev_mutex, intf);
|
2008-05-01 19:36:13 +00:00
|
|
|
init_completion(&us->cmnd_ready);
|
2005-04-16 22:20:36 +00:00
|
|
|
init_completion(&(us->notify));
|
|
|
|
init_waitqueue_head(&us->delay_wait);
|
2012-02-21 18:16:32 +00:00
|
|
|
INIT_DELAYED_WORK(&us->scan_dwork, usb_stor_scan_dwork);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
/* Associate the us_data structure with the USB device */
|
|
|
|
result = associate_dev(us, intf);
|
|
|
|
if (result)
|
|
|
|
goto BadDevice;
|
|
|
|
|
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-12 19:47:44 +00:00
|
|
|
/* Get the unusual_devs entries and the descriptors */
|
|
|
|
result = get_device_info(us, id, unusual_dev);
|
2006-07-26 12:59:23 +00:00
|
|
|
if (result)
|
|
|
|
goto BadDevice;
|
2005-04-16 22:20:36 +00:00
|
|
|
|
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-12 19:47:44 +00:00
|
|
|
/* Get standard transport and protocol settings */
|
|
|
|
get_transport(us);
|
|
|
|
get_protocol(us);
|
|
|
|
|
2016-04-18 10:09:11 +00:00
|
|
|
/*
|
|
|
|
* Give the caller a chance to fill in specialized transport
|
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-12 19:47:44 +00:00
|
|
|
* or protocol settings.
|
|
|
|
*/
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
BadDevice:
|
2013-04-19 18:44:00 +00:00
|
|
|
usb_stor_dbg(us, "storage_probe() failed\n");
|
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-12 19:47:44 +00:00
|
|
|
release_everything(us);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
EXPORT_SYMBOL_GPL(usb_stor_probe1);
|
|
|
|
|
|
|
|
/* Second part of general USB mass-storage probing */
|
|
|
|
int usb_stor_probe2(struct us_data *us)
|
|
|
|
{
|
|
|
|
int result;
|
2010-05-16 20:31:06 +00:00
|
|
|
struct device *dev = &us->pusb_intf->dev;
|
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-12 19:47:44 +00:00
|
|
|
|
|
|
|
/* Make sure the transport and protocol have both been set */
|
|
|
|
if (!us->transport || !us->proto_handler) {
|
|
|
|
result = -ENXIO;
|
2005-04-16 22:20:36 +00:00
|
|
|
goto BadDevice;
|
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-12 19:47:44 +00:00
|
|
|
}
|
2013-04-19 18:44:00 +00:00
|
|
|
usb_stor_dbg(us, "Transport: %s\n", us->transport_name);
|
|
|
|
usb_stor_dbg(us, "Protocol: %s\n", us->protocol_name);
|
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-12 19:47:44 +00:00
|
|
|
|
2014-11-08 21:39:55 +00:00
|
|
|
if (us->fflags & US_FL_SCM_MULT_TARG) {
|
|
|
|
/*
|
|
|
|
* SCM eUSCSI bridge devices can have different numbers
|
|
|
|
* of LUNs on different targets; allow all to be probed.
|
|
|
|
*/
|
|
|
|
us->max_lun = 7;
|
|
|
|
/* The eUSCSI itself has ID 7, so avoid scanning that */
|
|
|
|
us_to_host(us)->this_id = 7;
|
|
|
|
/* max_id is 8 initially, so no need to set it here */
|
|
|
|
} else {
|
|
|
|
/* In the normal case there is only a single target */
|
|
|
|
us_to_host(us)->max_id = 1;
|
|
|
|
/*
|
|
|
|
* Like Windows, we won't store the LUN bits in CDB[1] for
|
|
|
|
* SCSI-2 devices using the Bulk-Only transport (even though
|
|
|
|
* this violates the SCSI spec).
|
|
|
|
*/
|
|
|
|
if (us->transport == usb_stor_Bulk_transport)
|
|
|
|
us_to_host(us)->no_scsi2_lun_in_cdb = 1;
|
|
|
|
}
|
|
|
|
|
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-12 19:47:44 +00:00
|
|
|
/* fix for single-lun devices */
|
|
|
|
if (us->fflags & US_FL_SINGLE_LUN)
|
|
|
|
us->max_lun = 0;
|
|
|
|
|
|
|
|
/* Find the endpoints and calculate pipe values */
|
2005-04-16 22:20:36 +00:00
|
|
|
result = get_pipes(us);
|
|
|
|
if (result)
|
|
|
|
goto BadDevice;
|
|
|
|
|
2011-06-07 15:35:52 +00:00
|
|
|
/*
|
|
|
|
* If the device returns invalid data for the first READ(10)
|
|
|
|
* command, indicate the command should be retried.
|
|
|
|
*/
|
|
|
|
if (us->fflags & US_FL_INITIAL_READ10)
|
|
|
|
set_bit(US_FLIDX_REDO_READ10, &us->dflags);
|
|
|
|
|
2005-04-16 22:20:36 +00:00
|
|
|
/* Acquire all the other resources and add the host */
|
|
|
|
result = usb_stor_acquire_resources(us);
|
|
|
|
if (result)
|
|
|
|
goto BadDevice;
|
2016-08-03 19:46:47 +00:00
|
|
|
usb_autopm_get_interface_no_resume(us->pusb_intf);
|
2009-09-24 22:19:11 +00:00
|
|
|
snprintf(us->scsi_name, sizeof(us->scsi_name), "usb-storage %s",
|
2020-12-04 15:01:23 +00:00
|
|
|
dev_name(&us->pusb_intf->dev));
|
|
|
|
result = scsi_add_host(us_to_host(us), dev);
|
2005-04-16 22:20:36 +00:00
|
|
|
if (result) {
|
2010-05-16 20:31:06 +00:00
|
|
|
dev_warn(dev,
|
|
|
|
"Unable to add the scsi host\n");
|
2016-08-03 19:46:47 +00:00
|
|
|
goto HostAddErr;
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
|
|
|
|
2012-02-21 18:16:32 +00:00
|
|
|
/* Submit the delayed_work for SCSI-device scanning */
|
|
|
|
set_bit(US_FLIDX_SCAN_PENDING, &us->dflags);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2012-02-21 18:16:32 +00:00
|
|
|
if (delay_use > 0)
|
|
|
|
dev_dbg(dev, "waiting for device to settle before scanning\n");
|
|
|
|
queue_delayed_work(system_freezable_wq, &us->scan_dwork,
|
|
|
|
delay_use * HZ);
|
2005-04-16 22:20:36 +00:00
|
|
|
return 0;
|
|
|
|
|
|
|
|
/* We come here if there are any problems */
|
2016-08-03 19:46:47 +00:00
|
|
|
HostAddErr:
|
|
|
|
usb_autopm_put_interface_no_suspend(us->pusb_intf);
|
2005-04-16 22:20:36 +00:00
|
|
|
BadDevice:
|
2013-04-19 18:44:00 +00:00
|
|
|
usb_stor_dbg(us, "storage_probe() failed\n");
|
2005-07-28 21:44:29 +00:00
|
|
|
release_everything(us);
|
2005-04-16 22:20:36 +00:00
|
|
|
return result;
|
|
|
|
}
|
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-12 19:47:44 +00:00
|
|
|
EXPORT_SYMBOL_GPL(usb_stor_probe2);
|
2005-04-16 22:20:36 +00:00
|
|
|
|
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-12 19:47:44 +00:00
|
|
|
/* Handle a USB mass-storage disconnect */
|
|
|
|
void usb_stor_disconnect(struct usb_interface *intf)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
struct us_data *us = usb_get_intfdata(intf);
|
|
|
|
|
2005-07-28 21:44:29 +00:00
|
|
|
quiesce_and_remove_host(us);
|
|
|
|
release_everything(us);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
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-12 19:47:44 +00:00
|
|
|
EXPORT_SYMBOL_GPL(usb_stor_disconnect);
|
|
|
|
|
2015-05-06 09:24:21 +00:00
|
|
|
static struct scsi_host_template usb_stor_host_template;
|
|
|
|
|
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-12 19:47:44 +00:00
|
|
|
/* The main probe routine for standard devices */
|
|
|
|
static int storage_probe(struct usb_interface *intf,
|
|
|
|
const struct usb_device_id *id)
|
|
|
|
{
|
2020-02-18 00:59:54 +00:00
|
|
|
const struct us_unusual_dev *unusual_dev;
|
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-12 19:47:44 +00:00
|
|
|
struct us_data *us;
|
|
|
|
int result;
|
2012-01-14 02:16:40 +00:00
|
|
|
int size;
|
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-12 19:47:44 +00:00
|
|
|
|
2013-10-21 08:40:48 +00:00
|
|
|
/* If uas is enabled and this device can do uas then ignore it. */
|
|
|
|
#if IS_ENABLED(CONFIG_USB_UAS)
|
2015-04-21 09:20:30 +00:00
|
|
|
if (uas_use_uas_driver(intf, id, NULL))
|
2013-10-21 08:40:48 +00:00
|
|
|
return -ENXIO;
|
|
|
|
#endif
|
|
|
|
|
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-12 19:47:44 +00:00
|
|
|
/*
|
|
|
|
* If the device isn't standard (is handled by a subdriver
|
|
|
|
* module) then don't accept it.
|
|
|
|
*/
|
2012-08-28 20:37:13 +00:00
|
|
|
if (usb_usual_ignore_device(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-12 19:47:44 +00:00
|
|
|
return -ENXIO;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Call the general probe procedures.
|
|
|
|
*
|
|
|
|
* The unusual_dev_list array is parallel to the usb_storage_usb_ids
|
|
|
|
* table, so we use the index of the id entry to find the
|
|
|
|
* corresponding unusual_devs entry.
|
|
|
|
*/
|
2012-01-14 02:16:40 +00:00
|
|
|
|
|
|
|
size = ARRAY_SIZE(us_unusual_dev_list);
|
|
|
|
if (id >= usb_storage_usb_ids && id < usb_storage_usb_ids + size) {
|
|
|
|
unusual_dev = (id - usb_storage_usb_ids) + us_unusual_dev_list;
|
|
|
|
} else {
|
|
|
|
unusual_dev = &for_dynamic_ids;
|
|
|
|
|
2013-04-19 18:44:00 +00:00
|
|
|
dev_dbg(&intf->dev, "Use Bulk-Only transport with the Transparent SCSI protocol for dynamic id: 0x%04x 0x%04x\n",
|
2012-01-14 02:16:40 +00:00
|
|
|
id->idVendor, id->idProduct);
|
|
|
|
}
|
|
|
|
|
2015-05-06 09:24:21 +00:00
|
|
|
result = usb_stor_probe1(&us, intf, id, unusual_dev,
|
|
|
|
&usb_stor_host_template);
|
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-12 19:47:44 +00:00
|
|
|
if (result)
|
|
|
|
return result;
|
|
|
|
|
|
|
|
/* No special transport or protocol settings in the main module */
|
|
|
|
|
|
|
|
result = usb_stor_probe2(us);
|
|
|
|
return result;
|
|
|
|
}
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2005-10-24 02:41:39 +00:00
|
|
|
static struct usb_driver usb_storage_driver = {
|
2015-05-06 09:24:21 +00:00
|
|
|
.name = DRV_NAME,
|
2005-10-24 02:41:39 +00:00
|
|
|
.probe = storage_probe,
|
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-12 19:47:44 +00:00
|
|
|
.disconnect = usb_stor_disconnect,
|
|
|
|
.suspend = usb_stor_suspend,
|
|
|
|
.resume = usb_stor_resume,
|
|
|
|
.reset_resume = usb_stor_reset_resume,
|
|
|
|
.pre_reset = usb_stor_pre_reset,
|
|
|
|
.post_reset = usb_stor_post_reset,
|
|
|
|
.id_table = usb_storage_usb_ids,
|
2010-07-28 21:12:39 +00:00
|
|
|
.supports_autosuspend = 1,
|
2008-05-08 15:55:59 +00:00
|
|
|
.soft_unbind = 1,
|
2005-10-24 02:41:39 +00:00
|
|
|
};
|
|
|
|
|
2015-05-06 09:24:21 +00:00
|
|
|
module_usb_stor_driver(usb_storage_driver, usb_stor_host_template, DRV_NAME);
|