aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/storage')
-rw-r--r--drivers/usb/storage/alauda.c1
-rw-r--r--drivers/usb/storage/karma.c1
-rw-r--r--drivers/usb/storage/onetouch.c2
-rw-r--r--drivers/usb/storage/option_ms.c1
-rw-r--r--drivers/usb/storage/scsiglue.c20
-rw-r--r--drivers/usb/storage/shuttle_usbat.c15
-rw-r--r--drivers/usb/storage/sierra_ms.c1
-rw-r--r--drivers/usb/storage/transport.c25
-rw-r--r--drivers/usb/storage/unusual_devs.h127
-rw-r--r--drivers/usb/storage/usb.c48
-rw-r--r--drivers/usb/storage/usb.h1
11 files changed, 180 insertions, 62 deletions
diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c
index 67edc65acb8e..42d0eaed4a01 100644
--- a/drivers/usb/storage/alauda.c
+++ b/drivers/usb/storage/alauda.c
@@ -32,6 +32,7 @@
32 */ 32 */
33 33
34#include <linux/module.h> 34#include <linux/module.h>
35#include <linux/slab.h>
35 36
36#include <scsi/scsi.h> 37#include <scsi/scsi.h>
37#include <scsi/scsi_cmnd.h> 38#include <scsi/scsi_cmnd.h>
diff --git a/drivers/usb/storage/karma.c b/drivers/usb/storage/karma.c
index 7953d93a7739..ba1b78906880 100644
--- a/drivers/usb/storage/karma.c
+++ b/drivers/usb/storage/karma.c
@@ -19,6 +19,7 @@
19 */ 19 */
20 20
21#include <linux/module.h> 21#include <linux/module.h>
22#include <linux/slab.h>
22 23
23#include <scsi/scsi.h> 24#include <scsi/scsi.h>
24#include <scsi/scsi_cmnd.h> 25#include <scsi/scsi_cmnd.h>
diff --git a/drivers/usb/storage/onetouch.c b/drivers/usb/storage/onetouch.c
index 80e65f29921c..198bb3ed95b2 100644
--- a/drivers/usb/storage/onetouch.c
+++ b/drivers/usb/storage/onetouch.c
@@ -202,7 +202,7 @@ static int onetouch_connect_input(struct us_data *ss)
202 goto fail1; 202 goto fail1;
203 203
204 onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN, 204 onetouch->data = usb_buffer_alloc(udev, ONETOUCH_PKT_LEN,
205 GFP_ATOMIC, &onetouch->data_dma); 205 GFP_KERNEL, &onetouch->data_dma);
206 if (!onetouch->data) 206 if (!onetouch->data)
207 goto fail1; 207 goto fail1;
208 208
diff --git a/drivers/usb/storage/option_ms.c b/drivers/usb/storage/option_ms.c
index 773a5cd38c5a..89460181d122 100644
--- a/drivers/usb/storage/option_ms.c
+++ b/drivers/usb/storage/option_ms.c
@@ -21,6 +21,7 @@
21 */ 21 */
22 22
23#include <linux/usb.h> 23#include <linux/usb.h>
24#include <linux/slab.h>
24 25
25#include "usb.h" 26#include "usb.h"
26#include "transport.h" 27#include "transport.h"
diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
index cfa26d56ce60..d8d98cfecada 100644
--- a/drivers/usb/storage/scsiglue.c
+++ b/drivers/usb/storage/scsiglue.c
@@ -43,7 +43,6 @@
43 * 675 Mass Ave, Cambridge, MA 02139, USA. 43 * 675 Mass Ave, Cambridge, MA 02139, USA.
44 */ 44 */
45 45
46#include <linux/slab.h>
47#include <linux/module.h> 46#include <linux/module.h>
48#include <linux/mutex.h> 47#include <linux/mutex.h>
49 48
@@ -73,7 +72,8 @@
73 72
74static const char* host_info(struct Scsi_Host *host) 73static const char* host_info(struct Scsi_Host *host)
75{ 74{
76 return "SCSI emulation for USB Mass Storage devices"; 75 struct us_data *us = host_to_us(host);
76 return us->scsi_name;
77} 77}
78 78
79static int slave_alloc (struct scsi_device *sdev) 79static int slave_alloc (struct scsi_device *sdev)
@@ -132,15 +132,15 @@ static int slave_configure(struct scsi_device *sdev)
132 132
133 if (us->fflags & US_FL_MAX_SECTORS_MIN) 133 if (us->fflags & US_FL_MAX_SECTORS_MIN)
134 max_sectors = PAGE_CACHE_SIZE >> 9; 134 max_sectors = PAGE_CACHE_SIZE >> 9;
135 if (queue_max_sectors(sdev->request_queue) > max_sectors) 135 if (queue_max_hw_sectors(sdev->request_queue) > max_sectors)
136 blk_queue_max_sectors(sdev->request_queue, 136 blk_queue_max_hw_sectors(sdev->request_queue,
137 max_sectors); 137 max_sectors);
138 } else if (sdev->type == TYPE_TAPE) { 138 } else if (sdev->type == TYPE_TAPE) {
139 /* Tapes need much higher max_sector limits, so just 139 /* Tapes need much higher max_sector limits, so just
140 * raise it to the maximum possible (4 GB / 512) and 140 * raise it to the maximum possible (4 GB / 512) and
141 * let the queue segment size sort out the real limit. 141 * let the queue segment size sort out the real limit.
142 */ 142 */
143 blk_queue_max_sectors(sdev->request_queue, 0x7FFFFF); 143 blk_queue_max_hw_sectors(sdev->request_queue, 0x7FFFFF);
144 } 144 }
145 145
146 /* Some USB host controllers can't do DMA; they have to use PIO. 146 /* Some USB host controllers can't do DMA; they have to use PIO.
@@ -483,7 +483,7 @@ static ssize_t show_max_sectors(struct device *dev, struct device_attribute *att
483{ 483{
484 struct scsi_device *sdev = to_scsi_device(dev); 484 struct scsi_device *sdev = to_scsi_device(dev);
485 485
486 return sprintf(buf, "%u\n", queue_max_sectors(sdev->request_queue)); 486 return sprintf(buf, "%u\n", queue_max_hw_sectors(sdev->request_queue));
487} 487}
488 488
489/* Input routine for the sysfs max_sectors file */ 489/* Input routine for the sysfs max_sectors file */
@@ -493,9 +493,9 @@ static ssize_t store_max_sectors(struct device *dev, struct device_attribute *at
493 struct scsi_device *sdev = to_scsi_device(dev); 493 struct scsi_device *sdev = to_scsi_device(dev);
494 unsigned short ms; 494 unsigned short ms;
495 495
496 if (sscanf(buf, "%hu", &ms) > 0 && ms <= SCSI_DEFAULT_MAX_SECTORS) { 496 if (sscanf(buf, "%hu", &ms) > 0) {
497 blk_queue_max_sectors(sdev->request_queue, ms); 497 blk_queue_max_hw_sectors(sdev->request_queue, ms);
498 return strlen(buf); 498 return count;
499 } 499 }
500 return -EINVAL; 500 return -EINVAL;
501} 501}
@@ -538,7 +538,7 @@ struct scsi_host_template usb_stor_host_template = {
538 .slave_configure = slave_configure, 538 .slave_configure = slave_configure,
539 539
540 /* lots of sg segments can be handled */ 540 /* lots of sg segments can be handled */
541 .sg_tablesize = SG_ALL, 541 .sg_tablesize = SCSI_MAX_SG_CHAIN_SEGMENTS,
542 542
543 /* limit the total size of a transfer to 120 KB */ 543 /* limit the total size of a transfer to 120 KB */
544 .max_sectors = 240, 544 .max_sectors = 240,
diff --git a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c
index b62a28814ebe..bd3f415893d8 100644
--- a/drivers/usb/storage/shuttle_usbat.c
+++ b/drivers/usb/storage/shuttle_usbat.c
@@ -1628,10 +1628,10 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
1628 return USB_STOR_TRANSPORT_ERROR; 1628 return USB_STOR_TRANSPORT_ERROR;
1629 } 1629 }
1630 1630
1631 if ( (result = usbat_multiple_write(us, 1631 result = usbat_multiple_write(us, registers, data, 7);
1632 registers, data, 7)) != USB_STOR_TRANSPORT_GOOD) { 1632
1633 if (result != USB_STOR_TRANSPORT_GOOD)
1633 return result; 1634 return result;
1634 }
1635 1635
1636 /* 1636 /*
1637 * Write the 12-byte command header. 1637 * Write the 12-byte command header.
@@ -1643,12 +1643,11 @@ static int usbat_hp8200e_transport(struct scsi_cmnd *srb, struct us_data *us)
1643 * AT SPEED 4 IS UNRELIABLE!!! 1643 * AT SPEED 4 IS UNRELIABLE!!!
1644 */ 1644 */
1645 1645
1646 if ((result = usbat_write_block(us, 1646 result = usbat_write_block(us, USBAT_ATA, srb->cmnd, 12,
1647 USBAT_ATA, srb->cmnd, 12, 1647 srb->cmnd[0] == GPCMD_BLANK ? 75 : 10, 0);
1648 (srb->cmnd[0]==GPCMD_BLANK ? 75 : 10), 0) != 1648
1649 USB_STOR_TRANSPORT_GOOD)) { 1649 if (result != USB_STOR_TRANSPORT_GOOD)
1650 return result; 1650 return result;
1651 }
1652 1651
1653 /* If there is response data to be read in then do it here. */ 1652 /* If there is response data to be read in then do it here. */
1654 1653
diff --git a/drivers/usb/storage/sierra_ms.c b/drivers/usb/storage/sierra_ms.c
index 4395c4100ec2..57fc2f532cab 100644
--- a/drivers/usb/storage/sierra_ms.c
+++ b/drivers/usb/storage/sierra_ms.c
@@ -3,6 +3,7 @@
3#include <scsi/scsi_cmnd.h> 3#include <scsi/scsi_cmnd.h>
4#include <scsi/scsi_device.h> 4#include <scsi/scsi_device.h>
5#include <linux/usb.h> 5#include <linux/usb.h>
6#include <linux/slab.h>
6 7
7#include "usb.h" 8#include "usb.h"
8#include "transport.h" 9#include "transport.h"
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 589f6b4404f0..f253edec3bb8 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -44,8 +44,10 @@
44 */ 44 */
45 45
46#include <linux/sched.h> 46#include <linux/sched.h>
47#include <linux/gfp.h>
47#include <linux/errno.h> 48#include <linux/errno.h>
48#include <linux/slab.h> 49
50#include <linux/usb/quirks.h>
49 51
50#include <scsi/scsi.h> 52#include <scsi/scsi.h>
51#include <scsi/scsi_eh.h> 53#include <scsi/scsi_eh.h>
@@ -666,10 +668,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 668 * to wait for at least one CHECK_CONDITION to determine
667 * SANE_SENSE support 669 * SANE_SENSE support
668 */ 670 */
669 if ((srb->cmnd[0] == ATA_16 || srb->cmnd[0] == ATA_12) && 671 if (unlikely((srb->cmnd[0] == ATA_16 || srb->cmnd[0] == ATA_12) &&
670 result == USB_STOR_TRANSPORT_GOOD && 672 result == USB_STOR_TRANSPORT_GOOD &&
671 !(us->fflags & US_FL_SANE_SENSE) && 673 !(us->fflags & US_FL_SANE_SENSE) &&
672 !(srb->cmnd[2] & 0x20)) { 674 !(us->fflags & US_FL_BAD_SENSE) &&
675 !(srb->cmnd[2] & 0x20))) {
673 US_DEBUGP("-- SAT supported, increasing auto-sense\n"); 676 US_DEBUGP("-- SAT supported, increasing auto-sense\n");
674 us->fflags |= US_FL_SANE_SENSE; 677 us->fflags |= US_FL_SANE_SENSE;
675 } 678 }
@@ -718,6 +721,12 @@ Retry_Sense:
718 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) { 721 if (test_bit(US_FLIDX_TIMED_OUT, &us->dflags)) {
719 US_DEBUGP("-- auto-sense aborted\n"); 722 US_DEBUGP("-- auto-sense aborted\n");
720 srb->result = DID_ABORT << 16; 723 srb->result = DID_ABORT << 16;
724
725 /* If SANE_SENSE caused this problem, disable it */
726 if (sense_size != US_SENSE_SIZE) {
727 us->fflags &= ~US_FL_SANE_SENSE;
728 us->fflags |= US_FL_BAD_SENSE;
729 }
721 goto Handle_Errors; 730 goto Handle_Errors;
722 } 731 }
723 732
@@ -727,10 +736,11 @@ Retry_Sense:
727 * (small) sense request. This fixes some USB GSM modems 736 * (small) sense request. This fixes some USB GSM modems
728 */ 737 */
729 if (temp_result == USB_STOR_TRANSPORT_FAILED && 738 if (temp_result == USB_STOR_TRANSPORT_FAILED &&
730 (us->fflags & US_FL_SANE_SENSE) && 739 sense_size != US_SENSE_SIZE) {
731 sense_size != US_SENSE_SIZE) {
732 US_DEBUGP("-- auto-sense failure, retry small sense\n"); 740 US_DEBUGP("-- auto-sense failure, retry small sense\n");
733 sense_size = US_SENSE_SIZE; 741 sense_size = US_SENSE_SIZE;
742 us->fflags &= ~US_FL_SANE_SENSE;
743 us->fflags |= US_FL_BAD_SENSE;
734 goto Retry_Sense; 744 goto Retry_Sense;
735 } 745 }
736 746
@@ -754,6 +764,7 @@ Retry_Sense:
754 */ 764 */
755 if (srb->sense_buffer[7] > (US_SENSE_SIZE - 8) && 765 if (srb->sense_buffer[7] > (US_SENSE_SIZE - 8) &&
756 !(us->fflags & US_FL_SANE_SENSE) && 766 !(us->fflags & US_FL_SANE_SENSE) &&
767 !(us->fflags & US_FL_BAD_SENSE) &&
757 (srb->sense_buffer[0] & 0x7C) == 0x70) { 768 (srb->sense_buffer[0] & 0x7C) == 0x70) {
758 US_DEBUGP("-- SANE_SENSE support enabled\n"); 769 US_DEBUGP("-- SANE_SENSE support enabled\n");
759 us->fflags |= US_FL_SANE_SENSE; 770 us->fflags |= US_FL_SANE_SENSE;
@@ -1288,6 +1299,10 @@ int usb_stor_port_reset(struct us_data *us)
1288{ 1299{
1289 int result; 1300 int result;
1290 1301
1302 /*for these devices we must use the class specific method */
1303 if (us->pusb_dev->quirks & USB_QUIRK_RESET_MORPHS)
1304 return -EPERM;
1305
1291 result = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf); 1306 result = usb_lock_device_for_reset(us->pusb_dev, us->pusb_intf);
1292 if (result < 0) 1307 if (result < 0)
1293 US_DEBUGP("unable to lock device for reset: %d\n", result); 1308 US_DEBUGP("unable to lock device for reset: %d\n", result);
diff --git a/drivers/usb/storage/unusual_devs.h b/drivers/usb/storage/unusual_devs.h
index d4f034ebaa8a..ccf1dbbb87ef 100644
--- a/drivers/usb/storage/unusual_devs.h
+++ b/drivers/usb/storage/unusual_devs.h
@@ -374,6 +374,15 @@ UNUSUAL_DEV( 0x04ce, 0x0002, 0x0074, 0x0074,
374 US_SC_DEVICE, US_PR_DEVICE, NULL, 374 US_SC_DEVICE, US_PR_DEVICE, NULL,
375 US_FL_FIX_INQUIRY), 375 US_FL_FIX_INQUIRY),
376 376
377/* Reported by Ondrej Zary <linux@rainbow-software.org>
378 * The device reports one sector more and breaks when that sector is accessed
379 */
380UNUSUAL_DEV( 0x04ce, 0x0002, 0x026c, 0x026c,
381 "ScanLogic",
382 "SL11R-IDE",
383 US_SC_DEVICE, US_PR_DEVICE, NULL,
384 US_FL_FIX_CAPACITY),
385
377/* Reported by Kriston Fincher <kriston@airmail.net> 386/* Reported by Kriston Fincher <kriston@airmail.net>
378 * Patch submitted by Sean Millichamp <sean@bruenor.org> 387 * Patch submitted by Sean Millichamp <sean@bruenor.org>
379 * This is to support the Panasonic PalmCam PV-SD4090 388 * This is to support the Panasonic PalmCam PV-SD4090
@@ -818,6 +827,13 @@ UNUSUAL_DEV( 0x066f, 0x8000, 0x0001, 0x0001,
818 US_SC_DEVICE, US_PR_DEVICE, NULL, 827 US_SC_DEVICE, US_PR_DEVICE, NULL,
819 US_FL_FIX_CAPACITY ), 828 US_FL_FIX_CAPACITY ),
820 829
830/* Reported by Daniel Kukula <daniel.kuku@gmail.com> */
831UNUSUAL_DEV( 0x067b, 0x1063, 0x0100, 0x0100,
832 "Prolific Technology, Inc.",
833 "Prolific Storage Gadget",
834 US_SC_DEVICE, US_PR_DEVICE, NULL,
835 US_FL_BAD_SENSE ),
836
821/* Reported by Rogerio Brito <rbrito@ime.usp.br> */ 837/* Reported by Rogerio Brito <rbrito@ime.usp.br> */
822UNUSUAL_DEV( 0x067b, 0x2317, 0x0001, 0x001, 838UNUSUAL_DEV( 0x067b, 0x2317, 0x0001, 0x001,
823 "Prolific Technology, Inc.", 839 "Prolific Technology, Inc.",
@@ -934,7 +950,7 @@ UNUSUAL_DEV( 0x07ab, 0xfccd, 0x0000, 0x9999,
934UNUSUAL_DEV( 0x07af, 0x0004, 0x0100, 0x0133, 950UNUSUAL_DEV( 0x07af, 0x0004, 0x0100, 0x0133,
935 "Microtech", 951 "Microtech",
936 "USB-SCSI-DB25", 952 "USB-SCSI-DB25",
937 US_SC_SCSI, US_PR_BULK, usb_stor_euscsi_init, 953 US_SC_DEVICE, US_PR_DEVICE, usb_stor_euscsi_init,
938 US_FL_SCM_MULT_TARG ), 954 US_FL_SCM_MULT_TARG ),
939 955
940UNUSUAL_DEV( 0x07af, 0x0005, 0x0100, 0x0100, 956UNUSUAL_DEV( 0x07af, 0x0005, 0x0100, 0x0100,
@@ -1140,8 +1156,8 @@ UNUSUAL_DEV( 0x0af0, 0x7401, 0x0000, 0x0000,
1140 0 ), 1156 0 ),
1141 1157
1142/* Reported by Jan Dumon <j.dumon@option.com> 1158/* Reported by Jan Dumon <j.dumon@option.com>
1143 * This device (wrongly) has a vendor-specific device descriptor. 1159 * These devices (wrongly) have a vendor-specific device descriptor.
1144 * The entry is needed so usb-storage can bind to it's mass-storage 1160 * These entries are needed so usb-storage can bind to their mass-storage
1145 * interface as an interface driver */ 1161 * interface as an interface driver */
1146UNUSUAL_DEV( 0x0af0, 0x7501, 0x0000, 0x0000, 1162UNUSUAL_DEV( 0x0af0, 0x7501, 0x0000, 0x0000,
1147 "Option", 1163 "Option",
@@ -1149,6 +1165,90 @@ UNUSUAL_DEV( 0x0af0, 0x7501, 0x0000, 0x0000,
1149 US_SC_DEVICE, US_PR_DEVICE, NULL, 1165 US_SC_DEVICE, US_PR_DEVICE, NULL,
1150 0 ), 1166 0 ),
1151 1167
1168UNUSUAL_DEV( 0x0af0, 0x7701, 0x0000, 0x0000,
1169 "Option",
1170 "GI 0451 SD-Card",
1171 US_SC_DEVICE, US_PR_DEVICE, NULL,
1172 0 ),
1173
1174UNUSUAL_DEV( 0x0af0, 0x7706, 0x0000, 0x0000,
1175 "Option",
1176 "GI 0451 SD-Card",
1177 US_SC_DEVICE, US_PR_DEVICE, NULL,
1178 0 ),
1179
1180UNUSUAL_DEV( 0x0af0, 0x7901, 0x0000, 0x0000,
1181 "Option",
1182 "GI 0452 SD-Card",
1183 US_SC_DEVICE, US_PR_DEVICE, NULL,
1184 0 ),
1185
1186UNUSUAL_DEV( 0x0af0, 0x7A01, 0x0000, 0x0000,
1187 "Option",
1188 "GI 0461 SD-Card",
1189 US_SC_DEVICE, US_PR_DEVICE, NULL,
1190 0 ),
1191
1192UNUSUAL_DEV( 0x0af0, 0x7A05, 0x0000, 0x0000,
1193 "Option",
1194 "GI 0461 SD-Card",
1195 US_SC_DEVICE, US_PR_DEVICE, NULL,
1196 0 ),
1197
1198UNUSUAL_DEV( 0x0af0, 0x8300, 0x0000, 0x0000,
1199 "Option",
1200 "GI 033x SD-Card",
1201 US_SC_DEVICE, US_PR_DEVICE, NULL,
1202 0 ),
1203
1204UNUSUAL_DEV( 0x0af0, 0x8302, 0x0000, 0x0000,
1205 "Option",
1206 "GI 033x SD-Card",
1207 US_SC_DEVICE, US_PR_DEVICE, NULL,
1208 0 ),
1209
1210UNUSUAL_DEV( 0x0af0, 0x8304, 0x0000, 0x0000,
1211 "Option",
1212 "GI 033x SD-Card",
1213 US_SC_DEVICE, US_PR_DEVICE, NULL,
1214 0 ),
1215
1216UNUSUAL_DEV( 0x0af0, 0xc100, 0x0000, 0x0000,
1217 "Option",
1218 "GI 070x SD-Card",
1219 US_SC_DEVICE, US_PR_DEVICE, NULL,
1220 0 ),
1221
1222UNUSUAL_DEV( 0x0af0, 0xd057, 0x0000, 0x0000,
1223 "Option",
1224 "GI 1505 SD-Card",
1225 US_SC_DEVICE, US_PR_DEVICE, NULL,
1226 0 ),
1227
1228UNUSUAL_DEV( 0x0af0, 0xd058, 0x0000, 0x0000,
1229 "Option",
1230 "GI 1509 SD-Card",
1231 US_SC_DEVICE, US_PR_DEVICE, NULL,
1232 0 ),
1233
1234UNUSUAL_DEV( 0x0af0, 0xd157, 0x0000, 0x0000,
1235 "Option",
1236 "GI 1515 SD-Card",
1237 US_SC_DEVICE, US_PR_DEVICE, NULL,
1238 0 ),
1239
1240UNUSUAL_DEV( 0x0af0, 0xd257, 0x0000, 0x0000,
1241 "Option",
1242 "GI 1215 SD-Card",
1243 US_SC_DEVICE, US_PR_DEVICE, NULL,
1244 0 ),
1245
1246UNUSUAL_DEV( 0x0af0, 0xd357, 0x0000, 0x0000,
1247 "Option",
1248 "GI 1505 SD-Card",
1249 US_SC_DEVICE, US_PR_DEVICE, NULL,
1250 0 ),
1251
1152/* Reported by Ben Efros <ben@pc-doctor.com> */ 1252/* Reported by Ben Efros <ben@pc-doctor.com> */
1153UNUSUAL_DEV( 0x0bc2, 0x3010, 0x0000, 0x0000, 1253UNUSUAL_DEV( 0x0bc2, 0x3010, 0x0000, 0x0000,
1154 "Seagate", 1254 "Seagate",
@@ -1289,20 +1389,6 @@ UNUSUAL_DEV( 0x0f19, 0x0105, 0x0100, 0x0100,
1289 US_SC_DEVICE, US_PR_DEVICE, NULL, 1389 US_SC_DEVICE, US_PR_DEVICE, NULL,
1290 US_FL_IGNORE_RESIDUE ), 1390 US_FL_IGNORE_RESIDUE ),
1291 1391
1292/* Jeremy Katz <katzj@redhat.com>:
1293 * The Blackberry Pearl can run in two modes; a usb-storage only mode
1294 * and a mode that allows access via mass storage and to its database.
1295 * The berry_charge module will set the device to dual mode and thus we
1296 * should ignore its native mode if that module is built
1297 */
1298#ifdef CONFIG_USB_BERRY_CHARGE
1299UNUSUAL_DEV( 0x0fca, 0x0006, 0x0001, 0x0001,
1300 "RIM",
1301 "Blackberry Pearl",
1302 US_SC_DEVICE, US_PR_DEVICE, NULL,
1303 US_FL_IGNORE_DEVICE ),
1304#endif
1305
1306/* Reported by Michael Stattmann <michael@stattmann.com> */ 1392/* Reported by Michael Stattmann <michael@stattmann.com> */
1307UNUSUAL_DEV( 0x0fce, 0xd008, 0x0000, 0x0000, 1393UNUSUAL_DEV( 0x0fce, 0xd008, 0x0000, 0x0000,
1308 "Sony Ericsson", 1394 "Sony Ericsson",
@@ -1800,13 +1886,6 @@ UNUSUAL_DEV( 0x2735, 0x100b, 0x0000, 0x9999,
1800 US_SC_DEVICE, US_PR_DEVICE, NULL, 1886 US_SC_DEVICE, US_PR_DEVICE, NULL,
1801 US_FL_GO_SLOW ), 1887 US_FL_GO_SLOW ),
1802 1888
1803/* Reported by Rohan Hart <rohan.hart17@gmail.com> */
1804UNUSUAL_DEV( 0x2770, 0x915d, 0x0010, 0x0010,
1805 "INTOVA",
1806 "Pixtreme",
1807 US_SC_DEVICE, US_PR_DEVICE, NULL,
1808 US_FL_FIX_CAPACITY ),
1809
1810/* Reported by Frederic Marchal <frederic.marchal@wowcompany.com> 1889/* Reported by Frederic Marchal <frederic.marchal@wowcompany.com>
1811 * Mio Moov 330 1890 * Mio Moov 330
1812 */ 1891 */
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index 8060b85fe1a3..bbeeb92a2131 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>
@@ -74,7 +78,7 @@ MODULE_AUTHOR("Matthew Dharm <mdharm-usb@one-eyed-alien.net>");
74MODULE_DESCRIPTION("USB Mass Storage driver for Linux"); 78MODULE_DESCRIPTION("USB Mass Storage driver for Linux");
75MODULE_LICENSE("GPL"); 79MODULE_LICENSE("GPL");
76 80
77static unsigned int delay_use = 5; 81static unsigned int delay_use = 1;
78module_param(delay_use, uint, S_IRUGO | S_IWUSR); 82module_param(delay_use, uint, S_IRUGO | S_IWUSR);
79MODULE_PARM_DESC(delay_use, "seconds to delay before using a new device"); 83MODULE_PARM_DESC(delay_use, "seconds to delay before using a new device");
80 84
@@ -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);
@@ -429,7 +434,8 @@ static void adjust_quirks(struct us_data *us)
429 u16 vid = le16_to_cpu(us->pusb_dev->descriptor.idVendor); 434 u16 vid = le16_to_cpu(us->pusb_dev->descriptor.idVendor);
430 u16 pid = le16_to_cpu(us->pusb_dev->descriptor.idProduct); 435 u16 pid = le16_to_cpu(us->pusb_dev->descriptor.idProduct);
431 unsigned f = 0; 436 unsigned f = 0;
432 unsigned int mask = (US_FL_SANE_SENSE | US_FL_FIX_CAPACITY | 437 unsigned int mask = (US_FL_SANE_SENSE | US_FL_BAD_SENSE |
438 US_FL_FIX_CAPACITY |
433 US_FL_CAPACITY_HEURISTICS | US_FL_IGNORE_DEVICE | 439 US_FL_CAPACITY_HEURISTICS | US_FL_IGNORE_DEVICE |
434 US_FL_NOT_LOCKABLE | US_FL_MAX_SECTORS_64 | 440 US_FL_NOT_LOCKABLE | US_FL_MAX_SECTORS_64 |
435 US_FL_CAPACITY_OK | US_FL_IGNORE_RESIDUE | 441 US_FL_CAPACITY_OK | US_FL_IGNORE_RESIDUE |
@@ -459,6 +465,9 @@ static void adjust_quirks(struct us_data *us)
459 case 'a': 465 case 'a':
460 f |= US_FL_SANE_SENSE; 466 f |= US_FL_SANE_SENSE;
461 break; 467 break;
468 case 'b':
469 f |= US_FL_BAD_SENSE;
470 break;
462 case 'c': 471 case 'c':
463 f |= US_FL_FIX_CAPACITY; 472 f |= US_FL_FIX_CAPACITY;
464 break; 473 break;
@@ -808,14 +817,13 @@ static int usb_stor_scan_thread(void * __us)
808{ 817{
809 struct us_data *us = (struct us_data *)__us; 818 struct us_data *us = (struct us_data *)__us;
810 819
811 printk(KERN_DEBUG 820 dev_dbg(&us->pusb_intf->dev, "device found\n");
812 "usb-storage: device found at %d\n", us->pusb_dev->devnum);
813 821
814 set_freezable(); 822 set_freezable();
815 /* Wait for the timeout to expire or for a disconnect */ 823 /* Wait for the timeout to expire or for a disconnect */
816 if (delay_use > 0) { 824 if (delay_use > 0) {
817 printk(KERN_DEBUG "usb-storage: waiting for device " 825 dev_dbg(&us->pusb_intf->dev, "waiting for device to settle "
818 "to settle before scanning\n"); 826 "before scanning\n");
819 wait_event_freezable_timeout(us->delay_wait, 827 wait_event_freezable_timeout(us->delay_wait,
820 test_bit(US_FLIDX_DONT_SCAN, &us->dflags), 828 test_bit(US_FLIDX_DONT_SCAN, &us->dflags),
821 delay_use * HZ); 829 delay_use * HZ);
@@ -832,7 +840,7 @@ static int usb_stor_scan_thread(void * __us)
832 mutex_unlock(&us->dev_mutex); 840 mutex_unlock(&us->dev_mutex);
833 } 841 }
834 scsi_scan_host(us_to_host(us)); 842 scsi_scan_host(us_to_host(us));
835 printk(KERN_DEBUG "usb-storage: device scan complete\n"); 843 dev_dbg(&us->pusb_intf->dev, "scan complete\n");
836 844
837 /* Should we unbind if no devices were detected? */ 845 /* Should we unbind if no devices were detected? */
838 } 846 }
@@ -840,6 +848,15 @@ static int usb_stor_scan_thread(void * __us)
840 complete_and_exit(&us->scanning_done, 0); 848 complete_and_exit(&us->scanning_done, 0);
841} 849}
842 850
851static unsigned int usb_stor_sg_tablesize(struct usb_interface *intf)
852{
853 struct usb_device *usb_dev = interface_to_usbdev(intf);
854
855 if (usb_dev->bus->sg_tablesize) {
856 return usb_dev->bus->sg_tablesize;
857 }
858 return SG_ALL;
859}
843 860
844/* First part of general USB mass-storage probing */ 861/* First part of general USB mass-storage probing */
845int usb_stor_probe1(struct us_data **pus, 862int usb_stor_probe1(struct us_data **pus,
@@ -868,6 +885,7 @@ int usb_stor_probe1(struct us_data **pus,
868 * Allow 16-byte CDBs and thus > 2TB 885 * Allow 16-byte CDBs and thus > 2TB
869 */ 886 */
870 host->max_cmd_len = 16; 887 host->max_cmd_len = 16;
888 host->sg_tablesize = usb_stor_sg_tablesize(intf);
871 *pus = us = host_to_us(host); 889 *pus = us = host_to_us(host);
872 memset(us, 0, sizeof(struct us_data)); 890 memset(us, 0, sizeof(struct us_data));
873 mutex_init(&(us->dev_mutex)); 891 mutex_init(&(us->dev_mutex));
@@ -929,6 +947,8 @@ int usb_stor_probe2(struct us_data *us)
929 result = usb_stor_acquire_resources(us); 947 result = usb_stor_acquire_resources(us);
930 if (result) 948 if (result)
931 goto BadDevice; 949 goto BadDevice;
950 snprintf(us->scsi_name, sizeof(us->scsi_name), "usb-storage %s",
951 dev_name(&us->pusb_intf->dev));
932 result = scsi_add_host(us_to_host(us), &us->pusb_intf->dev); 952 result = scsi_add_host(us_to_host(us), &us->pusb_intf->dev);
933 if (result) { 953 if (result) {
934 printk(KERN_WARNING USB_STORAGE 954 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 */