File Index
Files and directories
Sign in
FILE

debug.c

File preview with syntax highlighting.

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