aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/storage/usb.c
diff options
context:
space:
mode:
authorAlan Stern <stern@rowland.harvard.edu>2008-12-15 12:43:41 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2009-01-07 13:00:11 -0500
commit25ff1c316f6a763f1eefe7f8984b2d8c03888432 (patch)
tree623759675a8e2db8cbcacc665d97d874e57ab4c5 /drivers/usb/storage/usb.c
parent9ebd9616648bc0e47e7f8e1898c919305f1e6347 (diff)
USB: storage: add last-sector hacks
This patch (as1189b) adds some hacks to usb-storage for dealing with the growing problems involving bad capacity values and last-sector accesses: A new flag, US_FL_CAPACITY_OK, is created to indicate that the device is known to report its capacity correctly. An unusual_devs entry for Linux's own File-backed Storage Gadget is added with this flag set, since g_file_storage always reports the correct capacity and since the capacity need not be even (it is determined by the size of the backing file). An entry in unusual_devs.h which has only the CAPACITY_OK flag set shouldn't prejudice libusual, since the device will work perfectly well with either usb-storage or ub. So a new macro, COMPLIANT_DEV, is added to let libusual know about these entries. When a last-sector access succeeds and the total number of sectors is odd (the unexpected case, in which guessing that the number is even might cause trouble), a WARN is triggered. The kerneloops.org project will collect these warnings, allowing us to add CAPACITY_OK flags for the devices in question before implementing the default-to-even heuristic. If users want to prevent the stack dump produced by the WARN, they can disable the hack by adding an unusual_devs entry for their device with the CAPACITY_OK flag. When a last-sector access fails three times in a row and neither the FIX_CAPACITY nor the CAPACITY_OK flag is set, we assume the last-sector bug is present. We replace the existing status and sense data with values that will cause the SCSI core to fail the access immediately rather than retry indefinitely. This should fix the difficulties people have been having with Nokia phones. Signed-off-by: Alan Stern <stern@rowland.harvard.edu> Cc: stable <stable@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/storage/usb.c')
-rw-r--r--drivers/usb/storage/usb.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
index ce0b580db5ea..80e234bf4e50 100644
--- a/drivers/usb/storage/usb.c
+++ b/drivers/usb/storage/usb.c
@@ -134,6 +134,8 @@ static struct quirks_entry *quirks_list, *quirks_end;
134{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax), \ 134{ USB_DEVICE_VER(id_vendor, id_product, bcdDeviceMin,bcdDeviceMax), \
135 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) } 135 .driver_info = (flags)|(USB_US_TYPE_STOR<<24) }
136 136
137#define COMPLIANT_DEV UNUSUAL_DEV
138
137#define USUAL_DEV(useProto, useTrans, useType) \ 139#define USUAL_DEV(useProto, useTrans, useType) \
138{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \ 140{ USB_INTERFACE_INFO(USB_CLASS_MASS_STORAGE, useProto, useTrans), \
139 .driver_info = (USB_US_TYPE_STOR<<24) } 141 .driver_info = (USB_US_TYPE_STOR<<24) }
@@ -142,6 +144,7 @@ static struct usb_device_id storage_usb_ids [] = {
142 144
143# include "unusual_devs.h" 145# include "unusual_devs.h"
144#undef UNUSUAL_DEV 146#undef UNUSUAL_DEV
147#undef COMPLIANT_DEV
145#undef USUAL_DEV 148#undef USUAL_DEV
146 /* Terminating entry */ 149 /* Terminating entry */
147 { } 150 { }
@@ -172,6 +175,8 @@ MODULE_DEVICE_TABLE (usb, storage_usb_ids);
172 .initFunction = init_function, \ 175 .initFunction = init_function, \
173} 176}
174 177
178#define COMPLIANT_DEV UNUSUAL_DEV
179
175#define USUAL_DEV(use_protocol, use_transport, use_type) \ 180#define USUAL_DEV(use_protocol, use_transport, use_type) \
176{ \ 181{ \
177 .useProtocol = use_protocol, \ 182 .useProtocol = use_protocol, \
@@ -181,6 +186,7 @@ MODULE_DEVICE_TABLE (usb, storage_usb_ids);
181static struct us_unusual_dev us_unusual_dev_list[] = { 186static struct us_unusual_dev us_unusual_dev_list[] = {
182# include "unusual_devs.h" 187# include "unusual_devs.h"
183# undef UNUSUAL_DEV 188# undef UNUSUAL_DEV
189# undef COMPLIANT_DEV
184# undef USUAL_DEV 190# undef USUAL_DEV
185 191
186 /* Terminating entry */ 192 /* Terminating entry */