Daniel Drake | 66bb42f | 2007-11-19 16:20:12 +0000 | [diff] [blame] | 1 | /* ZD1211 USB-WLAN driver for Linux |
| 2 | * |
| 3 | * Copyright (C) 2005-2007 Ulrich Kunitz <kune@deine-taler.de> |
| 4 | * Copyright (C) 2006-2007 Daniel Drake <dsd@gentoo.org> |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 19 | */ |
| 20 | |
| 21 | #ifndef _ZD_DEF_H |
| 22 | #define _ZD_DEF_H |
| 23 | |
| 24 | #include <linux/kernel.h> |
| 25 | #include <linux/stringify.h> |
| 26 | #include <linux/device.h> |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 27 | |
Daniel Drake | 0ce34bc | 2006-12-12 01:26:11 +0000 | [diff] [blame] | 28 | typedef u16 __nocast zd_addr_t; |
| 29 | |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 30 | #define dev_printk_f(level, dev, fmt, args...) \ |
| 31 | dev_printk(level, dev, "%s() " fmt, __func__, ##args) |
| 32 | |
| 33 | #ifdef DEBUG |
| 34 | # define dev_dbg_f(dev, fmt, args...) \ |
| 35 | dev_printk_f(KERN_DEBUG, dev, fmt, ## args) |
Johannes Berg | 00d3f14 | 2009-02-10 21:26:00 +0100 | [diff] [blame] | 36 | # define dev_dbg_f_limit(dev, fmt, args...) do { \ |
| 37 | if (net_ratelimit()) \ |
| 38 | dev_printk_f(KERN_DEBUG, dev, fmt, ## args); \ |
Johannes Berg | 570a0a7 | 2009-02-10 21:25:37 +0100 | [diff] [blame] | 39 | } while (0) |
Jussi Kivilinna | 7a1d656 | 2011-06-20 14:42:28 +0300 | [diff] [blame] | 40 | # define dev_dbg_f_cond(dev, cond, fmt, args...) ({ \ |
| 41 | bool __cond = !!(cond); \ |
| 42 | if (unlikely(__cond)) \ |
| 43 | dev_printk_f(KERN_DEBUG, dev, fmt, ## args); \ |
| 44 | }) |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 45 | #else |
| 46 | # define dev_dbg_f(dev, fmt, args...) do { (void)(dev); } while (0) |
Johannes Berg | 570a0a7 | 2009-02-10 21:25:37 +0100 | [diff] [blame] | 47 | # define dev_dbg_f_limit(dev, fmt, args...) do { (void)(dev); } while (0) |
Jussi Kivilinna | 7a1d656 | 2011-06-20 14:42:28 +0300 | [diff] [blame] | 48 | # define dev_dbg_f_cond(dev, cond, fmt, args...) do { (void)(dev); } while (0) |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 49 | #endif /* DEBUG */ |
| 50 | |
| 51 | #ifdef DEBUG |
| 52 | # define ZD_ASSERT(x) \ |
| 53 | do { \ |
Jussi Kivilinna | 91f71fa | 2011-02-12 20:43:51 +0200 | [diff] [blame] | 54 | if (unlikely(!(x))) { \ |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 55 | pr_debug("%s:%d ASSERT %s VIOLATED!\n", \ |
| 56 | __FILE__, __LINE__, __stringify(x)); \ |
Ulrich Kunitz | 741fec5 | 2006-11-22 00:05:53 +0000 | [diff] [blame] | 57 | dump_stack(); \ |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 58 | } \ |
| 59 | } while (0) |
| 60 | #else |
| 61 | # define ZD_ASSERT(x) do { } while (0) |
| 62 | #endif |
| 63 | |
Ulrich Kunitz | c48cf12 | 2006-08-12 18:00:17 +0100 | [diff] [blame] | 64 | #ifdef DEBUG |
| 65 | # define ZD_MEMCLEAR(pointer, size) memset((pointer), 0xff, (size)) |
| 66 | #else |
| 67 | # define ZD_MEMCLEAR(pointer, size) do { } while (0) |
| 68 | #endif |
| 69 | |
Daniel Drake | e85d091 | 2006-06-02 17:11:32 +0100 | [diff] [blame] | 70 | #endif /* _ZD_DEF_H */ |