scsi: introduce sdev_prefix_printk()
authorHannes Reinecke <hare@suse.de>
Fri, 24 Oct 2014 12:26:44 +0000 (14:26 +0200)
committerChristoph Hellwig <hch@lst.de>
Wed, 12 Nov 2014 10:15:57 +0000 (11:15 +0100)
Like scmd_printk(), but the device name is passed in as
a string. Can be used by eg ULDs which do not have access
to the scsi_cmnd structure.

Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Robert Elliott <elliott@hp.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
drivers/scsi/ch.c
drivers/scsi/sd.h
drivers/scsi/sg.c
drivers/scsi/sr.h
drivers/scsi/st.c
include/scsi/scsi_device.h

index ef5ae0d0361676af1afee8e86b709ec5cabf7000..52060e72b75d8a2b1a3090569ecd47ad84177a40 100644 (file)
@@ -85,8 +85,7 @@ static const char * vendor_labels[CH_TYPES-4] = {
 // module_param_string_array(vendor_labels, NULL, 0444);
 
 #define ch_printk(prefix, ch, fmt, a...) \
-       sdev_printk(prefix, (ch)->device, "[%s] " fmt, \
-                   (ch)->name, ##a)
+       sdev_prefix_printk(prefix, (ch)->device, (ch)->name, fmt, ##a)
 
 #define DPRINTK(fmt, arg...)                                           \
 do {                                                                   \
index 467377884b63ffbc55bdeb23e592b3aabfd8a20d..63ba5ca7f9a16b21735c1283c2a17df40a7ee06c 100644 (file)
@@ -103,9 +103,9 @@ static inline struct scsi_disk *scsi_disk(struct gendisk *disk)
 
 #define sd_printk(prefix, sdsk, fmt, a...)                             \
         (sdsk)->disk ?                                                 \
-       sdev_printk(prefix, (sdsk)->device, "[%s] " fmt,                \
-                   (sdsk)->disk->disk_name, ##a) :                     \
-       sdev_printk(prefix, (sdsk)->device, fmt, ##a)
+             sdev_prefix_printk(prefix, (sdsk)->device,                \
+                                (sdsk)->disk->disk_name, fmt, ##a) :   \
+             sdev_printk(prefix, (sdsk)->device, fmt, ##a)
 
 #define sd_first_printk(prefix, sdsk, fmt, a...)                       \
        do {                                                            \
index fe44c14f551e6044f73514d04d6557dbdc1c595a..55cbc6689d2780bb8c4d0e2ca4da94f6ccc3f76f 100644 (file)
@@ -219,8 +219,8 @@ static void sg_device_destroy(struct kref *kref);
 #define SZ_SG_REQ_INFO sizeof(sg_req_info_t)
 
 #define sg_printk(prefix, sdp, fmt, a...) \
-       sdev_printk(prefix, (sdp)->device, "[%s] " fmt, \
-                   (sdp)->disk->disk_name, ##a)
+       sdev_prefix_printk(prefix, (sdp)->device,               \
+                          (sdp)->disk->disk_name, fmt, ##a)
 
 static int sg_allow_access(struct file *filp, unsigned char *cmd)
 {
index 1d1f6f416c593daeb888283be777e4a7a3528b7b..1de33719ad8ef32c7042e2e59fd3c310973f7896 100644 (file)
@@ -57,8 +57,7 @@ typedef struct scsi_cd {
 } Scsi_CD;
 
 #define sr_printk(prefix, cd, fmt, a...) \
-       sdev_printk(prefix, (cd)->device, "[%s] " fmt, \
-                   (cd)->cdi.name, ##a)
+       sdev_prefix_printk(prefix, (cd)->device, (cd)->cdi.name, fmt, ##a)
 
 int sr_do_ioctl(Scsi_CD *, struct packet_command *);
 
index 8d5f8b4f9a22dcb476eb615e7b30eb29798124cf..36ab023793ca1e0c57f24fbe3b301326c77cf34b 100644 (file)
@@ -314,8 +314,7 @@ static inline char *tape_name(struct scsi_tape *tape)
 }
 
 #define st_printk(prefix, t, fmt, a...) \
-       sdev_printk(prefix, (t)->device, "%s: " fmt, \
-                   tape_name(t), ##a)
+       sdev_prefix_printk(prefix, (t)->device, tape_name(t), fmt, ##a)
 #ifdef DEBUG
 #define DEBC_printk(t, fmt, a...) \
        if (debugging) { st_printk(ST_DEB_MSG, t, fmt, ##a ); }
index 27ecee73bd72b35b6ad0029686a278ec3ae26de4..0b18a097c1ba953a14940a22354731f8f94426fd 100644 (file)
@@ -244,6 +244,15 @@ struct scsi_dh_data {
 #define sdev_dbg(sdev, fmt, a...) \
        dev_dbg(&(sdev)->sdev_gendev, fmt, ##a)
 
+/*
+ * like scmd_printk, but the device name is passed in
+ * as a string pointer
+ */
+#define sdev_prefix_printk(l, sdev, p, fmt, a...)                      \
+       (p) ?                                                           \
+       sdev_printk(l, sdev, "[%s] " fmt, p, ##a) :                     \
+       sdev_printk(l, sdev, fmt, ##a)
+
 #define scmd_printk(prefix, scmd, fmt, a...)                           \
         (scmd)->request->rq_disk ?                                     \
        sdev_printk(prefix, (scmd)->device, "[%s] " fmt,                \