public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@steeleye.com>
To: SCSI Mailing List <linux-scsi@vger.kernel.org>
Subject: Correct typo in linux/scsi/scsi.h and introduce new scsi_status_is_good macro
Date: 08 May 2003 10:15:12 -0400	[thread overview]
Message-ID: <1052403312.2097.35.camel@mulgrave> (raw)

[-- Attachment #1: Type: text/plain, Size: 530 bytes --]

I notice we seem to have a typo in the SAM_ status codes (they say
IMMEDIATE where they mean INTERMEDIATE).

I've also introduced a new macro who's job is to return true if any of
the possible good return codes is found.  This means

SAM_STAT_GOOD
SAM_STAT_INTERMEDIATE
SAM_STAT_INTERMEDIATE_CONDITION_MET

and for now

SAM_STAT_COMMAND_TERMINATED

By and large, this is currently irrelevant to us, since we don't use
linked commands and I've never met a device using COMMAND TERMINATED,
but it may help us in the future.

James


[-- Attachment #2: tmp.diff --]
[-- Type: text/plain, Size: 1582 bytes --]

===== include/scsi/scsi.h 1.9 vs edited =====
--- 1.9/include/scsi/scsi.h	Thu Jan 23 10:50:27 2003
+++ edited/include/scsi/scsi.h	Thu May  8 10:09:33 2003
@@ -111,13 +111,38 @@
 #define SAM_STAT_CHECK_CONDITION 0x02
 #define SAM_STAT_CONDITION_MET   0x04
 #define SAM_STAT_BUSY            0x08
-#define SAM_STAT_IMMEDIATE       0x10
-#define SAM_STAT_IMMEDIATE_CONDITION_MET 0x14
+#define SAM_STAT_INTERMEDIATE    0x10
+#define SAM_STAT_INTERMEDIATE_CONDITION_MET 0x14
 #define SAM_STAT_RESERVATION_CONFLICT 0x18
 #define SAM_STAT_COMMAND_TERMINATED 0x22	/* obsolete in SAM-3 */
 #define SAM_STAT_TASK_SET_FULL   0x28
 #define SAM_STAT_ACA_ACTIVE      0x30
 #define SAM_STAT_TASK_ABORTED    0x40
+
+/** scsi_status_is_good - check the status return.
+ *
+ * @status: the status passed up from the driver (including host and
+ *          driver components)
+ *
+ * This returns true for known good conditions that may be treated as
+ * command completed normally
+ */
+static inline int scsi_status_is_good(int status)
+{
+	/* mask out the relevant bits
+	 *
+	 * FIXME: bit0 is listed as reserved in SCSI-2, but is
+	 * significant in SCSI-3.  For now, we follow the SCSI-2
+	 * behaviour and ignore reserved bits. */
+	
+	status &= 0xfe;
+
+	return ((status & SAM_STAT_GOOD)
+		|| (status & SAM_STAT_INTERMEDIATE)
+		|| (status & SAM_STAT_INTERMEDIATE_CONDITION_MET)
+		/* FIXME: this is obsolete in SAM-3 */
+		|| (status & SAM_STAT_COMMAND_TERMINATED));
+}
 
 /*
  *  Status codes. These are deprecated as they are shifted 1 bit right

                 reply	other threads:[~2003-05-08 14:02 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1052403312.2097.35.camel@mulgrave \
    --to=james.bottomley@steeleye.com \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox