aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/storage')
-rw-r--r--drivers/usb/storage/scsiglue.c3
-rw-r--r--drivers/usb/storage/transport.c17
-rw-r--r--drivers/usb/storage/unusual_devs.h7
-rw-r--r--drivers/usb/storage/usb.c43
-rw-r--r--drivers/usb/storage/usb.h1
5 files changed, 54 insertions, 17 deletions
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index cfa26d56ce60..e5e6df39e737 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -73,7 +73,8 @@
73 73
74static const char* host_info(struct Scsi_Host *host) 74static const char* host_info(struct Scsi_Host *host)
75{ 75{
76 return "SCSI emulation for USB Mass Storage devices"; 76 struct us_data *us = host_to_us(host);
77 return us->scsi_name;
77} 78}
78 79
79static int slave_alloc (struct scsi_device *sdev) 80static int slave_alloc (struct scsi_device *sdev)
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 589f6b4404f0..cc313d16d727 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -666,10 +666,11 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us)
666 * to wait for at least one CHECK_CONDITION to determine 666 * to wait for at least one CHECK_CONDITION to determine
667 * SANE_SENSE support 667 * SANE_SENSE support
668 */ 668 */
669 if ((srb->cmnd[0] == ATA_16 || srb->cmnd[0] == ATA_12) && 669 if (unlikely((srb->cmnd[0] == ATA_16 || srb->cmnd[0] == ATA_12) &&
670 result == USB_STOR_TRANSPORT_GOOD && 670 result == USB_STOR_TRANSPORT_GOOD &&
671 !(us->fflags & US_FL_SANE_SENSE) && 671 !(us->fflags & US_FL_SANE_SENSE) &&
672 !(srb->cmnd[2] & 0x20)) { 672 !(us->fflags & US_FL_BAD_SENSE) &&
673 !(srb->cmnd[2] & 0x20))) {
673 US_DEBUGP("-- SAT supported, increasing auto-sense\n"); 674 US_DEBUGP("-- SAT supported, increasing auto-sense\n");
674 us->fflags |= US_FL_SANE_SENSE; 675 us->fflags |= US_FL_SANE_SENSE;
675 } 676 }
@@ -718,6 +719,12 @@ Retry_Sense:
718 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { 719 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
719 US_DEBUGP("-- auto-sense aborted\n"); 720 US_DEBUGP("-- auto-sense aborted\n");
720 srb->result = DID_ABORT << 16; 721 srb->result = DID_ABORT << 16;
722
723 /* If SANE_SENSE caused this problem, disable it */
724 if (sense_size != US_SENSE_SIZE) {
725 us->fflags &= ~US_FL_SANE_SENSE;
726 us->fflags |= US_FL_BAD_SENSE;
727 }
721 goto Handle_Errors; 728 goto Handle_Errors;
722 } 729 }
723 730
@@ -727,10 +734,11 @@ Retry_Sense:
727 * (small) sense request. This fixes some USB GSM modems 734 * (small) sense request. This fixes some USB GSM modems
728 */ 735 */
729 if (temp_result == USB_STOR_TRANSPORT_FAILED && 736 if (temp_result == USB_STOR_TRANSPORT_FAILED &&
730 (us->fflags & US_FL_SANE_SENSE) && 737 sense_size != US_SENSE_SIZE) {
731 sense_size != US_SENSE_SIZE) {
732 US_DEBUGP("-- auto-sense failure, retry small sense\n"); 738 US_DEBUGP("-- auto-sense failure, retry small sense\n");
733 sense_size = US_SENSE_SIZE; 739 sense_size = US_SENSE_SIZE;
740 us->fflags &= ~US_FL_SANE_SENSE;
741 us->fflags |= US_FL_BAD_SENSE;
734 goto Retry_Sense; 742 goto Retry_Sense;
735 } 743 }
736 744
@@ -754,6 +762,7 @@ Retry_Sense:
754 */ 762 */
755 if (srb->sense_buffer[7] > (US_SENSE_SIZE - 8) && 763 if (srb->sense_buffer[7] > (US_SENSE_SIZE - 8) &&
756 !(us->fflags & US_FL_SANE_SENSE) && 764 !(us->fflags & US_FL_SANE_SENSE) &&
765 !(us->fflags & US_FL_BAD_SENSE) &&
757 (srb->sense_buffer[0] & 0x7C) == 0x70) { 766 (srb->sense_buffer[0] & 0x7C) == 0x70) {
758 US_DEBUGP("-- SANE_SENSE support enabled\n"); 767 US_DEBUGP("-- SANE_SENSE support enabled\n");
759 us->fflags |= US_FL_SANE_SENSE; 768 us->fflags |= US_FL_SANE_SENSE;
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index d4f034ebaa8a..64a0a2c27e12 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -818,6 +818,13 @@ UNUSUAL_DEV( 0x066f, 0x8000, 0x0001, 0x0001,
818 US_SC_DEVICE, US_PR_DEVICE, NULL, 818 US_SC_DEVICE, US_PR_DEVICE, NULL,
819 US_FL_FIX_CAPACITY ), 819 US_FL_FIX_CAPACITY ),
820 820
821/* Reported by Daniel Kukula <daniel.kuku@gmail.com> */
822UNUSUAL_DEV( 0x067b, 0x1063, 0x0100, 0x0100,
823 "Prolific Technology, Inc.",
824 "Prolific Storage Gadget",
825 US_SC_DEVICE, US_PR_DEVICE, NULL,
826 US_FL_BAD_SENSE ),
827
821/* Reported by Rogerio Brito <rbrito@ime.usp.br> */ 828/* Reported by Rogerio Brito <rbrito@ime.usp.br> */
822UNUSUAL_DEV( 0x067b, 0x2317, 0x0001, 0x001, 829UNUSUAL_DEV( 0x067b, 0x2317, 0x0001, 0x001,
823 "Prolific Technology, Inc.", 830 "Prolific Technology, Inc.",
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 8060b85fe1a3..5a53d4f0dd11 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -45,6 +45,10 @@
45 * 675 Mass Ave, Cambridge, MA 02139, USA. 45 * 675 Mass Ave, Cambridge, MA 02139, USA.
46 */ 46 */
47 47
48#ifdef CONFIG_USB_STORAGE_DEBUG
49#define DEBUG
50#endif
51
48#include <linux/sched.h> 52#include <linux/sched.h>
49#include <linux/errno.h> 53#include <linux/errno.h>
50#include <linux/freezer.h> 54#include <linux/freezer.h>
@@ -228,6 +232,7 @@ void fill_inquiry_response(struct us_data *us, unsigned char *data,
228 if (data_len<36) // You lose. 232 if (data_len<36) // You lose.
229 return; 233 return;
230 234
235 memset(data+8, ' ', 28);
231 if(data[0]&0x20) { /* USB device currently not connected. Return 236 if(data[0]&0x20) { /* USB device currently not connected. Return
232 peripheral qualifier 001b ("...however, the 237 peripheral qualifier 001b ("...however, the
233 physical device is not currently connected 238 physical device is not currently connected
@@ -237,15 +242,15 @@ void fill_inquiry_response(struct us_data *us, unsigned char *data,
237 device, it may return zeros or ASCII spaces 242 device, it may return zeros or ASCII spaces
238 (20h) in those fields until the data is 243 (20h) in those fields until the data is
239 available from the device."). */ 244 available from the device."). */
240 memset(data+8,0,28);
241 } else { 245 } else {
242 u16 bcdDevice = le16_to_cpu(us->pusb_dev->descriptor.bcdDevice); 246 u16 bcdDevice = le16_to_cpu(us->pusb_dev->descriptor.bcdDevice);
243 memcpy(data+8, us->unusual_dev->vendorName, 247 int n;
244 strlen(us->unusual_dev->vendorName) > 8 ? 8 : 248
245 strlen(us->unusual_dev->vendorName)); 249 n = strlen(us->unusual_dev->vendorName);
246 memcpy(data+16, us->unusual_dev->productName, 250 memcpy(data+8, us->unusual_dev->vendorName, min(8, n));
247 strlen(us->unusual_dev->productName) > 16 ? 16 : 251 n = strlen(us->unusual_dev->productName);
248 strlen(us->unusual_dev->productName)); 252 memcpy(data+16, us->unusual_dev->productName, min(16, n));
253
249 data[32] = 0x30 + ((bcdDevice>>12) & 0x0F); 254 data[32] = 0x30 + ((bcdDevice>>12) & 0x0F);
250 data[33] = 0x30 + ((bcdDevice>>8) & 0x0F); 255 data[33] = 0x30 + ((bcdDevice>>8) & 0x0F);
251 data[34] = 0x30 + ((bcdDevice>>4) & 0x0F); 256 data[34] = 0x30 + ((bcdDevice>>4) & 0x0F);
@@ -459,6 +464,9 @@ static void adjust_quirks(struct us_data *us)
459 case 'a': 464 case 'a':
460 f |= US_FL_SANE_SENSE; 465 f |= US_FL_SANE_SENSE;
461 break; 466 break;
467 case 'b':
468 f |= US_FL_BAD_SENSE;
469 break;
462 case 'c': 470 case 'c':
463 f |= US_FL_FIX_CAPACITY; 471 f |= US_FL_FIX_CAPACITY;
464 break; 472 break;
@@ -808,14 +816,13 @@ static int usb_stor_scan_thread(void * __us)
808{ 816{
809 struct us_data *us = (struct us_data *)__us; 817 struct us_data *us = (struct us_data *)__us;
810 818
811 printk(KERN_DEBUG 819 dev_dbg(&us->pusb_intf->dev, "device found\n");
812 "usb-storage: device found at %d\n", us->pusb_dev->devnum);
813 820
814 set_freezable(); 821 set_freezable();
815 /* Wait for the timeout to expire or for a disconnect */ 822 /* Wait for the timeout to expire or for a disconnect */
816 if (delay_use > 0) { 823 if (delay_use > 0) {
817 printk(KERN_DEBUG "usb-storage: waiting for device " 824 dev_dbg(&us->pusb_intf->dev, "waiting for device to settle "
818 "to settle before scanning\n"); 825 "before scanning\n");
819 wait_event_freezable_timeout(us->delay_wait, 826 wait_event_freezable_timeout(us->delay_wait,
820 test_bit(US_FLIDX_DONT_SCAN, &us->dflags), 827 test_bit(US_FLIDX_DONT_SCAN, &us->dflags),
821 delay_use * HZ); 828 delay_use * HZ);
@@ -832,7 +839,7 @@ static int usb_stor_scan_thread(void * __us)
832 mutex_unlock(&us->dev_mutex); 839 mutex_unlock(&us->dev_mutex);
833 } 840 }
834 scsi_scan_host(us_to_host(us)); 841 scsi_scan_host(us_to_host(us));
835 printk(KERN_DEBUG "usb-storage: device scan complete\n"); 842 dev_dbg(&us->pusb_intf->dev, "scan complete\n");
836 843
837 /* Should we unbind if no devices were detected? */ 844 /* Should we unbind if no devices were detected? */
838 } 845 }
@@ -840,6 +847,15 @@ static int usb_stor_scan_thread(void * __us)
840 complete_and_exit(&us->scanning_done, 0); 847 complete_and_exit(&us->scanning_done, 0);
841} 848}
842 849
850static unsigned int usb_stor_sg_tablesize(struct usb_interface *intf)
851{
852 struct usb_device *usb_dev = interface_to_usbdev(intf);
853
854 if (usb_dev->bus->sg_tablesize) {
855 return usb_dev->bus->sg_tablesize;
856 }
857 return SG_ALL;
858}
843 859
844/* First part of general USB mass-storage probing */ 860/* First part of general USB mass-storage probing */
845int usb_stor_probe1(struct us_data **pus, 861int usb_stor_probe1(struct us_data **pus,
@@ -868,6 +884,7 @@ int usb_stor_probe1(struct us_data **pus,
868 * Allow 16-byte CDBs and thus > 2TB 884 * Allow 16-byte CDBs and thus > 2TB
869 */ 885 */
870 host->max_cmd_len = 16; 886 host->max_cmd_len = 16;
887 host->sg_tablesize = usb_stor_sg_tablesize(intf);
871 *pus = us = host_to_us(host); 888 *pus = us = host_to_us(host);
872 memset(us, 0, sizeof(struct us_data)); 889 memset(us, 0, sizeof(struct us_data));
873 mutex_init(&(us->dev_mutex)); 890 mutex_init(&(us->dev_mutex));
@@ -929,6 +946,8 @@ int usb_stor_probe2(struct us_data *us)
929 result = usb_stor_acquire_resources(us); 946 result = usb_stor_acquire_resources(us);
930 if (result) 947 if (result)
931 goto BadDevice; 948 goto BadDevice;
949 snprintf(us->scsi_name, sizeof(us->scsi_name), "usb-storage %s",
950 dev_name(&us->pusb_intf->dev));
932 result = scsi_add_host(us_to_host(us), &us->pusb_intf->dev); 951 result = scsi_add_host(us_to_host(us), &us->pusb_intf->dev);
933 if (result) { 952 if (result) {
934 printk(KERN_WARNING USB_STORAGE 953 printk(KERN_WARNING USB_STORAGE
diff --git a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
index 2609efb2bd7e..69717134231b 100644
--- a/drivers/usb/storage/usb.h
+++ b/drivers/usb/storage/usb.h
@@ -132,6 +132,7 @@ struct us_data {
132 /* SCSI interfaces */ 132 /* SCSI interfaces */
133 struct scsi_cmnd *srb; /* current srb */ 133 struct scsi_cmnd *srb; /* current srb */
134 unsigned int tag; /* current dCBWTag */ 134 unsigned int tag; /* current dCBWTag */
135 char scsi_name[32]; /* scsi_host name */
135 136
136 /* control and bulk communications data */ 137 /* control and bulk communications data */
137 struct urb *current_urb; /* USB requests */ 138 struct urb *current_urb; /* USB requests */