blob: 41bd755bc1353cb54b3dbe1d56e38777fc39b6e2 [file] [log] [blame]
Daniel Drake66bb42f2007-11-19 16:20:12 +00001/* 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 Drakee85d0912006-06-02 17:11:32 +01005 *
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
Jeff Kirsherf47cdae2013-12-06 03:32:10 -080017 * along with this program; if not, see <http://www.gnu.org/licenses/>.
Daniel Drakee85d0912006-06-02 17:11:32 +010018 */
19
20#ifndef _ZD_DEF_H
21#define _ZD_DEF_H
22
23#include <linux/kernel.h>
24#include <linux/stringify.h>
25#include <linux/device.h>
Daniel Drakee85d0912006-06-02 17:11:32 +010026
Daniel Drake0ce34bc2006-12-12 01:26:11 +000027typedef u16 __nocast zd_addr_t;
28
Daniel Drakee85d0912006-06-02 17:11:32 +010029#define dev_printk_f(level, dev, fmt, args...) \
30 dev_printk(level, dev, "%s() " fmt, __func__, ##args)
31
32#ifdef DEBUG
33# define dev_dbg_f(dev, fmt, args...) \
34 dev_printk_f(KERN_DEBUG, dev, fmt, ## args)
Johannes Berg00d3f142009-02-10 21:26:00 +010035# define dev_dbg_f_limit(dev, fmt, args...) do { \
36 if (net_ratelimit()) \
37 dev_printk_f(KERN_DEBUG, dev, fmt, ## args); \
Johannes Berg570a0a72009-02-10 21:25:37 +010038} while (0)
Jussi Kivilinna7a1d6562011-06-20 14:42:28 +030039# define dev_dbg_f_cond(dev, cond, fmt, args...) ({ \
40 bool __cond = !!(cond); \
41 if (unlikely(__cond)) \
42 dev_printk_f(KERN_DEBUG, dev, fmt, ## args); \
43})
Daniel Drakee85d0912006-06-02 17:11:32 +010044#else
45# define dev_dbg_f(dev, fmt, args...) do { (void)(dev); } while (0)
Johannes Berg570a0a72009-02-10 21:25:37 +010046# define dev_dbg_f_limit(dev, fmt, args...) do { (void)(dev); } while (0)
Jussi Kivilinna7a1d6562011-06-20 14:42:28 +030047# define dev_dbg_f_cond(dev, cond, fmt, args...) do { (void)(dev); } while (0)
Daniel Drakee85d0912006-06-02 17:11:32 +010048#endif /* DEBUG */
49
50#ifdef DEBUG
51# define ZD_ASSERT(x) \
52do { \
Jussi Kivilinna91f71fa2011-02-12 20:43:51 +020053 if (unlikely(!(x))) { \
Daniel Drakee85d0912006-06-02 17:11:32 +010054 pr_debug("%s:%d ASSERT %s VIOLATED!\n", \
55 __FILE__, __LINE__, __stringify(x)); \
Ulrich Kunitz741fec52006-11-22 00:05:53 +000056 dump_stack(); \
Daniel Drakee85d0912006-06-02 17:11:32 +010057 } \
58} while (0)
59#else
60# define ZD_ASSERT(x) do { } while (0)
61#endif
62
Ulrich Kunitzc48cf122006-08-12 18:00:17 +010063#ifdef DEBUG
64# define ZD_MEMCLEAR(pointer, size) memset((pointer), 0xff, (size))
65#else
66# define ZD_MEMCLEAR(pointer, size) do { } while (0)
67#endif
68
Daniel Drakee85d0912006-06-02 17:11:32 +010069#endif /* _ZD_DEF_H */