In order for end users to quickly react to new issues that come up in production, it is proving useful to leverage the printk indexing system. This printk index enables kernel developers to use calls to printk() with changable ad-hoc format strings, while still enabling end users to detect changes and develop a semi-stable interface for detecting and parsing these messages. So that detailed SCSI driver messages are captured by this printk index, this patch wraps sdev_prefix_printk with a macro. Signed-off-by: Jonathan Lassoff <jof@xxxxxxxxxx> --- drivers/scsi/scsi_logging.c | 7 ++++--- include/scsi/scsi_device.h | 8 +++++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/scsi_logging.c b/drivers/scsi/scsi_logging.c index 1f8f80b2dbfc..62aae95fc80f 100644 --- a/drivers/scsi/scsi_logging.c +++ b/drivers/scsi/scsi_logging.c @@ -53,7 +53,8 @@ static size_t sdev_format_header(char *logbuf, size_t logbuf_len, return off; } -void sdev_prefix_printk(const char *level, const struct scsi_device *sdev, + +void _sdev_prefix_printk(const char *level, const struct scsi_device *sdev, const char *name, const char *fmt, ...) { va_list args; @@ -75,10 +76,10 @@ void sdev_prefix_printk(const char *level, const struct scsi_device *sdev, off += vscnprintf(logbuf + off, logbuf_len - off, fmt, args); va_end(args); } - dev_printk(level, &sdev->sdev_gendev, "%s", logbuf); + _dev_printk(level, &sdev->sdev_gendev, "%s", logbuf); scsi_log_release_buffer(logbuf); } -EXPORT_SYMBOL(sdev_prefix_printk); +EXPORT_SYMBOL(_sdev_prefix_printk); void scmd_printk(const char *level, const struct scsi_cmnd *scmd, const char *fmt, ...) diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 647c53b26105..59a1087107ed 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -262,9 +262,15 @@ struct scsi_device { * as a string pointer */ __printf(4, 5) void -sdev_prefix_printk(const char *, const struct scsi_device *, const char *, +_sdev_prefix_printk(const char *, const struct scsi_device *, const char *, const char *, ...); +#define sdev_prefix_printk(level, sdev, name, fmt, ...) \ +({ \ + printk_index_subsys_emit("%s %s: [%s] ", level, fmt); \ + _sdev_prefix_printk(level, sdev, name, fmt, ##__VA_ARGS__); \ +}) + #define sdev_printk(l, sdev, fmt, a...) \ sdev_prefix_printk(l, sdev, NULL, fmt, ##a) -- 2.35.1