357-v5.4-0002-brcmfmac-add-reset-debugfs-entry-for-testing-reset.patch 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. This is a trivial debugfs entry for triggering reset just like in case
  9. of firmware crash. It works by writing 1 to it:
  10. echo 1 > reset
  11. Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
  12. Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
  13. ---
  14. .../broadcom/brcm80211/brcmfmac/core.c | 25 +++++++++++++++++++
  15. 1 file changed, 25 insertions(+)
  16. --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  17. +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
  18. @@ -1065,6 +1065,29 @@ static void brcmf_core_bus_reset(struct
  19. brcmf_bus_reset(drvr->bus_if);
  20. }
  21. +static ssize_t bus_reset_write(struct file *file, const char __user *user_buf,
  22. + size_t count, loff_t *ppos)
  23. +{
  24. + struct brcmf_pub *drvr = file->private_data;
  25. + u8 value;
  26. +
  27. + if (kstrtou8_from_user(user_buf, count, 0, &value))
  28. + return -EINVAL;
  29. +
  30. + if (value != 1)
  31. + return -EINVAL;
  32. +
  33. + schedule_work(&drvr->bus_reset);
  34. +
  35. + return count;
  36. +}
  37. +
  38. +static const struct file_operations bus_reset_fops = {
  39. + .open = simple_open,
  40. + .llseek = no_llseek,
  41. + .write = bus_reset_write,
  42. +};
  43. +
  44. int brcmf_bus_started(struct device *dev)
  45. {
  46. int ret = -1;
  47. @@ -1096,6 +1119,8 @@ int brcmf_bus_started(struct device *dev
  48. goto fail;
  49. brcmf_debugfs_add_entry(drvr, "revinfo", brcmf_revinfo_read);
  50. + debugfs_create_file("reset", 0600, brcmf_debugfs_get_devdir(drvr), drvr,
  51. + &bus_reset_fops);
  52. /* assure we have chipid before feature attach */
  53. if (!bus_if->chip) {