1 /* SPDX-License-Identifier: GPL-2.0-or-later */ 2 /* ZD1211 USB-WLAN driver for Linux 3 * 4 * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de> 5 * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org> 6 */ 7 8 #ifndef _ZD_DEF_H 9 #define _ZD_DEF_H 10 11 #include <linux/kernel.h> 12 #include <linux/stringify.h> 13 #include <linux/device.h> 14 15 typedef u16 zd_addr_t; 16 17 #define dev_printk_f(level, dev, fmt, args...) \ 18 dev_printk(level, dev, "%s() " fmt, __func__, ##args) 19 20 #ifdef DEBUG 21 # define dev_dbg_f(dev, fmt, args...) \ 22 dev_printk_f(KERN_DEBUG, dev, fmt, ## args) 23 # define dev_dbg_f_limit(dev, fmt, args...) do { \ 24 if (net_ratelimit()) \ 25 dev_printk_f(KERN_DEBUG, dev, fmt, ## args); \ 26 } while (0) 27 # define dev_dbg_f_cond(dev, cond, fmt, args...) ({ \ 28 bool __cond = !!(cond); \ 29 if (unlikely(__cond)) \ 30 dev_printk_f(KERN_DEBUG, dev, fmt, ## args); \ 31 }) 32 #else 33 # define dev_dbg_f(dev, fmt, args...) do { (void)(dev); } while (0) 34 # define dev_dbg_f_limit(dev, fmt, args...) do { (void)(dev); } while (0) 35 # define dev_dbg_f_cond(dev, cond, fmt, args...) do { (void)(dev); } while (0) 36 #endif /* DEBUG */ 37 38 #ifdef DEBUG 39 # define ZD_ASSERT(x) \ 40 do { \ 41 if (unlikely(!(x))) { \ 42 pr_debug("%s:%d ASSERT %s VIOLATED!\n", \ 43 __FILE__, __LINE__, __stringify(x)); \ 44 dump_stack(); \ 45 } \ 46 } while (0) 47 #else 48 # define ZD_ASSERT(x) do { } while (0) 49 #endif 50 51 #ifdef DEBUG 52 # define ZD_MEMCLEAR(pointer, size) memset((pointer), 0xff, (size)) 53 #else 54 # define ZD_MEMCLEAR(pointer, size) do { } while (0) 55 #endif 56 57 #endif /* _ZD_DEF_H */ 58