# This is a BitKeeper generated patch for the following project:
# Project Name: Linux kernel tree
# This patch format is intended for GNU patch command version 2.5 or higher.
# This patch includes the following deltas:
# ChangeSet 1.592.2.1 -> 1.592.2.2
# drivers/usb/storage/transport.c 1.19 -> 1.20
# drivers/usb/storage/freecom.c 1.11 -> 1.12
# drivers/usb/storage/scsiglue.c 1.20 -> 1.21
#
# The following is the BitKeeper ChangeSet Log
# --------------------------------------------
# 02/05/30 [EMAIL PROTECTED] 1.592.2.2
# [PATCH] USB storage: Dead code, more abort cleanups, and detached device fix
#
# Here's a patch which does three things:
#
# (1) It removes some dead code.
# (2) It moves more code to using the new state machine
# (3) It fixes a long standing bug relating to the sense data for a detached
# device.
# --------------------------------------------
#
diff -Nru a/drivers/usb/storage/freecom.c b/drivers/usb/storage/freecom.c
--- a/drivers/usb/storage/freecom.c Fri May 31 00:41:15 2002
+++ b/drivers/usb/storage/freecom.c Fri May 31 00:41:15 2002
@@ -167,108 +167,6 @@
srb->result = result;
}
-#if 0
-/* Write a value to an ide register. */
-static int
-freecom_ide_write (struct us_data *us, int reg, int value)
-{
- freecom_udata_t extra = (freecom_udata_t) us->extra;
- struct freecom_ide_out *ideout =
- (struct freecom_ide_out *) extra->buffer;
- int opipe;
- int result, partial;
-
- US_DEBUGP("IDE out 0x%02x <- 0x%02x\n", reg, value);
-
- /* Get handles for both transports. */
- opipe = usb_sndbulkpipe (us->pusb_dev, us->ep_out);
-
- if (reg < 0 || reg > 8)
- return USB_STOR_TRANSPORT_ERROR;
- if (reg < 8)
- reg |= 0x20;
- else
- reg = 0x0e;
-
- ideout->Type = FCM_PACKET_IDE_WRITE | reg;
- ideout->Pad = 0;
- ideout->Value = cpu_to_le16 (value);
- memset (ideout->Pad2, 0, sizeof (ideout->Pad2));
-
- result = usb_stor_bulk_msg (us, ideout, opipe,
- FCM_PACKET_LENGTH, &partial);
- if (result != 0) {
- if (result == -ENOENT)
- return US_BULK_TRANSFER_ABORTED;
- else
- return USB_STOR_TRANSPORT_ERROR;
- }
-
- return USB_STOR_TRANSPORT_GOOD;
-}
-
-/* Read a value from an ide register. */
-static int
-freecom_ide_read (struct us_data *us, int reg, int *value)
-{
- freecom_udata_t extra = (freecom_udata_t) us->extra;
- struct freecom_ide_in *idein =
- (struct freecom_ide_in *) extra->buffer;
- __u8 *buffer = extra->buffer;
- int ipipe, opipe;
- int result, partial;
- int desired_length;
-
- /* Get handles for both transports. */
- opipe = usb_sndbulkpipe (us->pusb_dev, us->ep_out);
- ipipe = usb_rcvbulkpipe (us->pusb_dev, us->ep_in);
-
- if (reg < 0 || reg > 8)
- return USB_STOR_TRANSPORT_ERROR;
- if (reg < 8)
- reg |= 0x10;
- else
- reg = 0x0e;
-
- US_DEBUGP("IDE in request for register 0x%02x\n", reg);
-
- idein->Type = FCM_PACKET_IDE_READ | reg;
- memset (idein->Pad, 0, sizeof (idein->Pad));
-
- result = usb_stor_bulk_msg (us, idein, opipe,
- FCM_PACKET_LENGTH, &partial);
- if (result != 0) {
- if (result == -ENOENT)
- return US_BULK_TRANSFER_ABORTED;
- else
- return USB_STOR_TRANSPORT_ERROR;
- }
-
- desired_length = 1;
- if (reg == 0x10)
- desired_length = 2;
-
- result = usb_stor_bulk_msg (us, buffer, ipipe,
- desired_length, &partial);
- if (result != 0) {
- if (result == -ENOENT)
- return US_BULK_TRANSFER_ABORTED;
- else
- return USB_STOR_TRANSPORT_ERROR;
- }
- US_DEBUGP("IDE in partial is %d\n", partial);
-
- if (desired_length == 1)
- *value = buffer[0];
- else
- *value = le16_to_cpu (*(__u16 *) buffer);
-
- US_DEBUGP("IDE in 0x%02x -> 0x%02x\n", reg, *value);
-
- return USB_STOR_TRANSPORT_GOOD;
-}
-#endif
-
static int
freecom_readdata (Scsi_Cmnd *srb, struct us_data *us,
int ipipe, int opipe, int count)
@@ -292,8 +190,8 @@
US_DEBUGP ("Freecom readdata xpot failure: r=%d, p=%d\n",
result, partial);
- /* -ENOENT -- we canceled this transfer */
- if (result == -ENOENT) {
+ /* has the current command been aborted? */
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_readdata(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
@@ -333,8 +231,8 @@
US_DEBUGP ("Freecom writedata xpot failure: r=%d, p=%d\n",
result, partial);
- /* -ENOENT -- we canceled this transfer */
- if (result == -ENOENT) {
+ /* has the current command been aborted? */
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_writedata(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
@@ -396,8 +294,8 @@
US_DEBUGP ("freecom xport failure: r=%d, p=%d\n",
result, partial);
- /* -ENOENT -- we canceled this transfer */
- if (result == -ENOENT) {
+ /* we canceled this transfer */
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
@@ -410,8 +308,9 @@
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) {
+
+ /* we canceled this transfer */
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
@@ -448,8 +347,8 @@
US_DEBUGP ("freecom xport failure: r=%d, p=%d\n",
result, partial);
- /* -ENOENT -- we canceled this transfer */
- if (result == -ENOENT) {
+ /* we canceled this transfer */
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
@@ -463,8 +362,8 @@
US_DEBUGP("bar Status result %d %d\n", result, partial);
- /* -ENOENT -- we canceled this transfer */
- if (result == -ENOENT) {
+ /* we canceled this transfer */
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP("freecom_transport(): transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
@@ -524,7 +423,8 @@
result = usb_stor_bulk_msg (us, fst, ipipe,
FCM_PACKET_LENGTH, &partial);
US_DEBUG(pdump ((void *) fst, partial));
- if (result == -ENOENT) {
+
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP ("freecom_transport: transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
@@ -552,7 +452,8 @@
US_DEBUGP("FCM: Waiting for status\n");
result = usb_stor_bulk_msg (us, fst, ipipe,
FCM_PACKET_LENGTH, &partial);
- if (result == -ENOENT) {
+
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
US_DEBUGP ("freecom_transport: transfer aborted\n");
return US_BULK_TRANSFER_ABORTED;
}
diff -Nru a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c
--- a/drivers/usb/storage/scsiglue.c Fri May 31 00:41:15 2002
+++ b/drivers/usb/storage/scsiglue.c Fri May 31 00:41:15 2002
@@ -386,9 +386,9 @@
unsigned char usb_stor_sense_notready[18] = {
[0] = 0x70, /* current error */
[2] = 0x02, /* not ready */
- [5] = 0x0a, /* additional length */
- [10] = 0x04, /* not ready */
- [11] = 0x03 /* manual intervention */
+ [7] = 0x0a, /* additional length */
+ [12] = 0x04, /* not ready */
+ [13] = 0x03 /* manual intervention */
};
#define USB_STOR_SCSI_SENSE_HDRSZ 4
diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
--- a/drivers/usb/storage/transport.c Fri May 31 00:41:15 2002
+++ b/drivers/usb/storage/transport.c Fri May 31 00:41:15 2002
@@ -986,9 +986,11 @@
clear_bit(IP_WANTED, &us->bitflags);
}
- /* if the command was aborted, indicate that */
- if (result == -ENOENT)
- return USB_STOR_TRANSPORT_ABORTED;
+ /* did we abort this command? */
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
+ US_DEBUGP("usb_stor_control_msg(): transfer aborted\n");
+ return US_BULK_TRANSFER_ABORTED;
+ }
/* STALL must be cleared when it is detected */
if (result == -EPIPE) {
@@ -996,9 +998,12 @@
result = usb_stor_clear_halt(us,
usb_sndctrlpipe(us->pusb_dev, 0));
- /* if the command was aborted, indicate that */
- if (result == -ENOENT)
- return USB_STOR_TRANSPORT_ABORTED;
+ /* did we abort this command? */
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
+ US_DEBUGP("usb_stor_control_msg(): transfer aborted\n");
+ return US_BULK_TRANSFER_ABORTED;
+ }
+
return USB_STOR_TRANSPORT_FAILED;
}
@@ -1098,9 +1103,11 @@
/* check the return code for the command */
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)
- return USB_STOR_TRANSPORT_ABORTED;
+ /* did we abort this command? */
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
+ US_DEBUGP("usb_stor_CB_transport(): transfer aborted\n");
+ return US_BULK_TRANSFER_ABORTED;
+ }
/* a stall is a fatal condition from the device */
if (result == -EPIPE) {
@@ -1108,9 +1115,11 @@
result = usb_stor_clear_halt(us,
usb_sndctrlpipe(us->pusb_dev, 0));
- /* if the command was aborted, indicate that */
- if (result == -ENOENT)
- return USB_STOR_TRANSPORT_ABORTED;
+ /* did we abort this command? */
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
+ US_DEBUGP("usb_stor_CB_transport(): transfer
+aborted\n");
+ return US_BULK_TRANSFER_ABORTED;
+ }
return USB_STOR_TRANSPORT_FAILED;
}
@@ -1215,18 +1224,22 @@
&partial);
US_DEBUGP("Bulk command transfer result=%d\n", result);
- /* if the command was aborted, indicate that */
- if (result == -ENOENT)
- return USB_STOR_TRANSPORT_ABORTED;
+ /* did we abort this command? */
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
+ US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n");
+ return US_BULK_TRANSFER_ABORTED;
+ }
/* if we stall, we need to clear it before we go on */
if (result == -EPIPE) {
US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe);
result = usb_stor_clear_halt(us, pipe);
- /* if the command was aborted, indicate that */
- if (result == -ENOENT)
- return USB_STOR_TRANSPORT_ABORTED;
+ /* did we abort this command? */
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
+ US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n");
+ return US_BULK_TRANSFER_ABORTED;
+ }
result = -EPIPE;
} else if (result) {
/* unknown error -- we've got a problem */
@@ -1259,36 +1272,44 @@
result = usb_stor_bulk_msg(us, &bcs, pipe, US_BULK_CS_WRAP_LEN,
&partial);
- /* if the command was aborted, indicate that */
- if (result == -ENOENT)
- return USB_STOR_TRANSPORT_ABORTED;
+ /* did we abort this command? */
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
+ US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n");
+ return US_BULK_TRANSFER_ABORTED;
+ }
/* did the attempt to read the CSW fail? */
if (result == -EPIPE) {
US_DEBUGP("clearing endpoint halt for pipe 0x%x\n", pipe);
result = usb_stor_clear_halt(us, pipe);
- /* if the command was aborted, indicate that */
- if (result == -ENOENT)
- return USB_STOR_TRANSPORT_ABORTED;
+ /* did we abort this command? */
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
+ US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n");
+ return US_BULK_TRANSFER_ABORTED;
+ }
/* get the status again */
US_DEBUGP("Attempting to get CSW (2nd try)...\n");
result = usb_stor_bulk_msg(us, &bcs, pipe,
US_BULK_CS_WRAP_LEN, &partial);
- /* if the command was aborted, indicate that */
- if (result == -ENOENT)
- return USB_STOR_TRANSPORT_ABORTED;
+ /* did we abort this command? */
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
+ US_DEBUGP("usb_stor_Bulk_transport(): transfer aborted\n");
+ return US_BULK_TRANSFER_ABORTED;
+ }
/* if it fails again, we need a reset and return an error*/
if (result == -EPIPE) {
US_DEBUGP("clearing halt for pipe 0x%x\n", pipe);
result = usb_stor_clear_halt(us, pipe);
- /* if the command was aborted, indicate that */
- if (result == -ENOENT)
- return USB_STOR_TRANSPORT_ABORTED;
+ /* did we abort this command? */
+ if (atomic_read(&us->sm_state) == US_STATE_ABORTING) {
+ US_DEBUGP("usb_stor_Bulk_transport(): transfer
+aborted\n");
+ return US_BULK_TRANSFER_ABORTED;
+ }
return USB_STOR_TRANSPORT_ERROR;
}
}
_______________________________________________________________
Don't miss the 2002 Sprint PCS Application Developer's Conference
August 25-28 in Las Vegas -- http://devcon.sprintpcs.com/adp/index.cfm
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel