1*0062f2f2Smatt /* $NetBSD: ralink_debug.h,v 1.2 2011/07/28 15:38:49 matt Exp $ */ 2*0062f2f2Smatt /*- 3*0062f2f2Smatt * Copyright (c) 2011 CradlePoint Technology, Inc. 4*0062f2f2Smatt * All rights reserved. 5*0062f2f2Smatt * 6*0062f2f2Smatt * 7*0062f2f2Smatt * Redistribution and use in source and binary forms, with or without 8*0062f2f2Smatt * modification, are permitted provided that the following conditions 9*0062f2f2Smatt * are met: 10*0062f2f2Smatt * 1. Redistributions of source code must retain the above copyright 11*0062f2f2Smatt * notice, this list of conditions and the following disclaimer. 12*0062f2f2Smatt * 2. Redistributions in binary form must reproduce the above copyright 13*0062f2f2Smatt * notice, this list of conditions and the following disclaimer in the 14*0062f2f2Smatt * documentation and/or other materials provided with the distribution. 15*0062f2f2Smatt * 16*0062f2f2Smatt * THIS SOFTWARE IS PROVIDED BY CRADLEPOINT TECHNOLOGY, INC. AND CONTRIBUTORS 17*0062f2f2Smatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 18*0062f2f2Smatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 19*0062f2f2Smatt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS 20*0062f2f2Smatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 21*0062f2f2Smatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 22*0062f2f2Smatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 23*0062f2f2Smatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 24*0062f2f2Smatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 25*0062f2f2Smatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 26*0062f2f2Smatt * POSSIBILITY OF SUCH DAMAGE. 27*0062f2f2Smatt */ 28*0062f2f2Smatt 29*0062f2f2Smatt #ifndef _RALINK_DEBUG_H_ 30*0062f2f2Smatt #define _RALINK_DEBUG_H_ 31*0062f2f2Smatt 32*0062f2f2Smatt /* Co-locate some debug routines to help keep the code clean. 33*0062f2f2Smatt * #define one or more ENABLE_RALINK_DEBUG_xxxx macros before including 34*0062f2f2Smatt * this file to turn on macros. If none are defined the debug code 35*0062f2f2Smatt * won't be compiled in. 36*0062f2f2Smatt */ 37*0062f2f2Smatt 38*0062f2f2Smatt /* 39*0062f2f2Smatt * High-level debug compile flag. If this isn't defined, this is 40*0062f2f2Smatt * a release build. 41*0062f2f2Smatt */ 42*0062f2f2Smatt 43*0062f2f2Smatt /* Debugging options */ 44*0062f2f2Smatt #ifndef ENABLE_RALINK_DEBUG_ERROR 45*0062f2f2Smatt #define ENABLE_RALINK_DEBUG_ERROR 0 46*0062f2f2Smatt #endif 47*0062f2f2Smatt #ifndef ENABLE_RALINK_DEBUG_FUNC 48*0062f2f2Smatt #define ENABLE_RALINK_DEBUG_FUNC 0 49*0062f2f2Smatt #endif 50*0062f2f2Smatt #ifndef ENABLE_RALINK_DEBUG_MISC 51*0062f2f2Smatt #define ENABLE_RALINK_DEBUG_MISC 0 52*0062f2f2Smatt #endif 53*0062f2f2Smatt #ifndef ENABLE_RALINK_DEBUG_INFO 54*0062f2f2Smatt #define ENABLE_RALINK_DEBUG_INFO 0 55*0062f2f2Smatt #endif 56*0062f2f2Smatt #ifndef ENABLE_RALINK_DEBUG_REG 57*0062f2f2Smatt #define ENABLE_RALINK_DEBUG_REG 0 58*0062f2f2Smatt #endif 59*0062f2f2Smatt /* don't check anything in with this option. Just use this if you want to 60*0062f2f2Smatt * force a specific statement and the above options don't give you fine enough 61*0062f2f2Smatt * control. 62*0062f2f2Smatt */ 63*0062f2f2Smatt #ifndef ENABLE_RALINK_DEBUG_FORCE 64*0062f2f2Smatt #define ENABLE_RALINK_DEBUG_FORCE 0 65*0062f2f2Smatt #endif 66*0062f2f2Smatt 67*0062f2f2Smatt #define RALINK_DEBUG_ERROR ((ENABLE_RALINK_DEBUG_ERROR ? 1 : 0) << 0) 68*0062f2f2Smatt #define RALINK_DEBUG_MISC ((ENABLE_RALINK_DEBUG_MISC ? 1 : 0) << 1) 69*0062f2f2Smatt #define RALINK_DEBUG_FUNC ((ENABLE_RALINK_DEBUG_FUNC ? 1 : 0) << 2) 70*0062f2f2Smatt #define RALINK_DEBUG_INFO ((ENABLE_RALINK_DEBUG_INFO ? 1 : 0) << 3) 71*0062f2f2Smatt #define RALINK_DEBUG_REG ((ENABLE_RALINK_DEBUG_REG ? 1 : 0) << 4) 72*0062f2f2Smatt #define RALINK_DEBUG_FORCE ((ENABLE_RALINK_DEBUG_FORCE ? 1 : 0) << 5) 73*0062f2f2Smatt 74*0062f2f2Smatt #ifndef RALINK_DEBUG_ALL 75*0062f2f2Smatt #define RALINK_DEBUG_ALL ( RALINK_DEBUG_ERROR | RALINK_DEBUG_MISC | RALINK_DEBUG_FUNC | \ 76*0062f2f2Smatt RALINK_DEBUG_INFO | RALINK_DEBUG_REG | RALINK_DEBUG_FORCE ) 77*0062f2f2Smatt #endif 78*0062f2f2Smatt 79*0062f2f2Smatt /* 80*0062f2f2Smatt * RALINK_DEBUG_0 is used instead of: 81*0062f2f2Smatt * 82*0062f2f2Smatt * #if 0 83*0062f2f2Smatt * RALINK_DEBUG(x, blah); 84*0062f2f2Smatt * #endif 85*0062f2f2Smatt * 86*0062f2f2Smatt * in order to preserve the if'ed-out prints, without the clutter; 87*0062f2f2Smatt * alternatively, just delete them and this macro 88*0062f2f2Smatt */ 89*0062f2f2Smatt #define RALINK_DEBUG_0(n, args...) do { } while (0) 90*0062f2f2Smatt 91*0062f2f2Smatt #ifdef CPDEBUG 92*0062f2f2Smatt 93*0062f2f2Smatt #if RALINK_DEBUG_ALL > 0 94*0062f2f2Smatt #define RALINK_DEBUG(n, args...) \ 95*0062f2f2Smatt do { \ 96*0062f2f2Smatt if (RALINK_DEBUG_ALL & (n)) \ 97*0062f2f2Smatt printf(args); \ 98*0062f2f2Smatt } while (0) 99*0062f2f2Smatt #else 100*0062f2f2Smatt #define RALINK_DEBUG(n, args...) do { } while (0) 101*0062f2f2Smatt #endif 102*0062f2f2Smatt 103*0062f2f2Smatt /* helper so we don't have to retype a bunch of times */ 104*0062f2f2Smatt #define RALINK_DEBUG_FUNC_ENTRY() \ 105*0062f2f2Smatt RALINK_DEBUG(RALINK_DEBUG_FUNC, "%s() entry\n", __FUNCTION__) 106*0062f2f2Smatt #define RALINK_DEBUG_FUNC_EXIT() \ 107*0062f2f2Smatt RALINK_DEBUG(RALINK_DEBUG_FUNC, "%s() exit\n", __FUNCTION__) 108*0062f2f2Smatt 109*0062f2f2Smatt #else /* DEBUG not defined (release build) */ 110*0062f2f2Smatt 111*0062f2f2Smatt #define RALINK_DEBUG(n, args...) 112*0062f2f2Smatt #define RALINK_DEBUG_FUNC_ENTRY() 113*0062f2f2Smatt #define RALINK_DEBUG_FUNC_EXIT() 114*0062f2f2Smatt 115*0062f2f2Smatt #endif /* DEBUG defined */ 116*0062f2f2Smatt 117*0062f2f2Smatt #endif /* _RALINK_DEBUG_H_ */ 118