aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2005-10-23 22:38:56 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2005-10-28 19:47:50 -0400
commitb876aef7f890d8c59a45b78858a36cf60fddf522 (patch)
treec8211d093fc0ab4ec04d3adaf8388253aa73d0bf
parent423e489d704d05c6e8c2927fb1854db85914912a (diff)
[PATCH] PATCH: usb-storage: move GetMaxLUN later in time
This patch is originally from Alan Stern (as557). It has been re-diffed against a current tree, and I also corrected a minor merging error. Some time ago we introduced a delay before device scanning, because many devices do not like to receive SCSI commands right after enumeration. Now it turns out there's a device that doesn't like to receive Get-Max-LUN right after enumeration either. Accordingly this patch delays the Get-Max-LUN request until the beginning of the scanning procedure. This fixes Bugzilla entry #5010. Three things are worth noting. First, I removed the locking code from usb_stor_acquire_resources. It's not needed, because the locking is to protect against disconnect events and acquire_resources is only called during probe (so the disconnect routine can't be called). Second, I initialized to 0 the buffer used for the Get-Max-LUN response. It's not really necessary, but it will prevent random values from showing up in the debugging log when the request fails. Third, I added a test against the SINGLE_LUN flag. This will allow us to use the flag to indicate Bulk-only devices that can't handle Get-Max-LUN. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/usb/storage/transport.c1
-rw-r--r--drivers/usb/storage/usb.c30
2 files changed, 14 insertions, 17 deletions
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index c1ba5301ebfc..e89e945fc4a7 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -923,6 +923,7 @@ int usb_stor_Bulk_max_lun(struct us_data *us)
923 int result; 923 int result;
924 924
925 /* issue the command */ 925 /* issue the command */
926 us->iobuf[0] = 0;
926 result = usb_stor_control_msg(us, us->recv_ctrl_pipe, 927 result = usb_stor_control_msg(us, us->recv_ctrl_pipe,
927 US_BULK_GET_MAX_LUN, 928 US_BULK_GET_MAX_LUN,
928 USB_DIR_IN | USB_TYPE_CLASS | 929 USB_DIR_IN | USB_TYPE_CLASS |
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 5164900e40c1..92ee079d9172 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -747,25 +747,13 @@ static int usb_stor_acquire_resources(struct us_data *us)
747 return -ENOMEM; 747 return -ENOMEM;
748 } 748 }
749 749
750 /* Lock the device while we carry out the next two operations */
751 down(&us->dev_semaphore);
752
753 /* For bulk-only devices, determine the max LUN value */
754 if (us->protocol == US_PR_BULK) {
755 p = usb_stor_Bulk_max_lun(us);
756 if (p < 0) {
757 up(&us->dev_semaphore);
758 return p;
759 }
760 us->max_lun = p;
761 }
762
763 /* Just before we start our control thread, initialize 750 /* Just before we start our control thread, initialize
764 * the device if it needs initialization */ 751 * the device if it needs initialization */
765 if (us->unusual_dev->initFunction) 752 if (us->unusual_dev->initFunction) {
766 us->unusual_dev->initFunction(us); 753 p = us->unusual_dev->initFunction(us);
767 754 if (p)
768 up(&us->dev_semaphore); 755 return p;
756 }
769 757
770 /* Start up our control thread */ 758 /* Start up our control thread */
771 p = kernel_thread(usb_stor_control_thread, us, CLONE_VM); 759 p = kernel_thread(usb_stor_control_thread, us, CLONE_VM);
@@ -904,6 +892,14 @@ retry:
904 892
905 /* If the device is still connected, perform the scanning */ 893 /* If the device is still connected, perform the scanning */
906 if (!test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { 894 if (!test_bit(US_FLIDX_DISCONNECTING, &us->flags)) {
895
896 /* For bulk-only devices, determine the max LUN value */
897 if (us->protocol == US_PR_BULK &&
898 !(us->flags & US_FL_SINGLE_LUN)) {
899 down(&us->dev_semaphore);
900 us->max_lun = usb_stor_Bulk_max_lun(us);
901 up(&us->dev_semaphore);
902 }
907 scsi_scan_host(us_to_host(us)); 903 scsi_scan_host(us_to_host(us));
908 printk(KERN_DEBUG "usb-storage: device scan complete\n"); 904 printk(KERN_DEBUG "usb-storage: device scan complete\n");
909 905