Skip to content

Commit

Permalink
usb-storage: enable multi-LUN scanning when needed
Browse files Browse the repository at this point in the history
People sometimes create their own custom-configured kernels and forget
to enable CONFIG_SCSI_MULTI_LUN.  This causes problems when they plug
in a USB storage device (such as a card reader) with more than one
LUN.

Fortunately, we can tell fairly easily when a storage device claims to
have more than one LUN.  When that happens, this patch asks the SCSI
layer to probe all the LUNs automatically, regardless of the config
setting.

The patch also updates the Kconfig help text for usb-storage,
explaining that CONFIG_SCSI_MULTI_LUN may be necessary.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Reported-by: Thomas Raschbacher <lordvan@lordvan.com>
CC: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
CC: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: stable <stable@vger.kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Alan Stern authored and Greg Kroah-Hartman committed Feb 4, 2014
1 parent 2240c36 commit 823d12c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/usb/storage/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ config USB_STORAGE

This option depends on 'SCSI' support being enabled, but you
probably also need 'SCSI device support: SCSI disk support'
(BLK_DEV_SD) for most USB storage devices.
(BLK_DEV_SD) for most USB storage devices. Some devices also
will require 'Probe all LUNs on each SCSI device'
(SCSI_MULTI_LUN).

To compile this driver as a module, choose M here: the
module will be called usb-storage.
Expand Down
6 changes: 6 additions & 0 deletions drivers/usb/storage/scsiglue.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ static const char* host_info(struct Scsi_Host *host)

static int slave_alloc (struct scsi_device *sdev)
{
struct us_data *us = host_to_us(sdev->host);

/*
* Set the INQUIRY transfer length to 36. We don't use any of
* the extra data and many devices choke if asked for more or
Expand All @@ -102,6 +104,10 @@ static int slave_alloc (struct scsi_device *sdev)
*/
blk_queue_update_dma_alignment(sdev->request_queue, (512 - 1));

/* Tell the SCSI layer if we know there is more than one LUN */
if (us->protocol == USB_PR_BULK && us->max_lun > 0)
sdev->sdev_bflags |= BLIST_FORCELUN;

return 0;
}

Expand Down

0 comments on commit 823d12c

Please sign in to comment.