ChangeSet 1.1254.1.78, 2003/06/01 23:00:22-07:00, mdharm-usb@one-eyed-alien.net

[PATCH] USB: usb-storage: change result codes

This patch changes to SAM_STAT_ result codes, which is (a) preferred,
according to the code comments, and (b) removes some odd-looking
bit-shifting.


 drivers/usb/storage/datafab.c   |    2 +-
 drivers/usb/storage/isd200.c    |   20 ++++++++++----------
 drivers/usb/storage/jumpshot.c  |    2 +-
 drivers/usb/storage/protocol.c  |    9 ++++-----
 drivers/usb/storage/transport.c |    8 ++++----
 drivers/usb/storage/usb.c       |    4 ++--
 6 files changed, 22 insertions(+), 23 deletions(-)


diff -Nru a/drivers/usb/storage/datafab.c b/drivers/usb/storage/datafab.c
--- a/drivers/usb/storage/datafab.c	Mon Jun  2 11:20:12 2003
+++ b/drivers/usb/storage/datafab.c	Mon Jun  2 11:20:12 2003
@@ -670,7 +670,7 @@
 			srb->result = SUCCESS;
 		} else {
 			info->sense_key = UNIT_ATTENTION;
-			srb->result = CHECK_CONDITION << 1;
+			srb->result = SAM_STAT_CHECK_CONDITION;
 		}
 		return rc;
 	}
diff -Nru a/drivers/usb/storage/isd200.c b/drivers/usb/storage/isd200.c
--- a/drivers/usb/storage/isd200.c	Mon Jun  2 11:20:12 2003
+++ b/drivers/usb/storage/isd200.c	Mon Jun  2 11:20:12 2003
@@ -558,7 +558,7 @@
 
 	case USB_STOR_TRANSPORT_GOOD:
 		/* Indicate a good result */
-		srb->result = GOOD << 1;
+		srb->result = SAM_STAT_GOOD;
 		break;
 
 	case USB_STOR_TRANSPORT_FAILED:
@@ -598,11 +598,11 @@
 		}
 		if (result == ISD200_GOOD) {
 			isd200_build_sense(us, srb);
-			srb->result = CHECK_CONDITION << 1;
+			srb->result = SAM_STAT_CHECK_CONDITION;
 
 			/* If things are really okay, then let's show that */
 			if ((srb->sense_buffer[2] & 0xf) == 0x0)
-				srb->result = GOOD << 1;
+				srb->result = SAM_STAT_GOOD;
 		} else
 			srb->result = DID_ERROR << 16;
 	}
@@ -611,7 +611,7 @@
 	 * condition, show that in the result code
 	 */
 	if (transferStatus == USB_STOR_TRANSPORT_FAILED)
-		srb->result = CHECK_CONDITION << 1;
+		srb->result = SAM_STAT_CHECK_CONDITION;
 }
 
 #ifdef CONFIG_USB_STORAGE_DEBUG
@@ -1185,7 +1185,7 @@
 
 		/* copy InquiryData */
 		isd200_data_copy(srb, (char *) &info->InquiryData, srb->request_bufflen);
-		srb->result = GOOD << 1;
+		srb->result = SAM_STAT_GOOD;
 		sendToTransport = FALSE;
 		break;
 
@@ -1205,7 +1205,7 @@
 			srb->request_bufflen = 0;
 		} else {
 			US_DEBUGP("   Media Status not supported, just report okay\n");
-			srb->result = GOOD << 1;
+			srb->result = SAM_STAT_GOOD;
 			sendToTransport = FALSE;
 		}
 		break;
@@ -1226,7 +1226,7 @@
 			srb->request_bufflen = 0;
 		} else {
 			US_DEBUGP("   Media Status not supported, just report okay\n");
-			srb->result = GOOD << 1;
+			srb->result = SAM_STAT_GOOD;
 			sendToTransport = FALSE;
 		}
 		break;
@@ -1252,7 +1252,7 @@
 			srb->request_bufflen = sizeof(struct read_capacity_data);
 
 		isd200_data_copy(srb, (char *) &readCapacityData, srb->request_bufflen);
-		srb->result = GOOD << 1;
+		srb->result = SAM_STAT_GOOD;
 		sendToTransport = FALSE;
 	}
 	break;
@@ -1336,7 +1336,7 @@
 			srb->request_bufflen = 0;
 		} else {
 			US_DEBUGP("   Not removeable media, just report okay\n");
-			srb->result = GOOD << 1;
+			srb->result = SAM_STAT_GOOD;
 			sendToTransport = FALSE;
 		}
 		break;
@@ -1365,7 +1365,7 @@
 			srb->request_bufflen = 0;
 		} else {
 			US_DEBUGP("   Nothing to do, just report okay\n");
-			srb->result = GOOD << 1;
+			srb->result = SAM_STAT_GOOD;
 			sendToTransport = FALSE;
 		}
 		break;
