linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch] NCR5380.c fix
@ 2003-05-15 22:45 Andries.Brouwer
  2003-05-15 22:52 ` James Bottomley
  2003-05-15 23:16 ` Douglas Gilbert
  0 siblings, 2 replies; 5+ messages in thread
From: Andries.Brouwer @ 2003-05-15 22:45 UTC (permalink / raw)
  To: linux-kernel, linux-scsi; +Cc: torvalds

Several SCSI drivers confuse CHECK_CONDITION and CHECK_CONDITION << 1.
One of them is NCR5380.c. Below a patch adding status_byte() twice.

(On the other hand, sun3_NCR5380.c does this right, and generally
looks better. Maybe they can be merged eventually.)

Andries

(This was for 2.5.68. I think 2.5.69 will differ by 1 line.)

diff -u --recursive --new-file -X /linux/dontdiff a/drivers/scsi/NCR5380.c b/drivers/scsi/NCR5380.c
--- a/drivers/scsi/NCR5380.c	Wed Mar  5 04:29:03 2003
+++ b/drivers/scsi/NCR5380.c	Fri May 16 01:42:51 2003
@@ -2466,11 +2466,11 @@
 
 					if (cmd->cmnd[0] != REQUEST_SENSE)
 						cmd->result = cmd->SCp.Status | (cmd->SCp.Message << 8);
-					else if (cmd->SCp.Status != GOOD)
+					else if (status_byte(cmd->SCp.Status) != GOOD)
 						cmd->result = (cmd->result & 0x00ffff) | (DID_ERROR << 16);
 
 #ifdef AUTOSENSE
-					if ((cmd->cmnd[0] != REQUEST_SENSE) && (cmd->SCp.Status == CHECK_CONDITION)) {
+					if ((cmd->cmnd[0] != REQUEST_SENSE) && (status_byte(cmd->SCp.Status) == CHECK_CONDITION)) {
 						dprintk(NDEBUG_AUTOSENSE, ("scsi%d : performing request sense\n", instance->host_no));
 						cmd->cmnd[0] = REQUEST_SENSE;
 						cmd->cmnd[1] &= 0xe0;

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] NCR5380.c fix
  2003-05-15 22:45 [patch] NCR5380.c fix Andries.Brouwer
@ 2003-05-15 22:52 ` James Bottomley
  2003-05-15 23:16 ` Douglas Gilbert
  1 sibling, 0 replies; 5+ messages in thread
From: James Bottomley @ 2003-05-15 22:52 UTC (permalink / raw)
  To: Andries.Brouwer; +Cc: Linux Kernel, SCSI Mailing List, torvalds

On Thu, 2003-05-15 at 17:45, Andries.Brouwer@cwi.nl wrote:
> -					else if (cmd->SCp.Status != GOOD)
> +					else if (status_byte(cmd->SCp.Status) != GOOD)

Well...if we're doing it this way, any reason not to use the newly
minted SAM_STAT_GOOD and SAM_STAT_CHECK_CONDITION?

James



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] NCR5380.c fix
@ 2003-05-15 23:10 Andries.Brouwer
  2003-05-15 23:12 ` James Bottomley
  0 siblings, 1 reply; 5+ messages in thread
From: Andries.Brouwer @ 2003-05-15 23:10 UTC (permalink / raw)
  To: Andries.Brouwer, James.Bottomley; +Cc: linux-kernel, linux-scsi, torvalds

> any reason not to use the newly minted SAM_STAT_GOOD and
> SAM_STAT_CHECK_CONDITION?

(i) this brings NCR5380.c a tiny little bit closer to sun3_NCR5380.c
(ii) I am not so happy with SAM_STAT_GOOD etc.

Maybe it is just me, but I do not immediately think of SCSI given SAM.
We have sym_defs.h with

#define S_GOOD          (0x00)
#define S_CHECK_COND    (0x02)
...

and aiclib.h with

#define SCSI_STATUS_OK                  0x00
#define SCSI_STATUS_CHECK_COND          0x02
...

and scsi.h with

#define SAM_STAT_GOOD            0x00
#define SAM_STAT_CHECK_CONDITION 0x02
...

I wouldn't mind merging these three and choosing the SCSI_STATUS_ prefix.

Andries

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] NCR5380.c fix
  2003-05-15 23:10 Andries.Brouwer
@ 2003-05-15 23:12 ` James Bottomley
  0 siblings, 0 replies; 5+ messages in thread
From: James Bottomley @ 2003-05-15 23:12 UTC (permalink / raw)
  To: Andries.Brouwer; +Cc: Linux Kernel, SCSI Mailing List, torvalds

On Thu, 2003-05-15 at 18:10, Andries.Brouwer@cwi.nl wrote:
> I wouldn't mind merging these three and choosing the SCSI_STATUS_ prefix.

I'll go for that if you want to do the honours.

James



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [patch] NCR5380.c fix
  2003-05-15 22:45 [patch] NCR5380.c fix Andries.Brouwer
  2003-05-15 22:52 ` James Bottomley
@ 2003-05-15 23:16 ` Douglas Gilbert
  1 sibling, 0 replies; 5+ messages in thread
From: Douglas Gilbert @ 2003-05-15 23:16 UTC (permalink / raw)
  To: Andries.Brouwer; +Cc: linux-kernel, linux-scsi

Andries.Brouwer@cwi.nl wrote:
> Several SCSI drivers confuse CHECK_CONDITION and CHECK_CONDITION << 1.
<snip>

Linux has always had SCSI status values that are masked
(reasonable) and shifted one bit right (bizarre) from
the equivalent values in the SCSI standards. This
has tricked lots of people.

So in lk 2.5 saner defines (with long-winded names)
have been introduced:
....
#define SAM_STAT_CHECK_CONDITION 0x02
....

The appropriate mask is now 0x7e since Linux uses
the upper bytes and the vendor could (but seldom)
use bits 0 and 7. We should have a constant or macro
for this mask.

So in lk 2.5 your check could read:

    if ((cmd->SCp.Status & 0x7e) == SAM_STAT_CHECK_CONDITION)


Aside: "SAM" stands for SCSI Architecture Model which is the
modern standard that defines SCSI status values.

Doug Gilbert



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-05-15 23:03 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-05-15 22:45 [patch] NCR5380.c fix Andries.Brouwer
2003-05-15 22:52 ` James Bottomley
2003-05-15 23:16 ` Douglas Gilbert
  -- strict thread matches above, loose matches on Subject: below --
2003-05-15 23:10 Andries.Brouwer
2003-05-15 23:12 ` James Bottomley

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).