23 Apr, 2020

1 commit

  • This patch corrects the SPDX License Identifier style in
    header files related to USB Storage driver configuration.
    For C header files Documentation/process/license-rules.rst
    mandates C-like comments (opposed to C source files where
    C++ style should be used).

    Changes made by using a script provided by Joe Perches here:
    https://lkml.org/lkml/2019/2/7/46.

    Suggested-by: Joe Perches
    Signed-off-by: Nishad Kamdar
    Link: https://lore.kernel.org/r/20200419131653.GA6611@nishad
    Signed-off-by: Greg Kroah-Hartman

    Nishad Kamdar
     

19 Feb, 2020

1 commit

  • Make structs const to reduce data size ~20KB.

    Change function arguments and prototypes as necessary to compile.

    $ size (x86-64 defconfig pre)
    text data bss dec hex filename
    12281 10948 480 23709 5c9d ./drivers/usb/storage/usb.o
    111 10528 8 10647 2997 ./drivers/usb/storage/usual-tables.o

    $ size (x86-64 defconfig post)
    text data bss dec hex filename
    22809 420 480 23709 5c9d drivers/usb/storage/usb.o
    10551 0 0 10551 2937 drivers/usb/storage/usual-tables.o

    Signed-off-by: Joe Perches
    Acked-by: Alan Stern
    Link: https://lore.kernel.org/r/cf13bd2d790ae3afbf5da55ea7bed12e00c5119d.camel@perches.com
    Signed-off-by: Greg Kroah-Hartman

    Joe Perches
     

23 Jan, 2018

1 commit


04 Nov, 2017

2 commits

  • Now that the SPDX tag is in all USB files, that identifies the license
    in a specific and legally-defined manner. So the extra GPL text wording
    can be removed as it is no longer needed at all.

    This is done on a quest to remove the 700+ different ways that files in
    the kernel describe the GPL license text. And there's unneeded stuff
    like the address (sometimes incorrect) for the FSF which is never
    needed.

    No copyright headers or other non-license-description text was removed.

    Cc: Oliver Neukum
    Signed-off-by: Greg Kroah-Hartman
    Acked-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • It's good to have SPDX identifiers in all files to make it easier to
    audit the kernel tree for correct licenses.

    Update the drivers/usb/ and include/linux/usb* files with the correct
    SPDX license identifier based on the license text in the file itself.
    The SPDX identifier is a legally binding shorthand, which can be used
    instead of the full boiler plate text.

    This work is based on a script and data from Thomas Gleixner, Philippe
    Ombredanne, and Kate Stewart.

    Cc: Thomas Gleixner
    Cc: Kate Stewart
    Cc: Philippe Ombredanne
    Signed-off-by: Greg Kroah-Hartman
    Acked-by: Felipe Balbi
    Acked-by: Johan Hovold
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

27 Apr, 2016

1 commit


10 May, 2015

1 commit

  • While accessing a unusual usb storage (ums-alauda, ums-cypress, ...),
    the module reference count is not incremented. Because these drivers
    allocate scsi hosts with usb_stor_host_template defined in usb-storage
    module. So these drivers always can be unloaded.

    This fixes it by preparing scsi host template which is initialized
    at module_init() for each ums-* driver. In order to minimize the
    difference in ums-* drivers, introduce module_usb_stor_driver() helper
    macro which is same as module_usb_driver() except that it also
    initializes scsi host template.

    Signed-off-by: Akinobu Mita
    Cc: Vinayak Holikatti
    Cc: Dolev Raviv
    Cc: Sujit Reddy Thumma
    Cc: Subhash Jadavani
    Cc: Christoph Hellwig
    Cc: "James E.J. Bottomley"
    Cc: Matthew Dharm
    Cc: Greg Kroah-Hartman
    Cc: "David S. Miller"
    Cc: Hannes Reinecke
    Cc: linux-usb@vger.kernel.org
    Cc: usb-storage@lists.one-eyed-alien.net
    Cc: linux-scsi@vger.kernel.org
    Acked-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Akinobu Mita
     

05 Mar, 2014

1 commit


22 Feb, 2012

1 commit

  • This patch (as1521b) fixes the interaction between usb-storage's
    scanning thread and the freezer. The current implementation has a
    race: If the device is unplugged shortly after being plugged in and
    just as a system sleep begins, the scanning thread may get frozen
    before the khubd task. Khubd won't be able to freeze until the
    disconnect processing is complete, and the disconnect processing can't
    proceed until the scanning thread finishes, so the sleep transition
    will fail.

    The implementation in the 3.2 kernel suffers from an additional
    problem. There the scanning thread calls set_freezable_with_signal(),
    and the signals sent by the freezer will mess up the thread's I/O
    delays, which are all interruptible.

    The solution to both problems is the same: Replace the kernel thread
    used for scanning with a delayed-work routine on the system freezable
    work queue. Freezable work queues have the nice property that you can
    cancel a work item even while the work queue is frozen, and no signals
    are needed.

    The 3.2 version of this patch solves the problem in Bugzilla #42730.

    Signed-off-by: Alan Stern
    Acked-by: Seth Forshee
    CC: stable
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

