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 07/10] scsi: use buffer for scsi_show_result()
Date: Fri, 12 Oct 2012 10:33:47 +0200 [thread overview]
Message-ID: <1350030830-25614-8-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1350030830-25614-1-git-send-email-hare@suse.de>
scsi_show_result() should be printing the message into a supplied
buffer to avoid linebreaks during output.
Cc: Kay Sievers <kay@vrfy.org>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
drivers/scsi/constants.c | 23 +++++++++++++----------
drivers/scsi/sd.c | 6 ++++--
include/scsi/scsi_dbg.h | 2 +-
3 files changed, 18 insertions(+), 13 deletions(-)
diff --git a/drivers/scsi/constants.c b/drivers/scsi/constants.c
index 65367e8..ded16d9 100644
--- a/drivers/scsi/constants.c
+++ b/drivers/scsi/constants.c
@@ -1502,32 +1502,35 @@ static const char * const driverbyte_table[]={
"DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD", "DRIVER_SENSE"};
#define NUM_DRIVERBYTE_STRS ARRAY_SIZE(driverbyte_table)
-void scsi_show_result(int result)
+void scsi_show_result(char *buf, int buf_size, int result)
{
int hb = host_byte(result);
int db = driver_byte(result);
- printk("Result: hostbyte=%s driverbyte=%s\n",
- (hb < NUM_HOSTBYTE_STRS ? hostbyte_table[hb] : "invalid"),
- (db < NUM_DRIVERBYTE_STRS ? driverbyte_table[db] : "invalid"));
+ snprintf(buf, buf_size,
+ "Result: hostbyte=%s driverbyte=%s\n",
+ (hb < NUM_HOSTBYTE_STRS ? hostbyte_table[hb] : "invalid"),
+ (db < NUM_DRIVERBYTE_STRS ? driverbyte_table[db] : "invalid"));
}
#else
-void scsi_show_result(int result)
+void scsi_show_result(char *buf, int buf_size, int result)
{
- printk("Result: hostbyte=0x%02x driverbyte=0x%02x\n",
- host_byte(result), driver_byte(result));
+ snprintf(buf, buf_size,
+ "Result: hostbyte=0x%02x driverbyte=0x%02x\n",
+ host_byte(result), driver_byte(result));
}
#endif
EXPORT_SYMBOL(scsi_show_result);
-
void scsi_print_result(struct scsi_cmnd *cmd)
{
- scmd_printk(KERN_INFO, cmd, " ");
- scsi_show_result(cmd->result);
+ char result_buf[70];
+
+ scsi_show_result(result_buf, 70, cmd->result);
+ scmd_printk(KERN_INFO, cmd, "%s", result_buf);
}
EXPORT_SYMBOL(scsi_print_result);
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 12f6fdf..f6165e6 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -3025,7 +3025,9 @@ static void sd_print_sense_hdr(struct scsi_disk *sdkp,
static void sd_print_result(struct scsi_disk *sdkp, int result)
{
- sd_printk(KERN_INFO, sdkp, " ");
- scsi_show_result(result);
+ char result_buf[70];
+
+ scsi_show_result(result_buf, 70, result);
+ sd_printk(KERN_INFO, sdkp, "%s", result_buf);
}
diff --git a/include/scsi/scsi_dbg.h b/include/scsi/scsi_dbg.h
index e89844c..cc6abb4 100644
--- a/include/scsi/scsi_dbg.h
+++ b/include/scsi/scsi_dbg.h
@@ -15,7 +15,7 @@ extern void scsi_print_sense(char *, struct scsi_cmnd *);
extern void __scsi_print_sense(const char *name,
const unsigned char *sense_buffer,
int sense_len);
-extern void scsi_show_result(int);
+extern void scsi_show_result(char *, int, int);
extern void scsi_print_result(struct scsi_cmnd *);
extern void scsi_print_status(unsigned char);
extern const char *scsi_sense_key_string(unsigned char);
--
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 ` Hannes Reinecke [this message]
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-8-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).