zd_def.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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>
  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, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef _ZD_DEF_H
  20. #define _ZD_DEF_H
  21. #include <linux/kernel.h>
  22. #include <linux/stringify.h>
  23. #include <linux/device.h>
  24. typedef u16 __nocast zd_addr_t;
  25. #define dev_printk_f(level, dev, fmt, args...) \
  26. dev_printk(level, dev, "%s() " fmt, __func__, ##args)
  27. #ifdef DEBUG
  28. # define dev_dbg_f(dev, fmt, args...) \
  29. dev_printk_f(KERN_DEBUG, dev, fmt, ## args)
  30. # define dev_dbg_f_limit(dev, fmt, args...) do { \
  31. if (net_ratelimit()) \
  32. dev_printk_f(KERN_DEBUG, dev, fmt, ## args); \
  33. } while (0)
  34. # define dev_dbg_f_cond(dev, cond, fmt, args...) ({ \
  35. bool __cond = !!(cond); \
  36. if (unlikely(__cond)) \
  37. dev_printk_f(KERN_DEBUG, dev, fmt, ## args); \
  38. })
  39. #else
  40. # define dev_dbg_f(dev, fmt, args...) do { (void)(dev); } while (0)
  41. # define dev_dbg_f_limit(dev, fmt, args...) do { (void)(dev); } while (0)
  42. # define dev_dbg_f_cond(dev, cond, fmt, args...) do { (void)(dev); } while (0)
  43. #endif /* DEBUG */
  44. #ifdef DEBUG
  45. # define ZD_ASSERT(x) \
  46. do { \
  47. if (unlikely(!(x))) { \
  48. pr_debug("%s:%d ASSERT %s VIOLATED!\n", \
  49. __FILE__, __LINE__, __stringify(x)); \
  50. dump_stack(); \
  51. } \
  52. } while (0)
  53. #else
  54. # define ZD_ASSERT(x) do { } while (0)
  55. #endif
  56. #ifdef DEBUG
  57. # define ZD_MEMCLEAR(pointer, size) memset((pointer), 0xff, (size))
  58. #else
  59. # define ZD_MEMCLEAR(pointer, size) do { } while (0)
  60. #endif
  61. #endif /* _ZD_DEF_H */