Linux 6.13-rc6
[linux.git] / drivers / net / wireless / broadcom / brcm80211 / brcmfmac / debug.c
blobeecf8a38d94aa43c502083ad3464b29dfbb98563
1 // SPDX-License-Identifier: ISC
2 /*
3 * Copyright (c) 2012 Broadcom Corporation
4 */
5 #include <linux/debugfs.h>
6 #include <linux/netdevice.h>
7 #include <linux/module.h>
8 #include <linux/devcoredump.h>
10 #include <brcmu_wifi.h>
11 #include <brcmu_utils.h>
12 #include "core.h"
13 #include "bus.h"
14 #include "fweh.h"
15 #include "debug.h"
17 int brcmf_debug_create_memdump(struct brcmf_bus *bus, const void *data,
18 size_t len)
20 void *dump;
21 size_t ramsize;
22 int err;
24 ramsize = brcmf_bus_get_ramsize(bus);
25 if (!ramsize)
26 return -ENOTSUPP;
28 dump = vzalloc(len + ramsize);
29 if (!dump)
30 return -ENOMEM;
32 if (data && len > 0)
33 memcpy(dump, data, len);
34 err = brcmf_bus_get_memdump(bus, dump + len, ramsize);
35 if (err) {
36 vfree(dump);
37 return err;
40 dev_coredumpv(bus->dev, dump, len + ramsize, GFP_KERNEL);
42 return 0;
45 struct dentry *brcmf_debugfs_get_devdir(struct brcmf_pub *drvr)
47 return drvr->wiphy->debugfsdir;
50 void brcmf_debugfs_add_entry(struct brcmf_pub *drvr, const char *fn,
51 int (*read_fn)(struct seq_file *seq, void *data))
53 WARN(!drvr->wiphy->debugfsdir, "wiphy not (yet) registered\n");
54 debugfs_create_devm_seqfile(drvr->bus_if->dev, fn,
55 drvr->wiphy->debugfsdir, read_fn);