[PATCH wireless-next 07/35] wifi: mm81x: add debug.c
From: Lachlan Hodges
Date: Thu Feb 26 2026 - 23:13:09 EST
(Patches split per file for review, see cover letter for more
information)
Signed-off-by: Lachlan Hodges <lachlan.hodges@xxxxxxxxxxxxxx>
---
drivers/net/wireless/morsemicro/mm81x/debug.c | 87 +++++++++++++++++++
1 file changed, 87 insertions(+)
create mode 100644 drivers/net/wireless/morsemicro/mm81x/debug.c
diff --git a/drivers/net/wireless/morsemicro/mm81x/debug.c b/drivers/net/wireless/morsemicro/mm81x/debug.c
new file mode 100644
index 000000000000..6c9720fa452c
--- /dev/null
+++ b/drivers/net/wireless/morsemicro/mm81x/debug.c
@@ -0,0 +1,87 @@
+// SPDX-License-Identifier: GPL-2.0-only
+/*
+ * Copyright (c) 2017-2026 Morse Micro
+ */
+#include <linux/printk.h>
+#include <linux/ratelimit.h>
+#include <linux/stdarg.h>
+#include "core.h"
+#include "debug.h"
+
+void mm81x_info(struct mm81x *mm, const char *fmt, ...)
+{
+ struct va_format vaf = { .fmt = fmt };
+ va_list args;
+
+ va_start(args, fmt);
+ vaf.va = &args;
+ dev_info(mm->dev, "%pV\n", &vaf);
+ va_end(args);
+}
+
+void mm81x_err(struct mm81x *mm, const char *fmt, ...)
+{
+ struct va_format vaf = { .fmt = fmt };
+ va_list args;
+
+ va_start(args, fmt);
+ vaf.va = &args;
+ dev_err(mm->dev, "%pV\n", &vaf);
+ va_end(args);
+}
+
+void __mm81x_warn(struct device *dev, const char *fmt, ...)
+{
+ struct va_format vaf = { .fmt = fmt };
+ va_list args;
+
+ va_start(args, fmt);
+ vaf.va = &args;
+ dev_warn_ratelimited(dev, "%pV\n", &vaf);
+ va_end(args);
+}
+
+#ifdef CONFIG_MM81X_DEBUG
+void __mm81x_dbg(struct mm81x *mm, enum mm81x_debug_mask mask, const char *fmt,
+ ...)
+{
+ struct va_format vaf;
+ va_list args;
+
+ va_start(args, fmt);
+ vaf.fmt = fmt;
+ vaf.va = &args;
+ dev_dbg(mm->dev, "%pV\n", &vaf);
+ va_end(args);
+}
+
+void mm81x_dbg_dump(struct mm81x *mm, enum mm81x_debug_mask mask,
+ const char *msg, const char *prefix, const void *buf,
+ size_t len)
+{
+ const u8 *ptr = buf;
+ char line[256];
+
+ if (!(mm81x_debug_mask & mask))
+ return;
+
+ if (msg)
+ __mm81x_dbg(mm, mask, "%s", msg);
+
+ if (!buf || !len)
+ return;
+
+ while (ptr < (const u8 *)buf + len) {
+ size_t off = ptr - (const u8 *)buf;
+ size_t n = min_t(size_t, 16, (const u8 *)buf + len - ptr);
+ size_t p = 0;
+
+ p += scnprintf(line + p, sizeof(line) - p,
+ "%s%08zx: ", prefix ? prefix : "", off);
+ hex_dump_to_buffer(ptr, n, 16, 1, line + p, sizeof(line) - p,
+ true);
+ dev_dbg(mm->dev, "%s\n", line);
+ ptr += n;
+ }
+}
+#endif /* CONFIG_MM81X_DEBUG */
--
2.43.0