From a69888384425b8d3e122396594a86e24cddad42a Mon Sep 17 00:00:00 2001 From: Vladislav Bolkhovitin Date: Wed, 10 Oct 2012 03:01:34 +0000 Subject: [PATCH] Switch to the new and preferred approach for printing kernel messages From: Bart Van Assche git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@4558 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- iscsi-scst/kernel/config.c | 12 +++++------ iscsi-scst/kernel/conn.c | 20 +++++++++--------- qla2x00t/qla2x_tgt.h | 2 +- scst/include/scst.h | 2 +- scst/include/scst_debug.h | 42 +++++++++++++++++++++++++++++++++++--- 5 files changed, 57 insertions(+), 21 deletions(-) diff --git a/iscsi-scst/kernel/config.c b/iscsi-scst/kernel/config.c index 74eb411d0..6996034c3 100644 --- a/iscsi-scst/kernel/config.c +++ b/iscsi-scst/kernel/config.c @@ -1223,26 +1223,26 @@ static void iscsi_dump_char(int ch, unsigned char *text, int *pos) if (ch < 0) { while ((i % 16) != 0) { - printk(KERN_CONT " "); + pr_cont(" "); text[i] = ' '; i++; if ((i % 16) == 0) - printk(KERN_CONT " | %.16s |\n", text); + pr_cont(" | %.16s |\n", text); else if ((i % 4) == 0) - printk(KERN_CONT " |"); + pr_cont(" |"); } i = 0; goto out; } text[i] = (ch < 0x20 || (ch >= 0x80 && ch <= 0xa0)) ? ' ' : ch; - printk(KERN_CONT " %02x", ch); + pr_cont(" %02x", ch); i++; if ((i % 16) == 0) { - printk(KERN_CONT " | %.16s |\n", text); + pr_cont(" | %.16s |\n", text); i = 0; } else if ((i % 4) == 0) - printk(KERN_CONT " |"); + pr_cont(" |"); out: *pos = i; diff --git a/iscsi-scst/kernel/conn.c b/iscsi-scst/kernel/conn.c index b414e5436..6ae2603d1 100644 --- a/iscsi-scst/kernel/conn.c +++ b/iscsi-scst/kernel/conn.c @@ -1007,13 +1007,13 @@ int __del_conn(struct iscsi_session *session, struct iscsi_kern_conn_info *info) void iscsi_extracheck_is_rd_thread(struct iscsi_conn *conn) { if (unlikely(current != conn->rd_task)) { - printk(KERN_EMERG "conn %p rd_task != current %p (pid %d)\n", - conn, current, current->pid); + pr_emerg("conn %p rd_task != current %p (pid %d)\n", + conn, current, current->pid); while (in_softirq()) local_bh_enable(); - printk(KERN_EMERG "rd_state %x\n", conn->rd_state); - printk(KERN_EMERG "rd_task %p\n", conn->rd_task); - printk(KERN_EMERG "rd_task->pid %d\n", conn->rd_task->pid); + pr_emerg("rd_state %x\n", conn->rd_state); + pr_emerg("rd_task %p\n", conn->rd_task); + pr_emerg("rd_task->pid %d\n", conn->rd_task->pid); BUG(); } } @@ -1021,13 +1021,13 @@ void iscsi_extracheck_is_rd_thread(struct iscsi_conn *conn) void iscsi_extracheck_is_wr_thread(struct iscsi_conn *conn) { if (unlikely(current != conn->wr_task)) { - printk(KERN_EMERG "conn %p wr_task != current %p (pid %d)\n", - conn, current, current->pid); + pr_emerg("conn %p wr_task != current %p (pid %d)\n", + conn, current, current->pid); while (in_softirq()) local_bh_enable(); - printk(KERN_EMERG "wr_state %x\n", conn->wr_state); - printk(KERN_EMERG "wr_task %p\n", conn->wr_task); - printk(KERN_EMERG "wr_task->pid %d\n", conn->wr_task->pid); + pr_emerg("wr_state %x\n", conn->wr_state); + pr_emerg("wr_task %p\n", conn->wr_task); + pr_emerg("wr_task->pid %d\n", conn->wr_task->pid); BUG(); } } diff --git a/qla2x00t/qla2x_tgt.h b/qla2x00t/qla2x_tgt.h index f7b5b59ac..b17afb44b 100644 --- a/qla2x00t/qla2x_tgt.h +++ b/qla2x00t/qla2x_tgt.h @@ -103,7 +103,7 @@ __qla2x00_send_enable_lun(scsi_qla_host_t *ha, int enable) qla_clear_tgt_mode(ha); #if defined(QL_DEBUG_LEVEL_2) || defined(QL_DEBUG_LEVEL_3) if (!pkt) - printk(KERN_ERR "%s: **** FAILED ****\n", __func__); + pr_err("%s: **** FAILED ****\n", __func__); #endif return; diff --git a/scst/include/scst.h b/scst/include/scst.h index df49db3e4..1cb370e6e 100644 --- a/scst/include/scst.h +++ b/scst/include/scst.h @@ -3039,7 +3039,7 @@ static inline bool scst_cmd_atomic(struct scst_cmd *cmd) */ if (unlikely((in_atomic() || in_interrupt() || irqs_disabled()) && !res)) { - printk(KERN_ERR "ERROR: atomic context and non-atomic cmd!\n"); + pr_err("ERROR: atomic context and non-atomic cmd!\n"); dump_stack(); cmd->atomic = 1; res = 1; diff --git a/scst/include/scst_debug.h b/scst/include/scst_debug.h index 6b4057507..467604dd4 100644 --- a/scst/include/scst_debug.h +++ b/scst/include/scst_debug.h @@ -32,11 +32,47 @@ #include /* for WARN_ON_ONCE */ #endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 28) +/* + * See also the following commits: + * d091c2f5 - Introduction of pr_info() etc. in . + * 311d0761 - Introduction of pr_cont() in . + * 968ab183 - Moved pr_info() etc. from to + */ +#ifndef pr_info +#ifndef pr_fmt +#define pr_fmt(fmt) fmt +#endif + +#define pr_emerg(fmt, ...) \ + printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) +#define pr_alert(fmt, ...) \ + printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) +#define pr_crit(fmt, ...) \ + printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) +#define pr_err(fmt, ...) \ + printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) +#define pr_warning(fmt, ...) \ + printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) +#define pr_warn pr_warning +#define pr_notice(fmt, ...) \ + printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) +#define pr_info(fmt, ...) \ + printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) +#endif +#endif +#if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 30) +#ifndef pr_cont +#define pr_cont(fmt, ...) \ + printk(KERN_CONT fmt, ##__VA_ARGS__) +#endif +#endif + #if !defined(INSIDE_KERNEL_TREE) #ifdef CONFIG_SCST_DEBUG #define sBUG() do { \ - printk(KERN_CRIT "BUG at %s:%d\n", __FILE__, __LINE__); \ + pr_crit("BUG at %s:%d\n", __FILE__, __LINE__); \ local_irq_enable(); \ while (in_softirq()) \ local_bh_enable(); \ @@ -45,8 +81,8 @@ #define sBUG_ON(p) do { \ if (unlikely(p)) { \ - printk(KERN_CRIT "BUG at %s:%d (%s)\n", \ - __FILE__, __LINE__, #p); \ + pr_crit("BUG at %s:%d (%s)\n", \ + __FILE__, __LINE__, #p); \ local_irq_enable(); \ while (in_softirq()) \ local_bh_enable(); \