Path: blob/master/drivers/isdn/hisax/hisax_debug.h
15115 views
/*1* Common debugging macros for use with the hisax driver2*3* Author Frode Isaksen4* Copyright 2001 by Frode Isaksen <[email protected]>5* 2001 by Kai Germaschewski <[email protected]>6*7* This software may be used and distributed according to the terms8* of the GNU General Public License, incorporated herein by reference.9*10* How to use:11*12* Before including this file, you need to13* #define __debug_variable my_debug14* where my_debug is a variable in your code which15* determines the debug bitmask.16*17* If CONFIG_HISAX_DEBUG is not set, all macros evaluate to nothing18*19*/2021#ifndef __HISAX_DEBUG_H__22#define __HISAX_DEBUG_H__232425#ifdef CONFIG_HISAX_DEBUG2627#define DBG(level, format, arg...) do { \28if (level & __debug_variable) \29printk(KERN_DEBUG "%s: " format "\n" , __func__ , ## arg); \30} while (0)3132#define DBG_PACKET(level,data,count) \33if (level & __debug_variable) dump_packet(__func__,data,count)3435#define DBG_SKB(level,skb) \36if ((level & __debug_variable) && skb) dump_packet(__func__,skb->data,skb->len)373839static void __attribute__((unused))40dump_packet(const char *name,const u_char *data,int pkt_len)41{42#define DUMP_HDR_SIZE 2043#define DUMP_TLR_SIZE 844if (pkt_len) {45int i,len1,len2;4647printk(KERN_DEBUG "%s: length=%d,data=",name,pkt_len);4849if (pkt_len > DUMP_HDR_SIZE+ DUMP_TLR_SIZE) {50len1 = DUMP_HDR_SIZE;51len2 = DUMP_TLR_SIZE;52} else {53len1 = pkt_len > DUMP_HDR_SIZE ? DUMP_HDR_SIZE : pkt_len;54len2 = 0;55}56for (i = 0; i < len1; ++i) {57printk ("%.2x", data[i]);58}59if (len2) {60printk ("..");61for (i = pkt_len-DUMP_TLR_SIZE; i < pkt_len; ++i) {62printk ("%.2x", data[i]);63}64}65printk ("\n");66}67#undef DUMP_HDR_SIZE68#undef DUMP_TLR_SIZE69}7071#else7273#define DBG(level, format, arg...) do {} while (0)74#define DBG_PACKET(level,data,count) do {} while (0)75#define DBG_SKB(level,skb) do {} while (0)7677#endif7879#endif808182