ChangeSet 1.996, 2003/02/20 11:11:34-08:00, stern@rowland.harvard.edu [PATCH] USB: Patches for the ECONNRESET error (2.4) Matt Dharm asked me to send these bug-fix patches directly to you. They correct the error-code handling in usb-storage. The change for 2.5 is pretty minor; it only affects debugging output. But the change for 2.4 is more pervasive, and according to Tom Collins it is the key to making a usb hard disk work on his MIPS-based system. diff -Nru a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c --- a/drivers/usb/storage/datafab.c Thu Feb 20 12:07:07 2003 +++ b/drivers/usb/storage/datafab.c Thu Feb 20 12:07:07 2003 @@ -121,8 +121,8 @@ return US_BULK_TRANSFER_FAILED; } - // -ENOENT -- we canceled this transfer - if (result == -ENOENT) { + // -ECONNRESET -- we canceled this transfer + if (result == -ECONNRESET) { US_DEBUGP("datafab_raw_bulk: transfer aborted\n"); return US_BULK_TRANSFER_ABORTED; } diff -Nru a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c --- a/drivers/usb/storage/freecom.c Thu Feb 20 12:07:07 2003 +++ b/drivers/usb/storage/freecom.c Thu Feb 20 12:07:07 2003 @@ -198,7 +198,7 @@ result = usb_stor_bulk_msg (us, ideout, opipe, FCM_PACKET_LENGTH, &partial); if (result != 0) { - if (result == -ENOENT) + if (result == -ECONNRESET) return US_BULK_TRANSFER_ABORTED; else return USB_STOR_TRANSPORT_ERROR; @@ -238,7 +238,7 @@ result = usb_stor_bulk_msg (us, idein, opipe, FCM_PACKET_LENGTH, &partial); if (result != 0) { - if (result == -ENOENT) + if (result == -ECONNRESET) return US_BULK_TRANSFER_ABORTED; else return USB_STOR_TRANSPORT_ERROR; @@ -251,7 +251,7 @@ result = usb_stor_bulk_msg (us, buffer, ipipe, desired_length, &partial); if (result != 0) { - if (result == -ENOENT) + if (result == -ECONNRESET) return US_BULK_TRANSFER_ABORTED; else return USB_STOR_TRANSPORT_ERROR; @@ -292,8 +292,8 @@ US_DEBUGP ("Freecom readdata xpot failure: r=%d, p=%d\n", result, partial); - /* -ENOENT -- we canceled this transfer */ - if (result == -ENOENT) { + /* -ECONNRESET -- we canceled this transfer */ + if (result == -ECONNRESET) { US_DEBUGP("freecom_readdata(): transfer aborted\n"); return US_BULK_TRANSFER_ABORTED; } @@ -333,8 +333,8 @@ US_DEBUGP ("Freecom writedata xpot failure: r=%d, p=%d\n", result, partial); - /* -ENOENT -- we canceled this transfer */ - if (result == -ENOENT) { + /* -ECONNRESET -- we canceled this transfer */ + if (result == -ECONNRESET) { US_DEBUGP("freecom_writedata(): transfer aborted\n"); return US_BULK_TRANSFER_ABORTED; } @@ -396,8 +396,8 @@ US_DEBUGP ("freecom xport failure: r=%d, p=%d\n", result, partial); - /* -ENOENT -- we canceled this transfer */ - if (result == -ENOENT) { + /* -ECONNRESET -- we canceled this transfer */ + if (result == -ECONNRESET) { US_DEBUGP("freecom_transport(): transfer aborted\n"); return US_BULK_TRANSFER_ABORTED; } @@ -410,8 +410,8 @@ result = usb_stor_bulk_msg (us, fst, ipipe, FCM_PACKET_LENGTH, &partial); US_DEBUGP("foo Status result %d %d\n", result, partial); - /* -ENOENT -- we canceled this transfer */ - if (result == -ENOENT) { + /* -ECONNRESET -- we canceled this transfer */ + if (result == -ECONNRESET) { US_DEBUGP("freecom_transport(): transfer aborted\n"); return US_BULK_TRANSFER_ABORTED; } @@ -448,8 +448,8 @@ US_DEBUGP ("freecom xport failure: r=%d, p=%d\n", result, partial); - /* -ENOENT -- we canceled this transfer */ - if (result == -ENOENT) { + /* -ECONNRESET -- we canceled this transfer */ + if (result == -ECONNRESET) { US_DEBUGP("freecom_transport(): transfer aborted\n"); return US_BULK_TRANSFER_ABORTED; } @@ -463,8 +463,8 @@ US_DEBUGP("bar Status result %d %d\n", result, partial); - /* -ENOENT -- we canceled this transfer */ - if (result == -ENOENT) { + /* -ECONNRESET -- we canceled this transfer */ + if (result == -ECONNRESET) { US_DEBUGP("freecom_transport(): transfer aborted\n"); return US_BULK_TRANSFER_ABORTED; } @@ -524,7 +524,7 @@ result = usb_stor_bulk_msg (us, fst, ipipe, FCM_PACKET_LENGTH, &partial); US_DEBUG(pdump ((void *) fst, partial)); - if (result == -ENOENT) { + if (result == -ECONNRESET) { US_DEBUGP ("freecom_transport: transfer aborted\n"); return US_BULK_TRANSFER_ABORTED; } @@ -552,7 +552,7 @@ US_DEBUGP("FCM: Waiting for status\n"); result = usb_stor_bulk_msg (us, fst, ipipe, FCM_PACKET_LENGTH, &partial); - if (result == -ENOENT) { + if (result == -ECONNRESET) { US_DEBUGP ("freecom_transport: transfer aborted\n"); return US_BULK_TRANSFER_ABORTED; } diff -Nru a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c --- a/drivers/usb/storage/isd200.c Thu Feb 20 12:07:07 2003 +++ b/drivers/usb/storage/isd200.c Thu Feb 20 12:07:07 2003 @@ -435,8 +435,8 @@ return ISD200_TRANSPORT_FAILED; } - /* -ENOENT -- we canceled this transfer */ - if (result == -ENOENT) { + /* -ECONNRESET -- we canceled this transfer */ + if (result == -ECONNRESET) { US_DEBUGP("isd200_transfer_partial(): transfer aborted\n"); return ISD200_TRANSPORT_ABORTED; } @@ -574,7 +574,7 @@ &partial); US_DEBUGP("Bulk command transfer result=%d\n", result); - if (result == -ENOENT) + if (result == -ECONNRESET) return ISD200_TRANSPORT_ABORTED; else if (result == -EPIPE) { /* if we stall, we need to clear it before we go on */ @@ -603,7 +603,7 @@ US_DEBUGP("Attempting to get CSW...\n"); result = usb_stor_bulk_msg(us, &bcs, pipe, US_BULK_CS_WRAP_LEN, &partial); - if (result == -ENOENT) + if (result == -ECONNRESET) return ISD200_TRANSPORT_ABORTED; /* did the attempt to read the CSW fail? */ @@ -617,7 +617,7 @@ US_BULK_CS_WRAP_LEN, &partial); /* if the command was aborted, indicate that */ - if (result == -ENOENT) + if (result == -ECONNRESET) return ISD200_TRANSPORT_ABORTED; /* if it fails again, we need a reset and return an error*/ diff -Nru a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c --- a/drivers/usb/storage/jumpshot.c Thu Feb 20 12:07:07 2003 +++ b/drivers/usb/storage/jumpshot.c Thu Feb 20 12:07:07 2003 @@ -132,7 +132,7 @@ if (result < 0) { /* if the command was aborted, indicate that */ - if (result == -ENOENT) + if (result == -ECONNRESET) return USB_STOR_TRANSPORT_ABORTED; /* a stall is a fatal condition from the device */ @@ -181,8 +181,8 @@ return US_BULK_TRANSFER_FAILED; } - // -ENOENT -- we canceled this transfer - if (result == -ENOENT) { + // -ECONNRESET -- we canceled this transfer + if (result == -ECONNRESET) { US_DEBUGP("jumpshot_raw_bulk: transfer aborted\n"); return US_BULK_TRANSFER_ABORTED; } diff -Nru a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c --- a/drivers/usb/storage/sddr09.c Thu Feb 20 12:07:07 2003 +++ b/drivers/usb/storage/sddr09.c Thu Feb 20 12:07:07 2003 @@ -110,7 +110,7 @@ if (result < 0) { /* if the command was aborted, indicate that */ - if (result == -ENOENT) + if (result == -ECONNRESET) return USB_STOR_TRANSPORT_ABORTED; /* a stall is a fatal condition from the device */ @@ -161,8 +161,8 @@ return US_BULK_TRANSFER_FAILED; } - /* -ENOENT -- we canceled this transfer */ - if (result == -ENOENT) { + /* -ECONNRESET -- we canceled this transfer */ + if (result == -ECONNRESET) { US_DEBUGP("usbat_raw_bulk():" " transfer aborted\n"); return US_BULK_TRANSFER_ABORTED; diff -Nru a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c --- a/drivers/usb/storage/sddr55.c Thu Feb 20 12:07:07 2003 +++ b/drivers/usb/storage/sddr55.c Thu Feb 20 12:07:07 2003 @@ -106,8 +106,8 @@ return US_BULK_TRANSFER_FAILED; } - /* -ENOENT -- we canceled this transfer */ - if (result == -ENOENT) { + /* -ECONNRESET -- we canceled this transfer */ + if (result == -ECONNRESET) { US_DEBUGP("usbat_raw_bulk():" " transfer aborted\n"); return US_BULK_TRANSFER_ABORTED; diff -Nru a/drivers/usb/storage/shuttle_usbat.c b/drivers/usb/storage/shuttle_usbat.c --- a/drivers/usb/storage/shuttle_usbat.c Thu Feb 20 12:07:07 2003 +++ b/drivers/usb/storage/shuttle_usbat.c Thu Feb 20 12:07:07 2003 @@ -104,7 +104,7 @@ if (result < 0) { /* if the command was aborted, indicate that */ - if (result == -ENOENT) + if (result == -ECONNRESET) return USB_STOR_TRANSPORT_ABORTED; /* a stall is a fatal condition from the device */ @@ -155,8 +155,8 @@ return US_BULK_TRANSFER_FAILED; } - /* -ENOENT -- we canceled this transfer */ - if (result == -ENOENT) { + /* -ECONNRESET -- we canceled this transfer */ + if (result == -ECONNRESET) { US_DEBUGP("usbat_raw_bulk():" " transfer aborted\n"); return US_BULK_TRANSFER_ABORTED; diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c --- a/drivers/usb/storage/transport.c Thu Feb 20 12:07:07 2003 +++ b/drivers/usb/storage/transport.c Thu Feb 20 12:07:07 2003 @@ -520,7 +520,7 @@ } /* did we abort this command? */ - if (result == -ENOENT) { + if (result == -ECONNRESET) { US_DEBUGP("usb_stor_transfer_partial(): transfer aborted\n"); return US_BULK_TRANSFER_ABORTED; } @@ -820,7 +820,7 @@ } /* is the device removed? */ - if (urb->status == -ENOENT) { + if (urb->status == -ENODEV) { US_DEBUGP("-- device has been removed\n"); return; } @@ -876,7 +876,7 @@ } /* if the command was aborted, indicate that */ - if (result == -ENOENT) + if (result == -ECONNRESET) return USB_STOR_TRANSPORT_ABORTED; /* STALL must be cleared when it is detected */ @@ -886,7 +886,7 @@ usb_sndctrlpipe(us->pusb_dev, 0)); /* if the command was aborted, indicate that */ - if (result == -ENOENT) + if (result == -ECONNRESET) return USB_STOR_TRANSPORT_ABORTED; return USB_STOR_TRANSPORT_FAILED; } @@ -989,7 +989,7 @@ US_DEBUGP("Call to usb_stor_control_msg() returned %d\n", result); if (result < 0) { /* if the command was aborted, indicate that */ - if (result == -ENOENT) + if (result == -ECONNRESET) return USB_STOR_TRANSPORT_ABORTED; /* a stall is a fatal condition from the device */ @@ -999,7 +999,7 @@ usb_sndctrlpipe(us->pusb_dev, 0)); /* if the command was aborted, indicate that */ - if (result == -ENOENT) + if (result == -ECONNRESET) return USB_STOR_TRANSPORT_ABORTED; return USB_STOR_TRANSPORT_FAILED; } @@ -1129,7 +1129,7 @@ US_DEBUGP("Bulk command transfer result=%d\n", result); /* if the command was aborted, indicate that */ - if (result == -ENOENT) { + if (result == -ECONNRESET) { ret = USB_STOR_TRANSPORT_ABORTED; goto out; } @@ -1140,7 +1140,7 @@ result = usb_stor_clear_halt(us, pipe); /* if the command was aborted, indicate that */ - if (result == -ENOENT) { + if (result == -ECONNRESET) { ret = USB_STOR_TRANSPORT_ABORTED; goto out; } @@ -1180,7 +1180,7 @@ &partial); /* if the command was aborted, indicate that */ - if (result == -ENOENT) { + if (result == -ECONNRESET) { ret = USB_STOR_TRANSPORT_ABORTED; goto out; } @@ -1191,7 +1191,7 @@ result = usb_stor_clear_halt(us, pipe); /* if the command was aborted, indicate that */ - if (result == -ENOENT) { + if (result == -ECONNRESET) { ret = USB_STOR_TRANSPORT_ABORTED; goto out; } @@ -1202,7 +1202,7 @@ US_BULK_CS_WRAP_LEN, &partial); /* if the command was aborted, indicate that */ - if (result == -ENOENT) { + if (result == -ECONNRESET) { ret = USB_STOR_TRANSPORT_ABORTED; goto out; } @@ -1213,7 +1213,7 @@ result = usb_stor_clear_halt(us, pipe); /* if the command was aborted, indicate that */ - if (result == -ENOENT) { + if (result == -ECONNRESET) { ret = USB_STOR_TRANSPORT_ABORTED; } else { ret = USB_STOR_TRANSPORT_ERROR;