All of lore.kernel.org
 help / color / mirror / Atom feed
From: Douglas Gilbert <dougg@torque.net>
To: Alan Stern <stern@rowland.harvard.edu>
Cc: linux-scsi@vger.kernel.org, James.Bottomley@SteelEye.com
Subject: [PATCH] scsi_get_sense_info_fld when valid=0
Date: Wed, 26 Oct 2005 11:12:51 +1000	[thread overview]
Message-ID: <435ED813.8070007@torque.net> (raw)

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

Alan,
This is in response to your post:
http://marc.theaimsgroup.com/?l=linux-scsi&m=112982432526039&w=2
in a thread titled:
  [PATCH] Improve code for detecting errors near the end of a CD

This patch should allow for the flexibility to handle
MMC devices that don't set the valid bit when putting
a lba in the information field.
The patch is against lk 2.6.14-rc5 .

Changelog:
  - make scsi_get_sense_info_fld() yield the sense
    data information field, or 0 if it is not available
  - the return value is the state of the valid bit in
    the sense data

Signed-off-by: Douglas Gilbert <dougg@torque.net>

Doug Gilbert


[-- Attachment #2: scsi_err2614rc5.diff --]
[-- Type: text/x-patch, Size: 1749 bytes --]

--- linux/drivers/scsi/scsi_error.c	2005-10-22 15:45:31.000000000 +1000
+++ linux/drivers/scsi/scsi_error.c2614rc5inf	2005-10-26 10:53:59.000000000 +1000
@@ -1929,11 +1929,17 @@
  *
  * @sense_buffer:	byte array of sense data
  * @sb_len:		number of valid bytes in sense_buffer
- * @info_out:		pointer to 64 integer where 8 or 4 byte information
- *			field will be placed if found.
+ * @info_out:		pointer to 64 bit integer where 8 or 4 byte
+ *			information field will be placed if found,
+ *			else 0 is written via pointer
+ *
+ * Notes:
+ *	Due to fuzziness in the MMC standard, a MMC device may (and some
+ *	do) set the information field without also setting the valid bit.
  *
  * Return value:
- *	1 if information field found, 0 if not found.
+ *	1 if valid bit is set, 0 if it is clear. Even when the return value
+ *	is 0, the information field may be fetched.
  **/
 int scsi_get_sense_info_fld(const u8 * sense_buffer, int sb_len,
 			    u64 * info_out)
@@ -1942,18 +1948,16 @@
 	const u8 * ucp;
 	u64 ull;
 
+	*info_out = 0;
 	if (sb_len < 7)
 		return 0;
 	switch (sense_buffer[0] & 0x7f) {
 	case 0x70:
 	case 0x71:
-		if (sense_buffer[0] & 0x80) {
-			*info_out = (sense_buffer[3] << 24) +
-				    (sense_buffer[4] << 16) +
-				    (sense_buffer[5] << 8) + sense_buffer[6];
-			return 1;
-		} else
-			return 0;
+		*info_out = (sense_buffer[3] << 24) +
+			    (sense_buffer[4] << 16) +
+			    (sense_buffer[5] << 8) + sense_buffer[6];
+		return (sense_buffer[0] & 0x80) ? 1 : 0;
 	case 0x72:
 	case 0x73:
 		ucp = scsi_sense_desc_find(sense_buffer, sb_len,
@@ -1966,7 +1970,7 @@
 				ull |= ucp[4 + j];
 			}
 			*info_out = ull;
-			return 1;
+			return 1;	/* valid bit defined to be 1 */
 		} else
 			return 0;
 	default:

                 reply	other threads:[~2005-10-26  1:12 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=435ED813.8070007@torque.net \
    --to=dougg@torque.net \
    --cc=James.Bottomley@SteelEye.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.