linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
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>, Jens Axboe <axboe@kernel.dk>
Subject: [PATCH 02/10] sr: Use dev_printk()
Date: Fri, 12 Oct 2012 10:33:42 +0200	[thread overview]
Message-ID: <1350030830-25614-3-git-send-email-hare@suse.de> (raw)
In-Reply-To: <1350030830-25614-1-git-send-email-hare@suse.de>

Convert sr to use dev_printk() to avoid linebreaks in kernel
messages.

Cc: Kay Sievers <kay@vrfy.org>
Cc: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Hannes Reinecke <hare@suse.de>
---
 drivers/scsi/sr.c |   47 ++++++++++++++++++++++++++---------------------
 drivers/scsi/sr.h |    4 ++++
 2 files changed, 30 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c
index 5fc97d2..26404ca 100644
--- a/drivers/scsi/sr.c
+++ b/drivers/scsi/sr.c
@@ -276,8 +276,8 @@ do_tur:
 	if (!cd->tur_changed) {
 		if (cd->get_event_changed) {
 			if (cd->tur_mismatch++ > 8) {
-				sdev_printk(KERN_WARNING, cd->device,
-					    "GET_EVENT and TUR disagree continuously, suppress GET_EVENT events\n");
+				sr_printk(KERN_WARNING, cd,
+					  "GET_EVENT and TUR disagree continuously, suppress GET_EVENT events\n");
 				cd->ignore_get_event = true;
 			}
 		} else {
@@ -306,7 +306,7 @@ static int sr_done(struct scsi_cmnd *SCpnt)
 	struct scsi_cd *cd = scsi_cd(SCpnt->request->rq_disk);
 
 #ifdef DEBUG
-	printk("sr.c done: %x\n", result);
+	sr_printk(KERN_INFO, cd, "sr.c done: %x\n", result);
 #endif
 
 	/*
@@ -389,13 +389,16 @@ static int sr_prep_fn(struct request_queue *q, struct request *rq)
 	 * is used for a killable error condition */
 	ret = BLKPREP_KILL;
 
-	SCSI_LOG_HLQUEUE(1, printk("Doing sr request, dev = %s, block = %d\n",
-				cd->disk->disk_name, block));
+	SCSI_LOG_HLQUEUE(1,
+		scmd_printk(KERN_INFO, SCpnt,
+			    "Doing sr request, block = %d\n", block));
 
 	if (!cd->device || !scsi_device_online(cd->device)) {
-		SCSI_LOG_HLQUEUE(2, printk("Finishing %u sectors\n",
-					   blk_rq_sectors(rq)));
-		SCSI_LOG_HLQUEUE(2, printk("Retry with 0x%p\n", SCpnt));
+		SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt,
+						"Finishing %u sectors\n",
+					      blk_rq_sectors(rq)));
+		SCSI_LOG_HLQUEUE(2, scmd_printk(KERN_INFO, SCpnt,
+						"Retry with 0x%p\n", SCpnt));
 		goto out;
 	}
 
@@ -416,7 +419,8 @@ static int sr_prep_fn(struct request_queue *q, struct request *rq)
 		if (!in_interrupt())
 			sr_set_blocklength(cd, 2048);
 		else
-			printk("sr: can't switch blocksize: in interrupt\n");
+			scmd_printk(KERN_INFO, SCpnt,
+				  "sr: can't switch blocksize: in interrupt\n");
 	}
 
 	if (s_size != 512 && s_size != 1024 && s_size != 2048) {
@@ -429,7 +433,7 @@ static int sr_prep_fn(struct request_queue *q, struct request *rq)
 			goto out;
 		SCpnt->cmnd[0] = WRITE_10;
 		SCpnt->sc_data_direction = DMA_TO_DEVICE;
- 	 	cd->cdi.media_written = 1;
+		cd->cdi.media_written = 1;
 	} else if (rq_data_dir(rq) == READ) {
 		SCpnt->cmnd[0] = READ_10;
 		SCpnt->sc_data_direction = DMA_FROM_DEVICE;
@@ -447,8 +451,8 @@ static int sr_prep_fn(struct request_queue *q, struct request *rq)
 
 		if (size != scsi_bufflen(SCpnt)) {
 			scmd_printk(KERN_ERR, SCpnt,
-				"mismatch count %d, bytes %d\n",
-				size, scsi_bufflen(SCpnt));
+				    "mismatch count %d, bytes %d\n",
+				    size, scsi_bufflen(SCpnt));
 			if (scsi_bufflen(SCpnt) > size)
 				SCpnt->sdb.length = size;
 		}
