1 // SPDX-License-Identifier: BSD-3-Clause-Clear
2 /*
3 * Copyright (c) 2018-2021 The Linux Foundation. All rights reserved.
4 * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
5 *
6 */
7
8 #include <linux/vmalloc.h>
9 #include "core.h"
10 #include "debug.h"
11
ath12k_info(struct ath12k_base * ab,const char * fmt,...)12 void ath12k_info(struct ath12k_base *ab, const char *fmt, ...)
13 {
14 struct va_format vaf = {
15 .fmt = fmt,
16 };
17 va_list args;
18
19 va_start(args, fmt);
20 vaf.va = &args;
21 dev_info(ab->dev, "%pV", &vaf);
22 /* TODO: Trace the log */
23 va_end(args);
24 }
25 EXPORT_SYMBOL(ath12k_info);
26
ath12k_err(struct ath12k_base * ab,const char * fmt,...)27 void ath12k_err(struct ath12k_base *ab, const char *fmt, ...)
28 {
29 struct va_format vaf = {
30 .fmt = fmt,
31 };
32 va_list args;
33
34 va_start(args, fmt);
35 vaf.va = &args;
36 dev_err(ab->dev, "%pV", &vaf);
37 /* TODO: Trace the log */
38 va_end(args);
39 }
40 EXPORT_SYMBOL(ath12k_err);
41
__ath12k_warn(struct device * dev,const char * fmt,...)42 void __ath12k_warn(struct device *dev, const char *fmt, ...)
43 {
44 struct va_format vaf = {
45 .fmt = fmt,
46 };
47 va_list args;
48
49 va_start(args, fmt);
50 vaf.va = &args;
51 dev_warn_ratelimited(dev, "%pV", &vaf);
52 /* TODO: Trace the log */
53 va_end(args);
54 }
55 EXPORT_SYMBOL(__ath12k_warn);
56
57 #ifdef CONFIG_ATH12K_DEBUG
58
__ath12k_dbg(struct ath12k_base * ab,enum ath12k_debug_mask mask,const char * fmt,...)59 void __ath12k_dbg(struct ath12k_base *ab, enum ath12k_debug_mask mask,
60 const char *fmt, ...)
61 {
62 struct va_format vaf;
63 va_list args;
64
65 va_start(args, fmt);
66
67 vaf.fmt = fmt;
68 vaf.va = &args;
69
70 if (likely(ab))
71 dev_printk(KERN_DEBUG, ab->dev, "%pV", &vaf);
72 else
73 printk(KERN_DEBUG "ath12k: %pV", &vaf);
74
75 /* TODO: trace log */
76
77 va_end(args);
78 }
79 EXPORT_SYMBOL(__ath12k_dbg);
80
ath12k_dbg_dump(struct ath12k_base * ab,enum ath12k_debug_mask mask,const char * msg,const char * prefix,const void * buf,size_t len)81 void ath12k_dbg_dump(struct ath12k_base *ab,
82 enum ath12k_debug_mask mask,
83 const char *msg, const char *prefix,
84 const void *buf, size_t len)
85 {
86 char linebuf[256];
87 size_t linebuflen;
88 const void *ptr;
89
90 if (ath12k_debug_mask & mask) {
91 if (msg)
92 __ath12k_dbg(ab, mask, "%s\n", msg);
93
94 for (ptr = buf; (ptr - buf) < len; ptr += 16) {
95 linebuflen = 0;
96 linebuflen += scnprintf(linebuf + linebuflen,
97 sizeof(linebuf) - linebuflen,
98 "%s%08x: ",
99 (prefix ? prefix : ""),
100 (unsigned int)(ptr - buf));
101 hex_dump_to_buffer(ptr, len - (ptr - buf), 16, 1,
102 linebuf + linebuflen,
103 sizeof(linebuf) - linebuflen, true);
104 dev_dbg(ab->dev, "%s\n", linebuf);
105 }
106 }
107 }
108 EXPORT_SYMBOL(ath12k_dbg_dump);
109
110 #endif /* CONFIG_ATH12K_DEBUG */
111