[zaptel-commits] tzafrir: branch tzafrir/sysfs r2827 - /team/tzafrir/sysfs/zap_dbg.h
SVN commits to the Zaptel project
zaptel-commits at lists.digium.com
Mon Aug 6 23:06:28 CDT 2007
Author: tzafrir
Date: Mon Aug 6 23:06:27 2007
New Revision: 2827
URL: http://svn.digium.com/view/zaptel?view=rev&rev=2827
Log:
Start by getting some nice debug macros. Adapt the ones from xpp.
Added:
team/tzafrir/sysfs/zap_dbg.h
- copied, changed from r2826, team/tzafrir/sysfs/xpp/zap_debug.h
Copied: team/tzafrir/sysfs/zap_dbg.h (from r2826, team/tzafrir/sysfs/xpp/zap_debug.h)
URL: http://svn.digium.com/view/zaptel/team/tzafrir/sysfs/zap_dbg.h?view=diff&rev=2827&p1=team/tzafrir/sysfs/xpp/zap_debug.h&r1=2826&p2=team/tzafrir/sysfs/zap_dbg.h&r2=2827
==============================================================================
--- team/tzafrir/sysfs/xpp/zap_debug.h (original)
+++ team/tzafrir/sysfs/zap_dbg.h Mon Aug 6 23:06:27 2007
@@ -1,8 +1,8 @@
-#ifndef ZAP_DEBUG_H
-#define ZAP_DEBUG_H
+#ifndef ZAP_DBG_H
+#define ZAP_DBG_H
/*
* Written by Oron Peled <oron at actcom.co.il>
- * Copyright (C) 2004-2006, Xorcom
+ * Copyright (C) 2004-2007, Xorcom
*
* All rights reserved.
*
@@ -24,140 +24,35 @@
/* Debugging Macros */
-#define PRINTK(level, fmt, ...) \
+#define zap_printk(level, fmt, ...) \
printk(KERN_ ## level "%s-%s: " fmt, #level, THIS_MODULE->name, ## __VA_ARGS__)
-#define XBUS_PRINTK(level, xbus, fmt, ...) \
+#define zap_printk_span(level, span, fmt, ...) \
printk(KERN_ ## level "%s-%s: %s: " fmt, #level, \
- THIS_MODULE->name, (xbus)->busname, ## __VA_ARGS__)
+ THIS_MODULE->name, (span)->name, ## __VA_ARGS__)
-#define XPD_PRINTK(level, xpd, fmt, ...) \
+#define zap_printk_chan(level, chan, fmt, ...) \
printk(KERN_ ## level "%s-%s: %s/%s: " fmt, #level, \
- THIS_MODULE->name, (xpd)->xbus->busname, (xpd)->xpdname, ## __VA_ARGS__)
+ THIS_MODULE->name, (chan)->span->name, (xpd)->xpdname, ## __VA_ARGS__)
-#define LINE_PRINTK(level, xpd, pos, fmt, ...) \
- printk(KERN_ ## level "%s-%s: %s/%s/%d: " fmt, #level, \
- THIS_MODULE->name, (xpd)->xbus->busname, (xpd)->xpdname, (pos), ## __VA_ARGS__)
+#define zap_dbg(fmt, ...) \
+ ((void)((print_dbg) && zap_printk(DEBUG, "%s: " fmt, __FUNCTION__, ## __VA_ARGS__)))
+#define zap_info(fmt, ...) zap_printk(INFO, fmt, ## __VA_ARGS__)
+#define zap_notice(fmt, ...) zap_printk(NOTICE, fmt, ## __VA_ARGS__)
+#define zap_warn(fmt, ...) zap_printk(WARNING, fmt, ## __VA_ARGS__)
+#define zap_err(fmt, ...) zap_printk(ERR, fmt, ## __VA_ARGS__)
-#define DBG(fmt, ...) \
- ((void)((print_dbg) && PRINTK(DEBUG, "%s: " fmt, __FUNCTION__, ## __VA_ARGS__)))
-#define INFO(fmt, ...) PRINTK(INFO, fmt, ## __VA_ARGS__)
-#define NOTICE(fmt, ...) PRINTK(NOTICE, fmt, ## __VA_ARGS__)
-#define WARNING(fmt, ...) PRINTK(WARNING, fmt, ## __VA_ARGS__)
-#define ERR(fmt, ...) PRINTK(ERR, fmt, ## __VA_ARGS__)
+#define zap_dbg_span(span, fmt, ...) \
+ ((void)((print_dbg) && zap_printk_span(DEBUG, span, "%s: " fmt, __FUNCTION__, ## __VA_ARGS__)))
+#define zap_info_span(span, fmt, ...) zap_printk_span(INFO, span, fmt, ## __VA_ARGS__)
+#define zap_notice_span(span, fmt, ...) zap_printk_span(NOTICE, span, fmt, ## __VA_ARGS__)
+#define zap_err_span(span, fmt, ...) zap_printk_span(ERR, span, fmt, ## __VA_ARGS__)
-#define XBUS_DBG(xbus, fmt, ...) \
- ((void)((print_dbg) && XBUS_PRINTK(DEBUG, xbus, "%s: " fmt, __FUNCTION__, ## __VA_ARGS__)))
-#define XBUS_INFO(xbus, fmt, ...) XBUS_PRINTK(INFO, xbus, fmt, ## __VA_ARGS__)
-#define XBUS_NOTICE(xbus, fmt, ...) XBUS_PRINTK(NOTICE, xbus, fmt, ## __VA_ARGS__)
-#define XBUS_ERR(xbus, fmt, ...) XBUS_PRINTK(ERR, xbus, fmt, ## __VA_ARGS__)
+#define zap_dbg_chan(xpd, fmt, ...) \
+ ((void)((print_dbg) && zap_printk_chan(DEBUG, chan, "%s: " fmt, __FUNCTION__, ## __VA_ARGS__)))
+#define zap_info_chan(chan, fmt, ...) zap_printk_chan(INFO, chan, fmt, ## __VA_ARGS__)
+#define zap_notice_chan(chan, fmt, ...) zap_printk_chan(NOTICE, chan, fmt, ## __VA_ARGS__)
+#define zap_warn_chan(chan, fmt, ...) zap_printk_chan(WARNING, chan, fmt, ## __VA_ARGS__)
+#define zap_err_chan(chan, fmt, ...) zap_printk_chan(ERR, chan, fmt, ## __VA_ARGS__)
-#define XPD_DBG(xpd, fmt, ...) \
- ((void)((print_dbg) && XPD_PRINTK(DEBUG, xpd, "%s: " fmt, __FUNCTION__, ## __VA_ARGS__)))
-#define XPD_INFO(xpd, fmt, ...) XPD_PRINTK(INFO, xpd, fmt, ## __VA_ARGS__)
-#define XPD_NOTICE(xpd, fmt, ...) XPD_PRINTK(NOTICE, xpd, fmt, ## __VA_ARGS__)
-#define XPD_WARNING(xpd, fmt, ...) XPD_PRINTK(WARNING, xpd, fmt, ## __VA_ARGS__)
-#define XPD_ERR(xpd, fmt, ...) XPD_PRINTK(ERR, xpd, fmt, ## __VA_ARGS__)
-
-#define LINE_DBG(xpd, pos, fmt, ...) \
- ((void)((print_dbg) && LINE_PRINTK(DEBUG, xpd, pos, "%s: " fmt, __FUNCTION__, ## __VA_ARGS__)))
-#define LINE_NOTICE(xpd, pos, fmt, ...) LINE_PRINTK(NOTICE, xpd, pos, fmt, ## __VA_ARGS__)
-
-/*
- * Bits for print_dbg
- */
-#define DBG_DEFAULT 0x01
-#define DBG_PCM 0x02
-
-void dump_poll(int print_dbg, const char *msg, int poll);
-
-static inline char *rxsig2str(zt_rxsig_t sig)
-{
- switch(sig) {
- case ZT_RXSIG_ONHOOK: return "ONHOOK";
- case ZT_RXSIG_OFFHOOK: return "OFFHOOK";
- case ZT_RXSIG_START: return "START";
- case ZT_RXSIG_RING: return "RING";
- case ZT_RXSIG_INITIAL: return "INITIAL";
- }
- return "Unknown rxsig";
-}
-
-static inline char *txsig2str(zt_txsig_t sig)
-{
- switch(sig) {
- case ZT_TXSIG_ONHOOK: return "TXSIG_ONHOOK";
- case ZT_TXSIG_OFFHOOK: return "TXSIG_OFFHOOK";
- case ZT_TXSIG_START: return "TXSIG_START";
- case ZT_TXSIG_KEWL: return "TXSIG_KEWL"; /* Drop battery if possible */
- }
- return "Unknown txsig";
-}
-
-static inline char *event2str(int event)
-{
- switch(event) {
- case ZT_EVENT_NONE: return "NONE";
- case ZT_EVENT_ONHOOK: return "ONHOOK";
- case ZT_EVENT_RINGOFFHOOK: return "RINGOFFHOOK";
- case ZT_EVENT_WINKFLASH: return "WINKFLASH";
- case ZT_EVENT_ALARM: return "ALARM";
- case ZT_EVENT_NOALARM: return "NOALARM";
- case ZT_EVENT_ABORT: return "ABORT";
- case ZT_EVENT_OVERRUN: return "OVERRUN";
- case ZT_EVENT_BADFCS: return "BADFCS";
- case ZT_EVENT_DIALCOMPLETE: return "DIALCOMPLETE";
- case ZT_EVENT_RINGERON: return "RINGERON";
- case ZT_EVENT_RINGEROFF: return "RINGEROFF";
- case ZT_EVENT_HOOKCOMPLETE: return "HOOKCOMPLETE";
- case ZT_EVENT_BITSCHANGED: return "BITSCHANGED";
- case ZT_EVENT_PULSE_START: return "PULSE_START";
- case ZT_EVENT_TIMER_EXPIRED: return "TIMER_EXPIRED";
- case ZT_EVENT_TIMER_PING: return "TIMER_PING";
- case ZT_EVENT_POLARITY: return "POLARITY";
- }
- return "Unknown event";
-}
-
-static inline char *hookstate2str(int hookstate)
-{
- switch(hookstate) {
- case ZT_ONHOOK: return "ZT_ONHOOK";
- case ZT_START: return "ZT_START";
- case ZT_OFFHOOK: return "ZT_OFFHOOK";
- case ZT_WINK: return "ZT_WINK";
- case ZT_FLASH: return "ZT_FLASH";
- case ZT_RING: return "ZT_RING";
- case ZT_RINGOFF: return "ZT_RINGOFF";
- }
- return "Unknown hookstate";
-}
-
-/* From zaptel.c */
-static inline char *sig2str(int sig)
-{
- switch (sig) {
- case ZT_SIG_FXSLS: return "FXSLS";
- case ZT_SIG_FXSKS: return "FXSKS";
- case ZT_SIG_FXSGS: return "FXSGS";
- case ZT_SIG_FXOLS: return "FXOLS";
- case ZT_SIG_FXOKS: return "FXOKS";
- case ZT_SIG_FXOGS: return "FXOGS";
- case ZT_SIG_EM: return "E&M";
- case ZT_SIG_EM_E1: return "E&M-E1";
- case ZT_SIG_CLEAR: return "Clear";
- case ZT_SIG_HDLCRAW: return "HDLCRAW";
- case ZT_SIG_HDLCFCS: return "HDLCFCS";
- case ZT_SIG_HDLCNET: return "HDLCNET";
- case ZT_SIG_SLAVE: return "Slave";
- case ZT_SIG_CAS: return "CAS";
- case ZT_SIG_DACS: return "DACS";
- case ZT_SIG_DACS_RBS: return "DACS+RBS";
- case ZT_SIG_SF: return "SF (ToneOnly)";
- case ZT_SIG_NONE:
- break;
- }
- return "Unconfigured";
-}
-
-#endif /* ZAP_DEBUG_H */
+#endif /* ZAP_DBG_H */
More information about the zaptel-commits
mailing list