diff options
| -rw-r--r-- | drivers/usb/storage/transport.c | 1 | ||||
| -rw-r--r-- | drivers/usb/storage/usb.c | 30 |
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 | ||