diff -Nru a/drivers/usb/storage/jumpshot.c b/drivers/usb/storage/jumpshot.c
--- a/drivers/usb/storage/jumpshot.c	Mon Jun  2 11:20:12 2003
+++ b/drivers/usb/storage/jumpshot.c	Mon Jun  2 11:20:12 2003
@@ -611,7 +611,7 @@
 			srb->result = SUCCESS;
 		} else {
 			info->sense_key = UNIT_ATTENTION;
-			srb->result = CHECK_CONDITION << 1;
+			srb->result = SAM_STAT_CHECK_CONDITION;
 		}
 		return rc;
 	}
diff -Nru a/drivers/usb/storage/protocol.c b/drivers/usb/storage/protocol.c
--- a/drivers/usb/storage/protocol.c	Mon Jun  2 11:20:12 2003
+++ b/drivers/usb/storage/protocol.c	Mon Jun  2 11:20:12 2003
@@ -137,8 +137,7 @@
 
 	/* send the command to the transport layer */
 	usb_stor_invoke_transport(srb, us);
-	if (srb->result == GOOD << 1) {
-
+	if (srb->result == SAM_STAT_GOOD) {
 		/* fix the INQUIRY data if necessary */
 		fix_inquiry_data(srb);
 	}
@@ -210,7 +209,7 @@
 
 	/* send the command to the transport layer */
 	usb_stor_invoke_transport(srb, us);
-	if (srb->result == GOOD << 1) {
+	if (srb->result == SAM_STAT_GOOD) {
 
 		/* Fix the MODE_SENSE data if we translated the command */
 		if (old_cmnd == MODE_SENSE)
@@ -307,7 +306,7 @@
 
 	/* send the command to the transport layer */
 	usb_stor_invoke_transport(srb, us);
-	if (srb->result == GOOD << 1) {
+	if (srb->result == SAM_STAT_GOOD) {
 
 		/* Fix the MODE_SENSE data if we translated the command */
 		if (old_cmnd == MODE_SENSE)
@@ -376,7 +375,7 @@
 
 	/* send the command to the transport layer */
 	usb_stor_invoke_transport(srb, us);
-	if (srb->result == GOOD << 1) {
+	if (srb->result == SAM_STAT_GOOD) {
 
 		/* Fix the MODE_SENSE data if we translated the command */
 		if ((us->flags & US_FL_MODE_XLATE) && (old_cmnd == MODE_SENSE))
diff -Nru a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
--- a/drivers/usb/storage/transport.c	Mon Jun  2 11:20:12 2003
+++ b/drivers/usb/storage/transport.c	Mon Jun  2 11:20:12 2003
@@ -669,19 +669,19 @@
 #endif
 
 		/* set the result so the higher layers expect this data */
-		srb->result = CHECK_CONDITION << 1;
+		srb->result = SAM_STAT_CHECK_CONDITION;
 
 		/* If things are really okay, then let's show that */
 		if ((srb->sense_buffer[2] & 0xf) == 0x0)
-			srb->result = GOOD << 1;
+			srb->result = SAM_STAT_GOOD;
 	} else /* if (need_auto_sense) */
-		srb->result = GOOD << 1;
+		srb->result = SAM_STAT_GOOD;
 
 	/* Regardless of auto-sense, if we _know_ we have an error
 	 * condition, show that in the result code
 	 */
 	if (result == USB_STOR_TRANSPORT_FAILED)
-		srb->result = CHECK_CONDITION << 1;
+		srb->result = SAM_STAT_CHECK_CONDITION;
 
 	/* If we think we're good, then make sure the sense data shows it.
 	 * This is necessary because the auto-sense for some devices always
diff -Nru a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c
--- a/drivers/usb/storage/usb.c	Mon Jun  2 11:20:12 2003
+++ b/drivers/usb/storage/usb.c	Mon Jun  2 11:20:12 2003
@@ -374,7 +374,7 @@
 				memcpy(us->srb->sense_buffer, 
 				       usb_stor_sense_invalidCDB, 
 				       sizeof(usb_stor_sense_invalidCDB));
-				us->srb->result = CHECK_CONDITION << 1;
+				us->srb->result = SAM_STAT_CHECK_CONDITION;
 		}
 
 		/* Handle those devices which need us to fake 
@@ -387,7 +387,7 @@
 
 			US_DEBUGP("Faking INQUIRY command\n");
 			fill_inquiry_response(us, data_ptr, 36);
-			us->srb->result = GOOD << 1;
+			us->srb->result = SAM_STAT_GOOD;
 		}
 
 		/* we've got a command, let's do it! */
