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.
This commit is contained in:
adrian 2011-03-05 21:20:18 +00:00
parent de259f37cb
commit 3b8e8b2e31
2 changed files with 11 additions and 4 deletions

View File

@ -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;

View File

@ -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, ...)