b3d01477a66dfea04a37f86d51ba56e937df8233
[openwrt/openwrt.git] /
1 From 2f8c8e62cd50d72ac68de884a09c6f5a969a269c Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
3 Date: Sun, 1 Sep 2019 13:34:36 +0200
4 Subject: [PATCH] brcmfmac: add "reset" debugfs entry for testing reset
5 MIME-Version: 1.0
6 Content-Type: text/plain; charset=UTF-8
7 Content-Transfer-Encoding: 8bit
8
9 This is a trivial debugfs entry for triggering reset just like in case
10 of firmware crash. It works by writing 1 to it:
11 echo 1 > reset
12
13 Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
14 Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
15 ---
16 .../broadcom/brcm80211/brcmfmac/core.c | 25 +++++++++++++++++++
17 1 file changed, 25 insertions(+)
18
19 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
20 +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
21 @@ -1107,6 +1107,29 @@ static void brcmf_core_bus_reset(struct
22 brcmf_bus_reset(drvr->bus_if);
23 }
24
25 +static ssize_t bus_reset_write(struct file *file, const char __user *user_buf,
26 + size_t count, loff_t *ppos)
27 +{
28 + struct brcmf_pub *drvr = file->private_data;
29 + u8 value;
30 +
31 + if (kstrtou8_from_user(user_buf, count, 0, &value))
32 + return -EINVAL;
33 +
34 + if (value != 1)
35 + return -EINVAL;
36 +
37 + schedule_work(&drvr->bus_reset);
38 +
39 + return count;
40 +}
41 +
42 +static const struct file_operations bus_reset_fops = {
43 + .open = simple_open,
44 + .llseek = no_llseek,
45 + .write = bus_reset_write,
46 +};
47 +
48 static int brcmf_bus_started(struct brcmf_pub *drvr, struct cfg80211_ops *ops)
49 {
50 int ret = -1;
51 @@ -1182,6 +1205,8 @@ static int brcmf_bus_started(struct brcm
52
53 /* populate debugfs */
54 brcmf_debugfs_add_entry(drvr, "revinfo", brcmf_revinfo_read);
55 + debugfs_create_file("reset", 0600, brcmf_debugfs_get_devdir(drvr), drvr,
56 + &bus_reset_fops);
57 brcmf_feat_debugfs_create(drvr);
58 brcmf_proto_debugfs_create(drvr);
59 brcmf_bus_debugfs_create(bus_if);