diff options
author | adrian <adrian@FreeBSD.org> | 2011-03-05 21:20:18 +0000 |
---|---|---|
committer | adrian <adrian@FreeBSD.org> | 2011-03-05 21:20:18 +0000 |
commit | 3b8e8b2e3136f809f5a78af99a2dee2f5687e84a (patch) | |
tree | 9ab5175c3a13e8a187e341ea36e22efc6eb35447 | |
parent | de259f37cb31240cbd58da707d68faf712d77bb3 (diff) | |
download | FreeBSD-src-3b8e8b2e3136f809f5a78af99a2dee2f5687e84a.zip FreeBSD-src-3b8e8b2e3136f809f5a78af99a2dee2f5687e84a.tar.gz |
Change HALDEBUG() to be a macro that conditionally calls the debug output routine.
The earlier way of doing debugging would evaluate the function parameters
before calling the HALDEBUG. In the case of detailed register debugging
would mean a -lot- of unneeded register IO and other stuff was going on.
This method evaluates the ath_hal_debug variable before the function
parameters are evaluated, drastically reducing the amount of overhead
enabling HAL debugging during compilation.
-rw-r--r-- | sys/dev/ath/ah_osdep.c | 6 | ||||
-rw-r--r-- | sys/dev/ath/ath_hal/ah_internal.h | 9 |
2 files changed, 11 insertions, 4 deletions
diff --git a/sys/dev/ath/ah_osdep.c b/sys/dev/ath/ah_osdep.c index 6b11b21..2cd6c97 100644 --- a/sys/dev/ath/ah_osdep.c +++ b/sys/dev/ath/ah_osdep.c @@ -71,7 +71,7 @@ extern void ath_hal_assert_failed(const char* filename, int lineno, const char* msg); #endif #ifdef AH_DEBUG -extern void HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...); +extern void DO_HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...); #endif /* AH_DEBUG */ /* NB: put this here instead of the driver to avoid circular references */ @@ -79,7 +79,7 @@ SYSCTL_NODE(_hw, OID_AUTO, ath, CTLFLAG_RD, 0, "Atheros driver parameters"); SYSCTL_NODE(_hw_ath, OID_AUTO, hal, CTLFLAG_RD, 0, "Atheros HAL parameters"); #ifdef AH_DEBUG -static int ath_hal_debug = 0; +int ath_hal_debug = 0; SYSCTL_INT(_hw_ath_hal, OID_AUTO, debug, CTLFLAG_RW, &ath_hal_debug, 0, "Atheros HAL debugging printfs"); TUNABLE_INT("hw.ath.hal.debug", &ath_hal_debug); @@ -136,7 +136,7 @@ ath_hal_ether_sprintf(const u_int8_t *mac) #ifdef AH_DEBUG void -HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...) +DO_HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...) { if (ath_hal_debug & mask) { __va_list ap; diff --git a/sys/dev/ath/ath_hal/ah_internal.h b/sys/dev/ath/ath_hal/ah_internal.h index 2ddb2b4..bd66b1d 100644 --- a/sys/dev/ath/ath_hal/ah_internal.h +++ b/sys/dev/ath/ath_hal/ah_internal.h @@ -501,7 +501,14 @@ extern void ath_hal_free(void *); #ifdef AH_DEBUG #include "ah_debug.h" extern int ath_hal_debug; -extern void HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...) +#define HALDEBUG(_ah, __m, ...) \ + do { \ + if (ath_hal_debug & (__m)) { \ + DO_HALDEBUG((_ah), (__m), __VA_ARGS__); \ + } \ + } while(0); + +extern void DO_HALDEBUG(struct ath_hal *ah, u_int mask, const char* fmt, ...) __printflike(3,4); #else #define HALDEBUG(_ah, __m, _fmt, ...) |