@@ -466,11 +470,11 @@ static int sr_prep_fn(struct request_queue *q, struct request *rq)
 	this_count = (scsi_bufflen(SCpnt) >> 9) / (s_size >> 9);
 
 
-	SCSI_LOG_HLQUEUE(2, printk("%s : %s %d/%u 512 byte blocks.\n",
-				cd->cdi.name,
-				(rq_data_dir(rq) == WRITE) ?
-					"writing" : "reading",
-				this_count, blk_rq_sectors(rq)));
+	SCSI_LOG_HLQUEUE(2, sr_printk(KERN_INFO, cd,
+				      "%s %d/%u 512 byte blocks.\n",
+				      (rq_data_dir(rq) == WRITE) ?
+				      "writing" : "reading",
+				      this_count, blk_rq_sectors(rq)));
 
 	SCpnt->cmnd[1] = 0;
 	block = (unsigned int)blk_rq_pos(rq) / (s_size >> 9);
@@ -790,8 +794,9 @@ static void get_sectorsize(struct scsi_cd *cd)
 		case 512:
 			break;
 		default:
-			printk("%s: unsupported sector size %d.\n",
-			       cd->cdi.name, sector_size);
+			sr_printk(KERN_INFO, cd,
+				  "unsupported sector size %d.\n",
+				  sector_size);
 			cd->capacity = 0;
 		}
 
@@ -852,7 +857,7 @@ static void get_capabilities(struct scsi_cd *cd)
 				 CDC_SELECT_DISC | CDC_SELECT_SPEED |
 				 CDC_MRW | CDC_MRW_W | CDC_RAM);
 		kfree(buffer);
-		printk("%s: scsi-1 drive\n", cd->cdi.name);
+		sr_printk(KERN_INFO, cd, "scsi-1 drive");
 		return;
 	}
 
@@ -861,7 +866,7 @@ static void get_capabilities(struct scsi_cd *cd)
 	cd->readcd_known = 1;
 	cd->readcd_cdda = buffer[n + 5] & 0x01;
 	/* print some capability bits */
-	printk("%s: scsi3-mmc drive: %dx/%dx %s%s%s%s%s%s\n", cd->cdi.name,
+	sr_printk(KERN_INFO, cd, "scsi3-mmc drive: %dx/%dx %s%s%s%s%s%s",
 	       ((buffer[n + 14] << 8) + buffer[n + 15]) / 176,
 	       cd->cdi.speed,
 	       buffer[n + 3] & 0x01 ? "writer " : "", /* CD Writer */
diff --git a/drivers/scsi/sr.h b/drivers/scsi/sr.h
index 37c8f6b..1610cac 100644
--- a/drivers/scsi/sr.h
+++ b/drivers/scsi/sr.h
@@ -55,6 +55,10 @@ typedef struct scsi_cd {
 	struct gendisk *disk;
 } Scsi_CD;
 
+#define sr_printk(prefix, scd, fmt, a...)				\
+	sdev_printk(prefix, (scd)->device, "[%s] " fmt,		\
+		    (scd)->cdi.name, ##a)
+
 int sr_do_ioctl(Scsi_CD *, struct packet_command *);
 
 int sr_lock_door(struct cdrom_device_info *, int);
-- 
1.7.4.2


  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 ` Hannes Reinecke [this message]
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 ` [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-3-git-send-email-hare@suse.de \
    --to=hare@suse.de \
    --cc=axboe@kernel.dk \
    --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).