From: Hannes Reinecke <hare@suse.de>
To: James Bottomley <jbottomley@parallels.com>
Cc: linux-scsi@vger.kernel.org, Hannes Reinecke <hare@suse.de>,
Kay Sievers <kay@vrfy.org>
Subject: [PATCH 08/10] scsi: open-code scsi_decode_sense_buffer()
Date: Fri, 12 Oct 2012 10:33:48 +0200 [thread overview]
Message-ID: <1350030830-25614-9-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1350030830-25614-1-git-send-email-hare@suse.de>
Pointless, and actually wrong as there is no point in trying
to decode invalid sense data.
Cc: Kay Sievers <kay@vrfy.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/scsi/constants.c | 43 +++++++++++++++++--------------------------
1 files changed, 17 insertions(+), 26 deletions(-)
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index ded16d9..8bf2616 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -1373,29 +1373,6 @@ scsi_cmd_print_sense_hdr(struct scsi_cmnd *scmd, const char *desc,
EXPORT_SYMBOL(scsi_cmd_print_sense_hdr);
static void
-scsi_decode_sense_buffer(const unsigned char *sense_buffer, int sense_len,
- struct scsi_sense_hdr *sshdr)
-{
- int k, num, res;
-
- res = scsi_normalize_sense(sense_buffer, sense_len, sshdr);
- if (0 == res) {
- /* this may be SCSI-1 sense data */
- num = (sense_len < 32) ? sense_len : 32;
- printk("Unrecognized sense data (in hex):");
- for (k = 0; k < num; ++k) {
- if (0 == (k % 16)) {
- printk("\n");
- printk(KERN_INFO " ");
- }
- printk("%02x ", sense_buffer[k]);
- }
- printk("\n");
- return;
- }
-}
-
-static void
scsi_decode_sense_extras(const unsigned char *sense_buffer, int sense_len,
struct scsi_sense_hdr *sshdr)
{
@@ -1462,8 +1439,15 @@ void __scsi_print_sense(const char *name, const unsigned char *sense_buffer,
{
struct scsi_sense_hdr sshdr;
+ if (!scsi_normalize_sense(sense_buffer, sense_len, &sshdr)) {
+ /* this may be SCSI-1 sense data */
+ int num = (sense_len < 32) ? sense_len : 32;
+ pr_info("%s: Unrecognized sense data (in hex):", name);
+ print_hex_dump(KERN_INFO, " ", DUMP_PREFIX_OFFSET,
+ 16, 1, sense_buffer, num, false);
+ return;
+ }
printk(KERN_INFO "%s: ", name);
- scsi_decode_sense_buffer(sense_buffer, sense_len, &sshdr);
scsi_show_sense_hdr(&sshdr);
scsi_decode_sense_extras(sense_buffer, sense_len, &sshdr);
printk(KERN_INFO "%s: ", name);
@@ -1476,9 +1460,16 @@ void scsi_print_sense(char *name, struct scsi_cmnd *cmd)
{
struct scsi_sense_hdr sshdr;
+ if (!scsi_normalize_sense(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
+ &sshdr)) {
+ scmd_printk(KERN_INFO, cmd,
+ "Unrecognized sense data (in hex):");
+ print_hex_dump(KERN_INFO, " ", DUMP_PREFIX_OFFSET,
+ 16, 1, cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
+ false);
+ return;
+ }
scmd_printk(KERN_INFO, cmd, " ");
- scsi_decode_sense_buffer(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
- &sshdr);
scsi_show_sense_hdr(&sshdr);
scsi_decode_sense_extras(cmd->sense_buffer, SCSI_SENSE_BUFFERSIZE,
&sshdr);
--
1.7.4.2
next prev parent reply other threads:[~2012-10-12 8:34 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-12 8:33 [PATCH 00/10] scsi: avoid linebreaks in syslog output Hannes Reinecke
2012-10-12 8:33 ` [PATCH 01/10] sg: Use dev_printk Hannes Reinecke
2012-10-12 14:34 ` Douglas Gilbert
2012-10-12 8:33 ` [PATCH 02/10] sr: Use dev_printk() Hannes Reinecke
2012-10-12 8:33 ` [PATCH 03/10] scsi: Avoid linebreaks in syslog output Hannes Reinecke
2012-10-12 8:33 ` [PATCH 04/10] scsi: Use sdev_printk() for logging Hannes Reinecke
2012-10-12 8:33 ` [PATCH 05/10] scsi: use buffer for print_opcode_name() Hannes Reinecke
2012-10-12 8:33 ` [PATCH 06/10] scsi: use single printk call in scsi_print_command() Hannes Reinecke
2012-10-12 8:33 ` [PATCH 07/10] scsi: use buffer for scsi_show_result() Hannes Reinecke
2012-10-12 8:33 ` Hannes Reinecke [this message]
2012-10-12 8:33 ` [PATCH 09/10] scsi: decode descriptor sense Hannes Reinecke
2012-10-12 8:33 ` [PATCH 10/10] scsi: use local buffer for decoding sense data Hannes Reinecke
2012-10-15 0:19 ` [PATCH 00/10] scsi: avoid linebreaks in syslog output Mike Snitzer
2012-10-15 6:02 ` Hannes Reinecke
2013-12-20 13:25 ` Tomas Henzl
2013-12-20 13:31 ` Hannes Reinecke
2013-12-20 13:35 ` Tomas Henzl
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=1350030830-25614-9-git-send-email-hare@suse.de \
--to=hare@suse.de \
--cc=jbottomley@parallels.com \
--cc=kay@vrfy.org \
--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;
as well as URLs for NNTP newsgroup(s).