1 // SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
2 /*
3 * Copyright (C) 2005-2011 Intel Corporation
4 */
5 #include <linux/device.h>
6 #include <linux/interrupt.h>
7 #include <linux/export.h>
8 #include "iwl-drv.h"
9 #include "iwl-debug.h"
10 #include "iwl-devtrace.h"
11
12 #define __iwl_fn(fn) \
13 void __iwl_ ##fn(struct device *dev, const char *fmt, ...) \
14 { \
15 struct va_format vaf = { \
16 .fmt = fmt, \
17 }; \
18 va_list args; \
19 \
20 va_start(args, fmt); \
21 vaf.va = &args; \
22 dev_ ##fn(dev, "%pV", &vaf); \
23 trace_iwlwifi_ ##fn(&vaf); \
24 va_end(args); \
25 }
26
27 __iwl_fn(warn)
28 IWL_EXPORT_SYMBOL(__iwl_warn);
29 __iwl_fn(info)
30 IWL_EXPORT_SYMBOL(__iwl_info);
31 __iwl_fn(crit)
32 IWL_EXPORT_SYMBOL(__iwl_crit);
33
__iwl_err(struct device * dev,bool rfkill_prefix,bool trace_only,const char * fmt,...)34 void __iwl_err(struct device *dev, bool rfkill_prefix, bool trace_only,
35 const char *fmt, ...)
36 {
37 struct va_format vaf = {
38 .fmt = fmt,
39 };
40 va_list args;
41
42 va_start(args, fmt);
43 vaf.va = &args;
44 if (!trace_only) {
45 if (rfkill_prefix)
46 dev_err(dev, "(RFKILL) %pV", &vaf);
47 else
48 dev_err(dev, "%pV", &vaf);
49 }
50 trace_iwlwifi_err(&vaf);
51 va_end(args);
52 }
53 IWL_EXPORT_SYMBOL(__iwl_err);
54
55 #if defined(CONFIG_IWLWIFI_DEBUG) || defined(CONFIG_IWLWIFI_DEVICE_TRACING)
__iwl_dbg(struct device * dev,u32 level,bool limit,const char * function,const char * fmt,...)56 void __iwl_dbg(struct device *dev,
57 u32 level, bool limit, const char *function,
58 const char *fmt, ...)
59 {
60 struct va_format vaf = {
61 .fmt = fmt,
62 };
63 va_list args;
64
65 va_start(args, fmt);
66 vaf.va = &args;
67 #ifdef CONFIG_IWLWIFI_DEBUG
68 if (iwl_have_debug_level(level) &&
69 (!limit || net_ratelimit()))
70 dev_printk(KERN_DEBUG, dev, "%s %pV", function, &vaf);
71 #endif
72 trace_iwlwifi_dbg(level, function, &vaf);
73 va_end(args);
74 }
75 IWL_EXPORT_SYMBOL(__iwl_dbg);
76 #endif
77