ChangeSet 1.2020.1.32, 2005/03/07 22:52:25-08:00, [EMAIL PROTECTED]
[PATCH] usb-storage: More flexible signature checking mechanism
This patch alters the CSW signature checking code to work with devices that
report non-standard signatures, such as some Olympus and Aldi cameras.
We now learn the first signature we see, and use it to check signatures of all
subsequent transfers. This allows us to continue to benefit from the
error-checking capabilities of the signature transfer, while becoming
compatible with (yet more) non-standard devices.
Suggestion from Alan Stern.
Signed-off-by: Daniel Drake <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>
drivers/usb/storage/transport.c | 20 ++++++++++++++++----
drivers/usb/storage/transport.h | 3 ---
drivers/usb/storage/usb.h | 1 +
3 files changed, 17 insertions(+), 7 deletions(-)
diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
--- a/drivers/usb/storage/transport.c 2005-03-08 16:53:19 -08:00
+++ b/drivers/usb/storage/transport.c 2005-03-08 16:53:19 -08:00
@@ -1055,11 +1055,23 @@
US_DEBUGP("Bulk Status S 0x%x T 0x%x R %u Stat 0x%x\n",
le32_to_cpu(bcs->Signature), bcs->Tag,
residue, bcs->Status);
- if ((bcs->Signature != cpu_to_le32(US_BULK_CS_SIGN) &&
- bcs->Signature != cpu_to_le32(US_BULK_CS_OLYMPUS_SIGN)) ||
- bcs->Tag != srb->serial_number ||
- bcs->Status > US_BULK_STAT_PHASE) {
+ if (bcs->Tag != srb->serial_number || bcs->Status > US_BULK_STAT_PHASE)
{
US_DEBUGP("Bulk logical error\n");
+ return USB_STOR_TRANSPORT_ERROR;
+ }
+
+ /* Some broken devices report odd signatures, so we do not check them
+ * for validity against the spec. We store the first one we see,
+ * and check subsequent transfers for validity against this signature.
+ */
+ if (!us->bcs_signature) {
+ us->bcs_signature = bcs->Signature;
+ US_DEBUGP("Learnt BCS signature 0x%08X\n",
+ le32_to_cpu(us->bcs_signature));
+ } else if (bcs->Signature != us->bcs_signature) {
+ US_DEBUGP("Signature mismatch: device sent %08X, expecting
%08X",
+ le32_to_cpu(bcs->Signature),
+ le32_to_cpu(us->bcs_signature));
return USB_STOR_TRANSPORT_ERROR;
}
diff -Nru a/drivers/usb/storage/transport.h b/drivers/usb/storage/transport.h
--- a/drivers/usb/storage/transport.h 2005-03-08 16:53:19 -08:00
+++ b/drivers/usb/storage/transport.h 2005-03-08 16:53:19 -08:00
@@ -107,9 +107,6 @@
};
#define US_BULK_CS_WRAP_LEN 13
-#define US_BULK_CS_SIGN 0x53425355 /* spells out 'USBS' */
-/* This is for Olympus Camedia digital cameras */
-#define US_BULK_CS_OLYMPUS_SIGN 0x55425355 /* spells out
'USBU' */
#define US_BULK_STAT_OK 0
#define US_BULK_STAT_FAIL 1
#define US_BULK_STAT_PHASE 2
diff -Nru a/drivers/usb/storage/usb.h b/drivers/usb/storage/usb.h
--- a/drivers/usb/storage/usb.h 2005-03-08 16:53:19 -08:00
+++ b/drivers/usb/storage/usb.h 2005-03-08 16:53:19 -08:00
@@ -127,6 +127,7 @@
char serial[USB_STOR_STRING_LEN];
char *transport_name;
char *protocol_name;
+ __le32 bcs_signature;
u8 subclass;
u8 protocol;
u8 max_lun;
-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now.
http://ads.osdn.com/?ad_ide95&alloc_id396&op=click
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel