diff options
author | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
---|---|---|
committer | Andrea Bastoni <bastoni@cs.unc.edu> | 2010-05-30 19:16:45 -0400 |
commit | ada47b5fe13d89735805b566185f4885f5a3f750 (patch) | |
tree | 644b88f8a71896307d71438e9b3af49126ffb22b /drivers/usb/storage/usb.c | |
parent | 43e98717ad40a4ae64545b5ba047c7b86aa44f4f (diff) | |
parent | 3280f21d43ee541f97f8cda5792150d2dbec20d5 (diff) |
Merge branch 'wip-2.6.34' into old-private-masterarchived-private-master
Diffstat (limited to 'drivers/usb/storage/usb.c')
-rw-r--r-- | drivers/usb/storage/usb.c | 48 |
1 files changed, 34 insertions, 14 deletions
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>"); | |||
74 | MODULE_DESCRIPTION("USB Mass Storage driver for Linux"); | 78 | MODULE_DESCRIPTION("USB Mass Storage driver for Linux"); |
75 | MODULE_LICENSE("GPL"); | 79 | MODULE_LICENSE("GPL"); |
76 | 80 | ||
77 | static unsigned int delay_use = 5; | 81 | static unsigned int delay_use = 1; |
78 | module_param(delay_use, uint, S_IRUGO | S_IWUSR); | 82 | module_param(delay_use, uint, S_IRUGO | S_IWUSR); |
79 | MODULE_PARM_DESC(delay_use, "seconds to delay before using a new device"); | 83 | MODULE_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 | ||
851 | static 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 */ |
845 | int usb_stor_probe1(struct us_data **pus, | 862 | int 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 |