08 Jun, 2011

1 commit

  • Some USB mass-storage devices have bugs that cause them not to handle
    the first READ(10) command they receive correctly. The Corsair
    Padlock v2 returns completely bogus data for its first read (possibly
    it returns the data in encrypted form even though the device is
    supposed to be unlocked). The Feiya SD/SDHC card reader fails to
    complete the first READ(10) command after it is plugged in or after a
    new card is inserted, returning a status code that indicates it thinks
    the command was invalid, which prevents the kernel from retrying the
    read.

    Since the first read of a new device or a new medium is for the
    partition sector, the kernel is unable to retrieve the device's
    partition table. Users have to manually issue an "hdparm -z" or
    "blockdev --rereadpt" command before they can access the device.

    This patch (as1470) works around the problem. It adds a new quirk
    flag, US_FL_INVALID_READ10, indicating that the first READ(10) should
    always be retried immediately, as should any failing READ(10) commands
    (provided the preceding READ(10) command succeeded, to avoid getting
    stuck in a loop). The patch also adds appropriate unusual_devs
    entries containing the new flag.

    Signed-off-by: Alan Stern
    Tested-by: Sven Geggus
    Tested-by: Paul Hartman
    CC: Matthew Dharm
    CC:
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

21 May, 2010

1 commit

  • This patch (as1350) removes all usages of coherent buffers for USB
    control-request setup-packet buffers. There's no good reason to
    reserve coherent memory for these things; control requests are hardly
    ever used in large quantity (the major exception is firmware
    transfers, and they aren't time-critical). Furthermore, only seven
    drivers used it. We might as well always use streaming DMA mappings
    for setup-packet buffers, and remove some extra complexity from
    usbcore.

    The DMA-mapping portion of hcd.c is currently in flux. A separate
    patch will be submitted to remove support for URB_NO_SETUP_DMA_MAP
    after everything else settles down. The removal should go smoothly,
    as by then nobody will be using it.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

12 Dec, 2009

1 commit


25 Mar, 2009

1 commit

  • 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
    CC: Matthew Dharm
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

08 Jan, 2009

2 commits

  • 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
    Cc: stable
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • This patch (as1171) removes us->sensebuf, since it isn't used anywhere.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

22 Jul, 2008

4 commits

  • This patch removes CVS keywords that weren't updated for a long time
    from comments.

    Signed-off-by: Adrian Bunk
    Signed-off-by: Greg Kroah-Hartman

    Adrian Bunk
     
  • This patch (as1092) implements "soft" unbinding for usb-storage. When
    the disconnect routine is called, all commands and reset delays are
    allowed to complete normally until after scsi_remove_host() returns.
    This means that the commands needed for an orderly shutdown will be
    sent through to the device.

    Unlike before, the driver will now execute every command that it
    accepts. Hence there's no need for special code to catch unexecuted
    commands and fail them.

    The new sequence of events when disconnect runs goes as follows:

    If the device is truly unplugged, set the DISCONNECTING
    flag so we won't try to access it any more.

    If the SCSI-scanning thread hasn't started up yet, prevent
    it from doing anything by setting the new DONT_SCAN flag.
    Then wake it up and wait for it to terminate.

    Remove the SCSI host. This unbinds the upper-level drivers,
    doing an orderly shutdown. Commands sent to quiesce the
    device will be transmitted normally, unless the device is
    unplugged.

    Set the DISCONNECTING flag so that we won't accept any new
    commands that might get submitted (there aren't supposed to be
    any) and we won't try to access the device for resets.

    Tell the control thread to exit by waking it up with no
    pending command, and wait for it to terminate.

    Go on to do all the other normal stuff: releasing resources,
    freeing memory, and so on.

    Signed-off-by: Alan Stern
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • This patch (as1090) converts the one remaining semaphore in
    usb-storage into a completion.

    Signed-off-by: Alan Stern
    Cc: Matthew Dharm
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • This patch (as1089) separates out the dynamic atomic bitflags and the
    static bitfields in usb-storage. Until now the two sorts of flags
    have been sharing the same word; this has always been awkward.

    To help prevent possible confusion, the two new fields each have a
    different name from the original. us->fflags contains the fixed
    bitfields (mostly taken from the USB ID table in unusual_devs.h), and
    us->dflags contains the dynamic atomic bitflags (used with set_bit,
    test_bit, and so on).

    Signed-off-by: Alan Stern
    Cc: Matthew Dharm
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

23 Aug, 2007

1 commit

  • This patch (as961) fixes a couple of bugs in the disconnect pathway of
    usb-storage.

    The first problem, which apparently has been around for a while
    although nobody noticed it, shows up when an aborted command is still
    pending when a disconnect occurs. The SCSI error-handler will
    continue to wait in command_abort() until the us->notify completion is
    signalled. Thus quiesce_and_remove_host() needs to signal it.

    The second problem was introduced recently along with autosuspend
    support. Since usb_stor_scan_thread() now calls
    usb_autopm_put_interface() before exiting, we can't simply leave the
    scanning thread running after a disconnect; we must wait until the
    thread exits. This is solved by adding a new struct completion to the
    private data structure. Fortuitously, it allows the removal of the
    rather clunky mechanism used in the past to insure that all threads
    have finished before the module is unloaded.

    Signed-off-by: Alan Stern
    CC: Matthew Dharm
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

13 Jul, 2007

1 commit

  • This patch (as923) makes usb-storage's control thread use
    kthread_should_stop()/kthread_stop(). The scanning thread can't be
    similarly converted until the core kthread implementation allows
    threads to call do_exit().

    The advantage of this change is that we can now be certain the control
    thread has terminated before storage_disconnect() returns. This will
    simplify the locking requirements when autosuspend support is added.

    Signed-off-by: Alan Stern
    Signed-off-by: Matthew Dharm
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

09 May, 2007

1 commit


13 Jul, 2006

1 commit


27 Jun, 2006

1 commit

  • Usually we don't care much about 'gcc -W' warnings, but some of us do build
    kernels that way to look for problems, and then the fewer warnings we have
    to wade through the better. Especially when they are very easy and
    non-intrusive to clean up. Which is the case for the following warnings
    spewed by drivers/usb/storage/usb.h :

    drivers/usb/storage/usb.h:163: warning: `inline' is not at beginning of
    +declaration
    drivers/usb/storage/usb.h:166: warning: `inline' is not at beginning of
    +declaration

    There's also some precedence for cleaning up these warnings. I've had
    a few patches merged in the past that remove exactly this class of
    warnings.

    Signed-off-by: Jesper Juhl
    Signed-off-by: Adrian Bunk

    Jesper Juhl
     

21 Mar, 2006

1 commit


05 Jan, 2006

2 commits

  • The OneTouch subdriver submits its own interrupt URB for notifications
    about button presses. Consequently it needs to know about suspend and
    resume events, so it can cancel or restart the URB.

    This patch (as593) adds a hook to struct us_data, to be used for
    notifying subdrivers about Power Management events, and it implements
    the hook in the OneTouch driver.

    Signed-off-by: Alan Stern
    Signed-off-by: Nick Sillik
    Signed-off-by: Matthew Dharm
    Signed-off-by: Greg Kroah-Hartman

    Matthew Dharm
     
  • This patch adds a shim driver libusual, which routes devices between
    usb-storage and ub according to the common table, based on unusual_devs.h.
    The help and example syntax is in Kconfig.

    Signed-off-by: Pete Zaitcev
    Signed-off-by: Greg Kroah-Hartman

    Pete Zaitcev
     

29 Oct, 2005

2 commits

  • This patch is originally from Alan Stern (as569). It has been rediffed
    against a current tree.

    This patch converts usb-storage to use the kthread API for creating its
    control and scanning threads. The new code doesn't use kthread_stop
    because the threads need (or will need in the future) to exit
    asynchronously.

    Signed-off-by: Alan Stern
    Signed-off-by: Matthew Dharm
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     
  • This patch is from Alan Stern (as560). It has been rediffed against a
    current tree.

    This patch allocates a separate buffer for usb-storage to use when
    auto-sensing. Up to now we have been using the sense buffer embedded in a
    scsi_cmnd struct, which is dangerous on hosts that (a) don't do
    cache-coherent DMA or (b) have DMA alignment restrictions.

    Signed-off-by: Alan Stern
    Signed-off-by: Matthew Dharm
    Signed-off-by: Greg Kroah-Hartman

    Alan Stern
     

09 Sep, 2005

1 commit

  • This patch started life as as531 from Alan Stern. It has been rediffed
    against the latest tree.

    The SCSI people have deprecated the use of scsi_cmnd.serial_number for
    anything other than printk. Worse than that, the SCSI core doesn't
    always increment the number (when the error handler is running, for
    example). So this patch creates a locally-stored value for use in
    bulk-only tags. The net result is a simplification, since we no longer
    have to save & restore the serial_number value while autosensing.

    Signed-off-by: Alan Stern
    Signed-off-by: Matthew Dharm
    Signed-off-by: Greg Kroah-Hartman

    Matthew Dharm
     

17 Apr, 2005

1 commit

  • Initial git repository build. I'm not bothering with the full history,
    even though we have it. We can create a separate "historical" git
    archive of that later if we want to, and in the meantime it's about
    3.2GB when imported into git - space that would just make the early
    git days unnecessarily complicated, when we don't have a lot of good
    infrastructure for it.

    Let it rip!

    Linus Torvalds