Skip to content

Commit

Permalink
scsi: introduce sdev_prefix_printk()
Browse files Browse the repository at this point in the history
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 <[email protected]>
Reviewed-by: Robert Elliott <[email protected]>
Signed-off-by: Christoph Hellwig <[email protected]>
  • Loading branch information
hreinecke authored and Christoph Hellwig committed Nov 12, 2014
1 parent f75ae8e commit 22e0d99
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 11 deletions.
3 changes: 1 addition & 2 deletions drivers/scsi/ch.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 { \
Expand Down
6 changes: 3 additions & 3 deletions drivers/scsi/sd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 { \
Expand Down
4 changes: 2 additions & 2 deletions drivers/scsi/sg.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 1 addition & 2 deletions drivers/scsi/sr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);

Expand Down
3 changes: 1 addition & 2 deletions drivers/scsi/st.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 ); }
Expand Down
9 changes: 9 additions & 0 deletions include/scsi/scsi_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, \
Expand Down

0 comments on commit 22e0d99

Please sign in to comment.