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 06/10] scsi: use single printk call in scsi_print_command()
Date: Fri, 12 Oct 2012 10:33:46 +0200 [thread overview]
Message-ID: <1350030830-25614-7-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1350030830-25614-1-git-send-email-hare@suse.de>
scsi_print_command is using several calls to printk(), causing
the output to be garbled. Modify it to use a single call to
printk().
Cc: Kay Sievers <kay@vrfy.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/scsi/constants.c | 71 +++++++++++++++++++++++++++++++++++++++------
1 files changed, 61 insertions(+), 10 deletions(-)
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index b469798..65367e8 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -349,34 +349,85 @@ static int print_opcode_name(char *buf, int buf_len,
void __scsi_print_command(unsigned char *cdb)
{
- int k, len;
+ int k, len, rem, linelen;
char cdb_str[64];
+ char line[16 * 3 + 1];
print_opcode_name(cdb_str, 64, cdb, 0);
- pr_info("%s", cdb_str);
len = scsi_command_size(cdb);
/* print out all bytes in cdb */
- for (k = 0; k < len; ++k)
- printk(" %02x", cdb[k]);
- printk("\n");
+ switch (len) {
+ case 6:
+ pr_info("%s %6ph\n", cdb_str, cdb);
+ break;
+ case 10:
+ pr_info("%s %10ph\n", cdb_str, cdb);
+ break;
+ case 12:
+ pr_info("%s %12ph\n", cdb_str, cdb);
+ break;
+ case 16:
+ pr_info("%s %16ph\n", cdb_str, cdb);
+ break;
+ default:
+ pr_info("%s\n", cdb_str);
+ rem = len;
+ for (k = 0; k < len; k += 16) {
+ linelen = min(rem, 16);
+ rem -= 16;
+
+ hex_dump_to_buffer(cdb + k, linelen, 16, 1,
+ line, sizeof(line), false);
+ pr_info("%s\n", line);
+ }
+ break;
+ }
}
EXPORT_SYMBOL(__scsi_print_command);
void scsi_print_command(struct scsi_cmnd *cmd)
{
- int k;
+ int k, rem, linelen;
char cdb_str[64];
+ char line[16 * 3 + 1];
if (cmd->cmnd == NULL)
return;
print_opcode_name(cdb_str, 64, cmd->cmnd, cmd->cmd_len);
- scmd_printk(KERN_INFO, cmd, "CDB: %s:", cdb_str);
/* print out all bytes in cdb */
- for (k = 0; k < cmd->cmd_len; ++k)
- printk(" %02x", cmd->cmnd[k]);
- printk("\n");
+ switch (cmd->cmd_len) {
+ case 6:
+ scmd_printk(KERN_INFO, cmd, "CDB: %s: %6ph\n",
+ cdb_str, cmd->cmnd);
+ break;
+ case 10:
+ scmd_printk(KERN_INFO, cmd, "CDB: %s: %10ph\n",
+ cdb_str, cmd->cmnd);
+ break;
+ case 12:
+ scmd_printk(KERN_INFO, cmd, "CDB: %s: %12ph\n",
+ cdb_str, cmd->cmnd);
+ break;
+ case 16:
+ scmd_printk(KERN_INFO, cmd, "CDB: %s: %16ph\n",
+ cdb_str, cmd->cmnd);
+ break;
+ default:
+ scmd_printk(KERN_INFO, cmd, "CDB: %s\n", cdb_str);
+ rem = cmd->cmd_len;
+ for (k = 0; k < cmd->cmd_len; k += 16) {
+ linelen = min(rem, 16);
+ rem -= 16;
+
+ hex_dump_to_buffer(cmd->cmnd + k, linelen, 16, 1,
+ line, sizeof(line), false);
+ scmd_printk(KERN_INFO, cmd, " %d: %s\n",
+ k, line);
+ }
+ break;
+ }
}
EXPORT_SYMBOL(scsi_print_command);
--
1.7.4.2
next prev parent reply other threads:[~2012-10-12 8:33 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 ` Hannes Reinecke [this message]
2012-10-12 8:33 ` [PATCH 07/10] scsi: use buffer for scsi_show_result() Hannes Reinecke
2012-10-12 8:33 ` [PATCH 08/10] scsi: open-code scsi_decode_sense_buffer() Hannes Reinecke
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-7-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).