From 360a9f542dc2eb7f07037b0a2ee988408bb665a8 Mon Sep 17 00:00:00 2001 From: Tzafrir Cohen Date: Sat, 20 Mar 2010 19:56:34 +0000 Subject: printk wrapper macros - first shot Add a number of printk-like macros to print messages for span and channel. I found them useful in the sysfs branch. The _dbg ones use the magical variable debug, and hence require the code to acknowledge that explicitly by defining DAHDI_PRINK_MACROS_USE_debug explicitly. git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@8354 a0bf4364-ded3-4de4-8d8a-66a801d63aff --- include/dahdi/kernel.h | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/include/dahdi/kernel.h b/include/dahdi/kernel.h index 0e98819..19378e4 100644 --- a/include/dahdi/kernel.h +++ b/include/dahdi/kernel.h @@ -1231,4 +1231,47 @@ wait_for_completion_timeout(struct completion *x, unsigned long timeout) #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) #endif +/* prink-wrapper macros */ +#define DAHDI_PRINTK(level, category, fmt, ...) \ + printk(KERN_ ## level "%s%s-%s: " fmt, #level, category, \ + THIS_MODULE->name, ## __VA_ARGS__) +#define span_printk(level, category, span, fmt, ...) \ + printk(KERN_ ## level "%s%s-%s: span-%d: " fmt, #level, \ + category, THIS_MODULE->name, (span)->spanno, ## __VA_ARGS__) +#define chan_printk(level, category, chan, fmt, ...) \ + printk(KERN_ ## level "%s%s-%s: %d: " fmt, #level, \ + category, THIS_MODULE->name, (chan)->channo, ## __VA_ARGS__) +#define dahdi_err(fmt, ...) DAHDI_PRINTK(ERR, "", fmt, ## __VA_ARGS__) +#define span_info(span, fmt, ...) span_printk(INFO, "", span, fmt, \ + ## __VA_ARGS__) +#define span_err(span, fmt, ...) span_printk(ERR, "", span, fmt, \ + ## __VA_ARGS__) +#define chan_err(chan, fmt, ...) chan_printk(ERR, "", chan, fmt, \ + ## __VA_ARGS__) + +/* The dbg_* ones use a magical variable 'debug' and the user should be + * aware of that. +*/ +#ifdef DAHDI_PRINK_MACROS_USE_debug +#ifndef BIT /* added in 2.6.24 */ +#define BIT(i) (1UL << (i)) +#endif +/* Standard debug bit values. Any module may define others. They must + * be of the form DAHDI_DBG_* + */ +#define DAHDI_DBG_GENERAL BIT(0) +#define DAHDI_DBG_DEVICES BIT(7) /* instantiation/destruction etc. */ +#define dahdi_dbg(bits, fmt, ...) \ + ((void)((debug & (DAHDI_DBG_ ## bits)) && DAHDI_PRINTK(DEBUG, \ + "-" #bits, "%s: " fmt, __func__, ## __VA_ARGS__))) +#define span_dbg(bits, span, fmt, ...) \ + ((void)((debug & (DAHDI_DBG_ ## bits)) && \ + span_printk(DEBUG, "-" #bits, span, "%s: " \ + fmt, __func__, ## __VA_ARGS__))) +#define chan_dbg(bits, chan, fmt, ...) \ + ((void)((debug & (DAHDI_DBG_ ## bits)) && \ + chan_printk(DEBUG, "-" #bits, chan, \ + "%s: " fmt, __func__, ## __VA_ARGS__))) +#endif /* DAHDI_PRINK_MACROS_USE_debug */ + #endif /* _DAHDI_KERNEL_H */ -- cgit v1.2.3