firewire: sbp2: Fix SCSI sense data mangling
authorChris Boot <bootc@bootc.net>
Wed, 15 Feb 2012 14:59:10 +0000 (14:59 +0000)
committerStefan Richter <stefanr@s5r6.in-berlin.de>
Wed, 22 Feb 2012 21:36:02 +0000 (22:36 +0100)
SCSI sense data in SBP-2/3 is carried in an unusual format that means we
have to un-mangle it on our end before we pass it to the SCSI subsystem.
Currently our un-mangling code doesn't quite follow the SBP-2 standard
in that we always assume Current and never Deferred error types, we
never set the VALID bit, and we mishandle the FILEMARK, EOM and ILI
bits.

This patch fixes the sense un-mangling to correctly handle those and
follow the spec.

Signed-off-by: Chris Boot <bootc@bootc.net>
Signed-off-by: Stefan Richter <stefanr@s5r6.in-berlin.de>
drivers/firewire/sbp2.c

index 0c92ed835e06f435d65fe9c6160cc5064df0ff90..cc5828e7c7353725800594c96deb0754a01ae3cb 100644 (file)
@@ -1309,10 +1309,19 @@ static void sbp2_unmap_scatterlist(struct device *card_device,
 static unsigned int sbp2_status_to_sense_data(u8 *sbp2_status, u8 *sense_data)
 {
        int sam_status;
+       int sfmt = (sbp2_status[0] >> 6) & 0x03;
 
-       sense_data[0] = 0x70;
+       if (sfmt == 2 || sfmt == 3) {
+               /*
+                * Reserved for future standardization (2) or
+                * Status block format vendor-dependent (3)
+                */
+               return DID_ERROR << 16;
+       }
+
+       sense_data[0] = 0x70 | sfmt | (sbp2_status[1] & 0x80);
        sense_data[1] = 0x0;
-       sense_data[2] = sbp2_status[1];
+       sense_data[2] = ((sbp2_status[1] << 1) & 0xe0) | (sbp2_status[1] & 0x0f);
        sense_data[3] = sbp2_status[4];
        sense_data[4] = sbp2_status[5];
        sense_data[5] = sbp2_status[6];
This page took 0.025521 seconds and 5 git commands to generate.