aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRafał Miłecki <rafal@milecki.pl>2019-02-25 22:39:04 +0100
committerRafał Miłecki <rafal@milecki.pl>2019-02-26 07:50:22 +0100
commiteab65374490a53dd88bdff00be11cdf1fcb5fe62 (patch)
treefbce35e5666e012754b9163ac9fabda3be3ae19b
parentfb333a7fec5fd58c00aa7409fbd11c6aaa9110ce (diff)
downloadupstream-eab65374490a53dd88bdff00be11cdf1fcb5fe62.tar.gz
upstream-eab65374490a53dd88bdff00be11cdf1fcb5fe62.tar.bz2
upstream-eab65374490a53dd88bdff00be11cdf1fcb5fe62.zip
mac80211: brcmfmac: backport 5.0 & 5.1 important changes/fixes
This backports the most important brcmfmac commits that: 1) Fix some bugs 2) Help debugging bugs Signed-off-by: Rafał Miłecki <rafal@milecki.pl> (cherry picked from commit d32bbd747733de5daeb63a8f2c1307f612422f87)
-rw-r--r--package/kernel/mac80211/Makefile2
-rw-r--r--package/kernel/mac80211/patches/338-v5.0-0001-brcmfmac-fix-spelling-mistake-Retreiving-Retrieving.patch34
-rw-r--r--package/kernel/mac80211/patches/338-v5.0-0002-brcmutil-print-invalid-chanspec-when-WARN-ing.patch (renamed from package/kernel/mac80211/patches/338-v4.21-0001-brcmutil-print-invalid-chanspec-when-WARN-ing.patch)0
-rw-r--r--package/kernel/mac80211/patches/338-v5.0-0003-brcmfmac-support-STA-info-struct-v7.patch (renamed from package/kernel/mac80211/patches/339-v4.21-0001-brcmfmac-support-STA-info-struct-v7.patch)0
-rw-r--r--package/kernel/mac80211/patches/338-v5.0-0005-brcmfmac-fix-roamoff-1-modparam.patch68
-rw-r--r--package/kernel/mac80211/patches/338-v5.0-0006-brcmfmac-Fix-access-point-mode.patch41
-rw-r--r--package/kernel/mac80211/patches/339-v5.1-0001-brcmfmac-modify-__brcmf_err-to-take-bus-as-a-paramet.patch104
-rw-r--r--package/kernel/mac80211/patches/339-v5.1-0002-brcmfmac-pass-bus-to-the-__brcmf_err-in-pcie.c.patch286
-rw-r--r--package/kernel/mac80211/patches/339-v5.1-0003-brcmfmac-add-bphy_err-and-use-it-in-the-cfg80211.c.patch1954
-rw-r--r--package/kernel/mac80211/patches/339-v5.1-0004-brcmfmac-support-monitor-frames-with-the-hardware-uc.patch147
-rw-r--r--package/kernel/mac80211/patches/339-v5.1-0005-brcmfmac-print-firmware-reported-ring-status-errors.patch67
-rw-r--r--package/kernel/mac80211/patches/339-v5.1-0006-brcmfmac-improve-code-handling-bandwidth-of-firmware.patch42
-rw-r--r--package/kernel/mac80211/patches/339-v5.1-0007-brcmfmac-support-firmware-reporting-160-MHz-channels.patch30
-rw-r--r--package/kernel/mac80211/patches/339-v5.1-0008-brcmfmac-rework-bphy_err-to-take-struct-brcmf_pub-ar.patch2223
-rw-r--r--package/kernel/mac80211/patches/339-v5.1-0009-brcmfmac-use-bphy_err-in-all-wiphy-related-code.patch1584
-rw-r--r--package/kernel/mac80211/patches/339-v5.1-0010-brcmfmac-add-basic-validation-of-shared-RAM-address.patch38
-rw-r--r--package/kernel/mac80211/patches/860-brcmfmac-register-wiphy-s-during-module_init.patch2
-rw-r--r--package/kernel/mac80211/patches/861-brcmfmac-workaround-bug-with-some-inconsistent-BSSes.patch9
-rw-r--r--package/kernel/mac80211/patches/862-brcmfmac-Disable-power-management.patch2
19 files changed, 6625 insertions, 8 deletions
diff --git a/package/kernel/mac80211/Makefile b/package/kernel/mac80211/Makefile
index d65038ccc0..28ee6107c6 100644
--- a/package/kernel/mac80211/Makefile
+++ b/package/kernel/mac80211/Makefile
@@ -11,7 +11,7 @@ include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=mac80211
PKG_VERSION:=2017-01-31
-PKG_RELEASE:=14
+PKG_RELEASE:=15
PKG_SOURCE_URL:=http://mirror2.openwrt.org/sources
PKG_BACKPORT_VERSION:=
PKG_HASH:=75e6d39e34cf156212a2509172a4a62b673b69eb4a1d9aaa565f7fa719fa2317
diff --git a/package/kernel/mac80211/patches/338-v5.0-0001-brcmfmac-fix-spelling-mistake-Retreiving-Retrieving.patch b/package/kernel/mac80211/patches/338-v5.0-0001-brcmfmac-fix-spelling-mistake-Retreiving-Retrieving.patch
new file mode 100644
index 0000000000..767f15affc
--- /dev/null
+++ b/package/kernel/mac80211/patches/338-v5.0-0001-brcmfmac-fix-spelling-mistake-Retreiving-Retrieving.patch
@@ -0,0 +1,34 @@
+From e966a79c2f761a696dec9cfb0e2d4aa977bf78cb Mon Sep 17 00:00:00 2001
+From: Colin Ian King <colin.king@canonical.com>
+Date: Tue, 16 Oct 2018 18:43:42 +0100
+Subject: [PATCH] brcmfmac: fix spelling mistake "Retreiving" -> "Retrieving"
+
+Trivial fix to spelling mistake in brcmf_err error message.
+
+Signed-off-by: Colin Ian King <colin.king@canonical.com>
+Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 4 ++--
+ 1 file changed, 2 insertions(+), 2 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+@@ -121,7 +121,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
+ err = brcmf_fil_iovar_data_get(ifp, "cur_etheraddr", ifp->mac_addr,
+ sizeof(ifp->mac_addr));
+ if (err < 0) {
+- brcmf_err("Retreiving cur_etheraddr failed, %d\n", err);
++ brcmf_err("Retrieving cur_etheraddr failed, %d\n", err);
+ goto done;
+ }
+ memcpy(ifp->drvr->wiphy->perm_addr, ifp->drvr->mac, ETH_ALEN);
+@@ -158,7 +158,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
+ strcpy(buf, "ver");
+ err = brcmf_fil_iovar_data_get(ifp, "ver", buf, sizeof(buf));
+ if (err < 0) {
+- brcmf_err("Retreiving version information failed, %d\n",
++ brcmf_err("Retrieving version information failed, %d\n",
+ err);
+ goto done;
+ }
diff --git a/package/kernel/mac80211/patches/338-v4.21-0001-brcmutil-print-invalid-chanspec-when-WARN-ing.patch b/package/kernel/mac80211/patches/338-v5.0-0002-brcmutil-print-invalid-chanspec-when-WARN-ing.patch
index 566336cbc3..566336cbc3 100644
--- a/package/kernel/mac80211/patches/338-v4.21-0001-brcmutil-print-invalid-chanspec-when-WARN-ing.patch
+++ b/package/kernel/mac80211/patches/338-v5.0-0002-brcmutil-print-invalid-chanspec-when-WARN-ing.patch
diff --git a/package/kernel/mac80211/patches/339-v4.21-0001-brcmfmac-support-STA-info-struct-v7.patch b/package/kernel/mac80211/patches/338-v5.0-0003-brcmfmac-support-STA-info-struct-v7.patch
index e1785812c7..e1785812c7 100644
--- a/package/kernel/mac80211/patches/339-v4.21-0001-brcmfmac-support-STA-info-struct-v7.patch
+++ b/package/kernel/mac80211/patches/338-v5.0-0003-brcmfmac-support-STA-info-struct-v7.patch
diff --git a/package/kernel/mac80211/patches/338-v5.0-0005-brcmfmac-fix-roamoff-1-modparam.patch b/package/kernel/mac80211/patches/338-v5.0-0005-brcmfmac-fix-roamoff-1-modparam.patch
new file mode 100644
index 0000000000..6851dcad84
--- /dev/null
+++ b/package/kernel/mac80211/patches/338-v5.0-0005-brcmfmac-fix-roamoff-1-modparam.patch
@@ -0,0 +1,68 @@
+From 8c892df41500469729e0d662816300196e4f463d Mon Sep 17 00:00:00 2001
+From: Stijn Tintel <stijn@linux-ipv6.be>
+Date: Tue, 4 Dec 2018 20:29:05 +0200
+Subject: [PATCH] brcmfmac: fix roamoff=1 modparam
+
+When the update_connect_param callback is set, nl80211 expects the flag
+WIPHY_FLAG_SUPPORTS_FW_ROAM to be set as well. However, this flag is
+only set when modparam roamoff=0, while the callback is set
+unconditionally. Since commit 7f9a3e150ec7 this causes a warning in
+wiphy_register, which breaks brcmfmac.
+
+Disable the update_connect_param callback when roamoff=0 to fix this.
+
+Fixes: 7f9a3e150ec7 ("nl80211: Update ERP info using NL80211_CMD_UPDATE_CONNECT_PARAMS")
+Cc: Stable <stable@vger.kernel.org> # 4.19+
+Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
+Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ .../wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 11 +++++++++--
+ .../wireless/broadcom/brcm80211/brcmfmac/cfg80211.h | 2 +-
+ .../net/wireless/broadcom/brcm80211/brcmfmac/core.c | 2 +-
+ 3 files changed, 11 insertions(+), 4 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+@@ -5190,10 +5190,17 @@ static struct cfg80211_ops brcmf_cfg8021
+ .update_connect_params = brcmf_cfg80211_update_conn_params,
+ };
+
+-struct cfg80211_ops *brcmf_cfg80211_get_ops(void)
++struct cfg80211_ops *brcmf_cfg80211_get_ops(struct brcmf_mp_device *settings)
+ {
+- return kmemdup(&brcmf_cfg80211_ops, sizeof(brcmf_cfg80211_ops),
++ struct cfg80211_ops *ops;
++
++ ops = kmemdup(&brcmf_cfg80211_ops, sizeof(brcmf_cfg80211_ops),
+ GFP_KERNEL);
++
++ if (ops && settings->roamoff)
++ ops->update_connect_params = NULL;
++
++ return ops;
+ }
+
+ struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.h
+@@ -391,7 +391,7 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+ void brcmf_cfg80211_detach(struct brcmf_cfg80211_info *cfg);
+ s32 brcmf_cfg80211_up(struct net_device *ndev);
+ s32 brcmf_cfg80211_down(struct net_device *ndev);
+-struct cfg80211_ops *brcmf_cfg80211_get_ops(void);
++struct cfg80211_ops *brcmf_cfg80211_get_ops(struct brcmf_mp_device *settings);
+ enum nl80211_iftype brcmf_cfg80211_get_iftype(struct brcmf_if *ifp);
+
+ struct brcmf_cfg80211_vif *brcmf_alloc_vif(struct brcmf_cfg80211_info *cfg,
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+@@ -1132,7 +1132,7 @@ int brcmf_attach(struct device *dev, str
+
+ brcmf_dbg(TRACE, "Enter\n");
+
+- ops = brcmf_cfg80211_get_ops();
++ ops = brcmf_cfg80211_get_ops(settings);
+ if (!ops)
+ return -ENOMEM;
+
diff --git a/package/kernel/mac80211/patches/338-v5.0-0006-brcmfmac-Fix-access-point-mode.patch b/package/kernel/mac80211/patches/338-v5.0-0006-brcmfmac-Fix-access-point-mode.patch
new file mode 100644
index 0000000000..8732ce4e01
--- /dev/null
+++ b/package/kernel/mac80211/patches/338-v5.0-0006-brcmfmac-Fix-access-point-mode.patch
@@ -0,0 +1,41 @@
+From 861cb5eb467f5e38dce1aabe4e8db379255bd89b Mon Sep 17 00:00:00 2001
+From: Stefan Wahren <stefan.wahren@i2se.com>
+Date: Wed, 12 Dec 2018 20:20:06 +0100
+Subject: [PATCH] brcmfmac: Fix access point mode
+
+Since commit 1204aa17f3b4 ("brcmfmac: set WIPHY_FLAG_HAVE_AP_SME flag")
+the Raspberry Pi 3 A+ (BCM43455) isn't able to operate in AP mode with
+hostapd (device_ap_sme=1 use_monitor=0):
+
+brcmfmac: brcmf_cfg80211_stop_ap: setting AP mode failed -52
+
+So add the missing mgmt_stypes for AP mode to fix this.
+
+Fixes: 1204aa17f3b4 ("brcmfmac: set WIPHY_FLAG_HAVE_AP_SME flag")
+Suggested-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
+Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ .../wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 10 ++++++++++
+ 1 file changed, 10 insertions(+)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+@@ -6271,6 +6271,16 @@ brcmf_txrx_stypes[NUM_NL80211_IFTYPES] =
+ .tx = 0xffff,
+ .rx = BIT(IEEE80211_STYPE_ACTION >> 4) |
+ BIT(IEEE80211_STYPE_PROBE_REQ >> 4)
++ },
++ [NL80211_IFTYPE_AP] = {
++ .tx = 0xffff,
++ .rx = BIT(IEEE80211_STYPE_ASSOC_REQ >> 4) |
++ BIT(IEEE80211_STYPE_REASSOC_REQ >> 4) |
++ BIT(IEEE80211_STYPE_PROBE_REQ >> 4) |
++ BIT(IEEE80211_STYPE_DISASSOC >> 4) |
++ BIT(IEEE80211_STYPE_AUTH >> 4) |
++ BIT(IEEE80211_STYPE_DEAUTH >> 4) |
++ BIT(IEEE80211_STYPE_ACTION >> 4)
+ }
+ };
+
diff --git a/package/kernel/mac80211/patches/339-v5.1-0001-brcmfmac-modify-__brcmf_err-to-take-bus-as-a-paramet.patch b/package/kernel/mac80211/patches/339-v5.1-0001-brcmfmac-modify-__brcmf_err-to-take-bus-as-a-paramet.patch
new file mode 100644
index 0000000000..6b846e3677
--- /dev/null
+++ b/package/kernel/mac80211/patches/339-v5.1-0001-brcmfmac-modify-__brcmf_err-to-take-bus-as-a-paramet.patch
@@ -0,0 +1,104 @@
+From 5cc898fbcb352b764f8d51c16e10e2eb0056173d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Wed, 6 Feb 2019 12:28:15 +0100
+Subject: [PATCH] brcmfmac: modify __brcmf_err() to take bus as a parameter
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+So far __brcmf_err() was using pr_err() which didn't allow identifying
+device that was affected by an error. It's crucial for systems with more
+than 1 device supported by brcmfmac (a common case for home routers).
+
+This change allows passing struct brcmf_bus to the __brcmf_err(). That
+struct has been agreed to be the most common one. It allows accessing
+struct device easily & using dev_err() printing helper.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ .../net/wireless/broadcom/brcm80211/brcmfmac/common.c | 7 +++++--
+ drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h | 8 +++++---
+ .../wireless/broadcom/brcm80211/brcmfmac/tracepoint.c | 9 +++++++--
+ 3 files changed, 17 insertions(+), 7 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+@@ -221,7 +221,7 @@ done:
+ }
+
+ #ifndef CPTCFG_BRCM_TRACING
+-void __brcmf_err(const char *func, const char *fmt, ...)
++void __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...)
+ {
+ struct va_format vaf;
+ va_list args;
+@@ -230,7 +230,10 @@ void __brcmf_err(const char *func, const
+
+ vaf.fmt = fmt;
+ vaf.va = &args;
+- pr_err("%s: %pV", func, &vaf);
++ if (bus)
++ dev_err(bus->dev, "%s: %pV", func, &vaf);
++ else
++ pr_err("%s: %pV", func, &vaf);
+
+ va_end(args);
+ }
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
+@@ -45,8 +45,10 @@
+ #undef pr_fmt
+ #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
+
+-__printf(2, 3)
+-void __brcmf_err(const char *func, const char *fmt, ...);
++struct brcmf_bus;
++
++__printf(3, 4)
++void __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...);
+ /* Macro for error messages. When debugging / tracing the driver all error
+ * messages are important to us.
+ */
+@@ -55,7 +57,7 @@ void __brcmf_err(const char *func, const
+ if (IS_ENABLED(CPTCFG_BRCMDBG) || \
+ IS_ENABLED(CPTCFG_BRCM_TRACING) || \
+ net_ratelimit()) \
+- __brcmf_err(__func__, fmt, ##__VA_ARGS__); \
++ __brcmf_err(NULL, __func__, fmt, ##__VA_ARGS__);\
+ } while (0)
+
+ #if defined(DEBUG) || defined(CPTCFG_BRCM_TRACING)
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c
+@@ -14,14 +14,16 @@
+ * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
++#include <linux/device.h>
+ #include <linux/module.h> /* bug in tracepoint.h, it should include this */
+
+ #ifndef __CHECKER__
+ #define CREATE_TRACE_POINTS
++#include "bus.h"
+ #include "tracepoint.h"
+ #include "debug.h"
+
+-void __brcmf_err(const char *func, const char *fmt, ...)
++void __brcmf_err(struct brcmf_bus *bus, const char *func, const char *fmt, ...)
+ {
+ struct va_format vaf = {
+ .fmt = fmt,
+@@ -30,7 +32,10 @@ void __brcmf_err(const char *func, const
+
+ va_start(args, fmt);
+ vaf.va = &args;
+- pr_err("%s: %pV", func, &vaf);
++ if (bus)
++ dev_err(bus->dev, "%s: %pV", func, &vaf);
++ else
++ pr_err("%s: %pV", func, &vaf);
+ trace_brcmf_err(func, &vaf);
+ va_end(args);
+ }
diff --git a/package/kernel/mac80211/patches/339-v5.1-0002-brcmfmac-pass-bus-to-the-__brcmf_err-in-pcie.c.patch b/package/kernel/mac80211/patches/339-v5.1-0002-brcmfmac-pass-bus-to-the-__brcmf_err-in-pcie.c.patch
new file mode 100644
index 0000000000..2cb39856e9
--- /dev/null
+++ b/package/kernel/mac80211/patches/339-v5.1-0002-brcmfmac-pass-bus-to-the-__brcmf_err-in-pcie.c.patch
@@ -0,0 +1,286 @@
+From 8602e62441aba276cafd68034b72162fbc5ca0a6 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Wed, 6 Feb 2019 12:28:16 +0100
+Subject: [PATCH] brcmfmac: pass bus to the __brcmf_err() in pcie.c
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This enables dev_err() usage (instead of pr_err()) in the __brcmf_err().
+It makes error messages more meaningful and is important for debugging
+errors/bugs on systems with multiple brcmfmac supported devices.
+
+All bus files should follow & get updated similarly (soon).
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ .../broadcom/brcm80211/brcmfmac/debug.h | 2 +
+ .../broadcom/brcm80211/brcmfmac/pcie.c | 59 +++++++++++--------
+ 2 files changed, 38 insertions(+), 23 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
+@@ -52,6 +52,7 @@ void __brcmf_err(struct brcmf_bus *bus,
+ /* Macro for error messages. When debugging / tracing the driver all error
+ * messages are important to us.
+ */
++#ifndef brcmf_err
+ #define brcmf_err(fmt, ...) \
+ do { \
+ if (IS_ENABLED(CPTCFG_BRCMDBG) || \
+@@ -59,6 +60,7 @@ void __brcmf_err(struct brcmf_bus *bus,
+ net_ratelimit()) \
+ __brcmf_err(NULL, __func__, fmt, ##__VA_ARGS__);\
+ } while (0)
++#endif
+
+ #if defined(DEBUG) || defined(CPTCFG_BRCM_TRACING)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+@@ -30,6 +30,15 @@
+ #include <brcmu_wifi.h>
+ #include <brcm_hw_ids.h>
+
++/* Custom brcmf_err() that takes bus arg and passes it further */
++#define brcmf_err(bus, fmt, ...) \
++ do { \
++ if (IS_ENABLED(CPTCFG_BRCMDBG) || \
++ IS_ENABLED(CPTCFG_BRCM_TRACING) || \
++ net_ratelimit()) \
++ __brcmf_err(bus, __func__, fmt, ##__VA_ARGS__); \
++ } while (0)
++
+ #include "debug.h"
+ #include "bus.h"
+ #include "commonring.h"
+@@ -529,6 +538,7 @@ static void
+ brcmf_pcie_select_core(struct brcmf_pciedev_info *devinfo, u16 coreid)
+ {
+ const struct pci_dev *pdev = devinfo->pdev;
++ struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
+ struct brcmf_core *core;
+ u32 bar0_win;
+
+@@ -546,7 +556,7 @@ brcmf_pcie_select_core(struct brcmf_pcie
+ }
+ }
+ } else {
+- brcmf_err("Unsupported core selected %x\n", coreid);
++ brcmf_err(bus, "Unsupported core selected %x\n", coreid);
+ }
+ }
+
+@@ -840,9 +850,8 @@ static irqreturn_t brcmf_pcie_isr_thread
+
+ static int brcmf_pcie_request_irq(struct brcmf_pciedev_info *devinfo)
+ {
+- struct pci_dev *pdev;
+-
+- pdev = devinfo->pdev;
++ struct pci_dev *pdev = devinfo->pdev;
++ struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
+
+ brcmf_pcie_intr_disable(devinfo);
+
+@@ -853,7 +862,7 @@ static int brcmf_pcie_request_irq(struct
+ brcmf_pcie_isr_thread, IRQF_SHARED,
+ "brcmf_pcie_intr", devinfo)) {
+ pci_disable_msi(pdev);
+- brcmf_err("Failed to request IRQ %d\n", pdev->irq);
++ brcmf_err(bus, "Failed to request IRQ %d\n", pdev->irq);
+ return -EIO;
+ }
+ devinfo->irq_allocated = true;
+@@ -863,15 +872,14 @@ static int brcmf_pcie_request_irq(struct
+
+ static void brcmf_pcie_release_irq(struct brcmf_pciedev_info *devinfo)
+ {
+- struct pci_dev *pdev;
++ struct pci_dev *pdev = devinfo->pdev;
++ struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
+ u32 status;
+ u32 count;
+
+ if (!devinfo->irq_allocated)
+ return;
+
+- pdev = devinfo->pdev;
+-
+ brcmf_pcie_intr_disable(devinfo);
+ free_irq(pdev->irq, devinfo);
+ pci_disable_msi(pdev);
+@@ -883,7 +891,7 @@ static void brcmf_pcie_release_irq(struc
+ count++;
+ }
+ if (devinfo->in_irq)
+- brcmf_err("Still in IRQ (processing) !!!\n");
++ brcmf_err(bus, "Still in IRQ (processing) !!!\n");
+
+ status = brcmf_pcie_read_reg32(devinfo, BRCMF_PCIE_PCIE2REG_MAILBOXINT);
+ brcmf_pcie_write_reg32(devinfo, BRCMF_PCIE_PCIE2REG_MAILBOXINT, status);
+@@ -1094,6 +1102,7 @@ static void brcmf_pcie_release_ringbuffe
+
+ static int brcmf_pcie_init_ringbuffers(struct brcmf_pciedev_info *devinfo)
+ {
++ struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev);
+ struct brcmf_pcie_ringbuf *ring;
+ struct brcmf_pcie_ringbuf *rings;
+ u32 d2h_w_idx_ptr;
+@@ -1246,7 +1255,7 @@ static int brcmf_pcie_init_ringbuffers(s
+ return 0;
+
+ fail:
+- brcmf_err("Allocating ring buffers failed\n");
++ brcmf_err(bus, "Allocating ring buffers failed\n");
+ brcmf_pcie_release_ringbuffers(devinfo);
+ return -ENOMEM;
+ }
+@@ -1269,6 +1278,7 @@ brcmf_pcie_release_scratchbuffers(struct
+
+ static int brcmf_pcie_init_scratchbuffers(struct brcmf_pciedev_info *devinfo)
+ {
++ struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev);
+ u64 address;
+ u32 addr;
+
+@@ -1308,7 +1318,7 @@ static int brcmf_pcie_init_scratchbuffer
+ return 0;
+
+ fail:
+- brcmf_err("Allocating scratch buffers failed\n");
++ brcmf_err(bus, "Allocating scratch buffers failed\n");
+ brcmf_pcie_release_scratchbuffers(devinfo);
+ return -ENOMEM;
+ }
+@@ -1409,6 +1419,7 @@ static int
+ brcmf_pcie_init_share_ram_info(struct brcmf_pciedev_info *devinfo,
+ u32 sharedram_addr)
+ {
++ struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev);
+ struct brcmf_pcie_shared_info *shared;
+ u32 addr;
+
+@@ -1420,7 +1431,8 @@ brcmf_pcie_init_share_ram_info(struct br
+ brcmf_dbg(PCIE, "PCIe protocol version %d\n", shared->version);
+ if ((shared->version > BRCMF_PCIE_MAX_SHARED_VERSION) ||
+ (shared->version < BRCMF_PCIE_MIN_SHARED_VERSION)) {
+- brcmf_err("Unsupported PCIE version %d\n", shared->version);
++ brcmf_err(bus, "Unsupported PCIE version %d\n",
++ shared->version);
+ return -EINVAL;
+ }
+
+@@ -1462,6 +1474,7 @@ static int brcmf_pcie_download_fw_nvram(
+ const struct firmware *fw, void *nvram,
+ u32 nvram_len)
+ {
++ struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev);
+ u32 sharedram_addr;
+ u32 sharedram_addr_written;
+ u32 loop_counter;
+@@ -1516,7 +1529,7 @@ static int brcmf_pcie_download_fw_nvram(
+ loop_counter--;
+ }
+ if (sharedram_addr == sharedram_addr_written) {
+- brcmf_err("FW failed to initialize\n");
++ brcmf_err(bus, "FW failed to initialize\n");
+ return -ENODEV;
+ }
+ brcmf_dbg(PCIE, "Shared RAM addr: 0x%08x\n", sharedram_addr);
+@@ -1527,16 +1540,15 @@ static int brcmf_pcie_download_fw_nvram(
+
+ static int brcmf_pcie_get_resource(struct brcmf_pciedev_info *devinfo)
+ {
+- struct pci_dev *pdev;
++ struct pci_dev *pdev = devinfo->pdev;
++ struct brcmf_bus *bus = dev_get_drvdata(&pdev->dev);
+ int err;
+ phys_addr_t bar0_addr, bar1_addr;
+ ulong bar1_size;
+
+- pdev = devinfo->pdev;
+-
+ err = pci_enable_device(pdev);
+ if (err) {
+- brcmf_err("pci_enable_device failed err=%d\n", err);
++ brcmf_err(bus, "pci_enable_device failed err=%d\n", err);
+ return err;
+ }
+
+@@ -1549,7 +1561,7 @@ static int brcmf_pcie_get_resource(struc
+ /* read Bar-1 mapped memory range */
+ bar1_size = pci_resource_len(pdev, 2);
+ if ((bar1_size == 0) || (bar1_addr == 0)) {
+- brcmf_err("BAR1 Not enabled, device size=%ld, addr=%#016llx\n",
++ brcmf_err(bus, "BAR1 Not enabled, device size=%ld, addr=%#016llx\n",
+ bar1_size, (unsigned long long)bar1_addr);
+ return -EINVAL;
+ }
+@@ -1558,7 +1570,7 @@ static int brcmf_pcie_get_resource(struc
+ devinfo->tcm = ioremap_nocache(bar1_addr, bar1_size);
+
+ if (!devinfo->regs || !devinfo->tcm) {
+- brcmf_err("ioremap() failed (%p,%p)\n", devinfo->regs,
++ brcmf_err(bus, "ioremap() failed (%p,%p)\n", devinfo->regs,
+ devinfo->tcm);
+ return -EINVAL;
+ }
+@@ -1585,16 +1597,17 @@ static void brcmf_pcie_release_resource(
+
+ static int brcmf_pcie_attach_bus(struct brcmf_pciedev_info *devinfo)
+ {
++ struct brcmf_bus *bus = dev_get_drvdata(&devinfo->pdev->dev);
+ int ret;
+
+ /* Attach to the common driver interface */
+ ret = brcmf_attach(&devinfo->pdev->dev, devinfo->settings);
+ if (ret) {
+- brcmf_err("brcmf_attach failed\n");
++ brcmf_err(bus, "brcmf_attach failed\n");
+ } else {
+ ret = brcmf_bus_started(&devinfo->pdev->dev);
+ if (ret)
+- brcmf_err("dongle is not responding\n");
++ brcmf_err(bus, "dongle is not responding\n");
+ }
+
+ return ret;
+@@ -1823,7 +1836,7 @@ fail_bus:
+ kfree(bus->msgbuf);
+ kfree(bus);
+ fail:
+- brcmf_err("failed %x:%x\n", pdev->vendor, pdev->device);
++ brcmf_err(NULL, "failed %x:%x\n", pdev->vendor, pdev->device);
+ brcmf_pcie_release_resource(devinfo);
+ if (devinfo->ci)
+ brcmf_chip_detach(devinfo->ci);
+@@ -1897,7 +1910,7 @@ static int brcmf_pcie_pm_enter_D3(struct
+ wait_event_timeout(devinfo->mbdata_resp_wait, devinfo->mbdata_completed,
+ BRCMF_PCIE_MBDATA_TIMEOUT);
+ if (!devinfo->mbdata_completed) {
+- brcmf_err("Timeout on response for entering D3 substate\n");
++ brcmf_err(bus, "Timeout on response for entering D3 substate\n");
+ brcmf_bus_change_state(bus, BRCMF_BUS_UP);
+ return -EIO;
+ }
+@@ -1942,7 +1955,7 @@ cleanup:
+
+ err = brcmf_pcie_probe(pdev, NULL);
+ if (err)
+- brcmf_err("probe after resume failed, err=%d\n", err);
++ brcmf_err(bus, "probe after resume failed, err=%d\n", err);
+
+ return err;
+ }
+@@ -2014,7 +2027,8 @@ void brcmf_pcie_register(void)
+ brcmf_dbg(PCIE, "Enter\n");
+ err = pci_register_driver(&brcmf_pciedrvr);
+ if (err)
+- brcmf_err("PCIE driver registration failed, err=%d\n", err);
++ brcmf_err(NULL, "PCIE driver registration failed, err=%d\n",
++ err);
+ }
+
+
diff --git a/package/kernel/mac80211/patches/339-v5.1-0003-brcmfmac-add-bphy_err-and-use-it-in-the-cfg80211.c.patch b/package/kernel/mac80211/patches/339-v5.1-0003-brcmfmac-add-bphy_err-and-use-it-in-the-cfg80211.c.patch
new file mode 100644
index 0000000000..db6261163c
--- /dev/null
+++ b/package/kernel/mac80211/patches/339-v5.1-0003-brcmfmac-add-bphy_err-and-use-it-in-the-cfg80211.c.patch
@@ -0,0 +1,1954 @@
+From 3ef005b82e2ad68107fc5814eaa743d171a6c362 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Wed, 16 Jan 2019 07:28:54 +0100
+Subject: [PATCH] brcmfmac: add bphy_err() and use it in the cfg80211.c
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This new macro uses wiphy_err() which:
+1) Should be the best choice with wiphy already created
+2) Uses dev_err() which allows identifying error-affected device
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ .../broadcom/brcm80211/brcmfmac/cfg80211.c | 497 ++++++++++--------
+ .../broadcom/brcm80211/brcmfmac/debug.h | 9 +
+ 2 files changed, 282 insertions(+), 224 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+@@ -457,6 +457,7 @@ static void convert_key_from_CPU(struct
+ static int
+ send_key_to_dongle(struct brcmf_if *ifp, struct brcmf_wsec_key *key)
+ {
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ int err;
+ struct brcmf_wsec_key_le key_le;
+
+@@ -468,7 +469,7 @@ send_key_to_dongle(struct brcmf_if *ifp,
+ sizeof(key_le));
+
+ if (err)
+- brcmf_err("wsec_key error (%d)\n", err);
++ bphy_err(wiphy, "wsec_key error (%d)\n", err);
+ return err;
+ }
+
+@@ -549,6 +550,7 @@ static int brcmf_get_first_free_bsscfgid
+
+ static int brcmf_cfg80211_request_ap_if(struct brcmf_if *ifp)
+ {
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ struct brcmf_mbss_ssid_le mbss_ssid_le;
+ int bsscfgidx;
+ int err;
+@@ -565,7 +567,7 @@ static int brcmf_cfg80211_request_ap_if(
+ err = brcmf_fil_bsscfg_data_set(ifp, "bsscfg:ssid", &mbss_ssid_le,
+ sizeof(mbss_ssid_le));
+ if (err < 0)
+- brcmf_err("setting ssid failed %d\n", err);
++ bphy_err(wiphy, "setting ssid failed %d\n", err);
+
+ return err;
+ }
+@@ -609,7 +611,7 @@ struct wireless_dev *brcmf_ap_add_vif(st
+ BRCMF_VIF_EVENT_TIMEOUT);
+ brcmf_cfg80211_arm_vif_event(cfg, NULL);
+ if (!err) {
+- brcmf_err("timeout occurred\n");
++ bphy_err(wiphy, "timeout occurred\n");
+ err = -EIO;
+ goto fail;
+ }
+@@ -617,7 +619,7 @@ struct wireless_dev *brcmf_ap_add_vif(st
+ /* interface created in firmware */
+ ifp = vif->ifp;
+ if (!ifp) {
+- brcmf_err("no if pointer provided\n");
++ bphy_err(wiphy, "no if pointer provided\n");
+ err = -ENOENT;
+ goto fail;
+ }
+@@ -625,7 +627,7 @@ struct wireless_dev *brcmf_ap_add_vif(st
+ strncpy(ifp->ndev->name, name, sizeof(ifp->ndev->name) - 1);
+ err = brcmf_net_attach(ifp, true);
+ if (err) {
+- brcmf_err("Registering netdevice failed\n");
++ bphy_err(wiphy, "Registering netdevice failed\n");
+ goto fail;
+ }
+
+@@ -662,7 +664,7 @@ static struct wireless_dev *brcmf_cfg802
+ brcmf_dbg(TRACE, "enter: %s type %d\n", name, type);
+ err = brcmf_vif_add_validate(wiphy_to_cfg(wiphy), type);
+ if (err) {
+- brcmf_err("iface validation failed: err=%d\n", err);
++ bphy_err(wiphy, "iface validation failed: err=%d\n", err);
+ return ERR_PTR(err);
+ }
+ switch (type) {
+@@ -687,8 +689,8 @@ static struct wireless_dev *brcmf_cfg802
+ }
+
+ if (IS_ERR(wdev))
+- brcmf_err("add iface %s type %d failed: err=%d\n",
+- name, type, (int)PTR_ERR(wdev));
++ bphy_err(wiphy, "add iface %s type %d failed: err=%d\n", name,
++ type, (int)PTR_ERR(wdev));
+ else
+ brcmf_cfg80211_update_proto_addr_mode(wdev);
+
+@@ -703,12 +705,13 @@ static void brcmf_scan_config_mpc(struct
+
+ void brcmf_set_mpc(struct brcmf_if *ifp, int mpc)
+ {
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ s32 err = 0;
+
+ if (check_vif_up(ifp->vif)) {
+ err = brcmf_fil_iovar_int_set(ifp, "mpc", mpc);
+ if (err) {
+- brcmf_err("fail to set mpc\n");
++ bphy_err(wiphy, "fail to set mpc\n");
+ return;
+ }
+ brcmf_dbg(INFO, "MPC : %d\n", mpc);
+@@ -793,7 +796,7 @@ static int brcmf_cfg80211_del_ap_iface(s
+
+ err = brcmf_fil_bsscfg_data_set(ifp, "interface_remove", NULL, 0);
+ if (err) {
+- brcmf_err("interface_remove failed %d\n", err);
++ bphy_err(wiphy, "interface_remove failed %d\n", err);
+ goto err_unarm;
+ }
+
+@@ -801,7 +804,7 @@ static int brcmf_cfg80211_del_ap_iface(s
+ ret = brcmf_cfg80211_wait_vif_event(cfg, BRCMF_E_IF_DEL,
+ BRCMF_VIF_EVENT_TIMEOUT);
+ if (!ret) {
+- brcmf_err("timeout occurred\n");
++ bphy_err(wiphy, "timeout occurred\n");
+ err = -EIO;
+ goto err_unarm;
+ }
+@@ -903,14 +906,14 @@ brcmf_cfg80211_change_iface(struct wiphy
+ }
+ err = brcmf_vif_change_validate(wiphy_to_cfg(wiphy), vif, type);
+ if (err) {
+- brcmf_err("iface validation failed: err=%d\n", err);
++ bphy_err(wiphy, "iface validation failed: err=%d\n", err);
+ return err;
+ }
+ switch (type) {
+ case NL80211_IFTYPE_MONITOR:
+ case NL80211_IFTYPE_WDS:
+- brcmf_err("type (%d) : currently we do not support this type\n",
+- type);
++ bphy_err(wiphy, "type (%d) : currently we do not support this type\n",
++ type);
+ return -EOPNOTSUPP;
+ case NL80211_IFTYPE_ADHOC:
+ infra = 0;
+@@ -938,7 +941,7 @@ brcmf_cfg80211_change_iface(struct wiphy
+ } else {
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_INFRA, infra);
+ if (err) {
+- brcmf_err("WLC_SET_INFRA error (%d)\n", err);
++ bphy_err(wiphy, "WLC_SET_INFRA error (%d)\n", err);
+ err = -EAGAIN;
+ goto done;
+ }
+@@ -1040,6 +1043,7 @@ static s32
+ brcmf_run_escan(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp,
+ struct cfg80211_scan_request *request)
+ {
++ struct wiphy *wiphy = cfg_to_wiphy(cfg);
+ s32 params_size = BRCMF_SCAN_PARAMS_FIXED_SIZE +
+ offsetof(struct brcmf_escan_params_le, params_le);
+ struct brcmf_escan_params_le *params;
+@@ -1071,7 +1075,7 @@ brcmf_run_escan(struct brcmf_cfg80211_in
+ if (err == -EBUSY)
+ brcmf_dbg(INFO, "system busy : escan canceled\n");
+ else
+- brcmf_err("error (%d)\n", err);
++ bphy_err(wiphy, "error (%d)\n", err);
+ }
+
+ kfree(params);
+@@ -1129,21 +1133,23 @@ brcmf_cfg80211_escan(struct wiphy *wiphy
+ brcmf_dbg(SCAN, "START ESCAN\n");
+
+ if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status)) {
+- brcmf_err("Scanning already: status (%lu)\n", cfg->scan_status);
++ bphy_err(wiphy, "Scanning already: status (%lu)\n",
++ cfg->scan_status);
+ return -EAGAIN;
+ }
+ if (test_bit(BRCMF_SCAN_STATUS_ABORT, &cfg->scan_status)) {
+- brcmf_err("Scanning being aborted: status (%lu)\n",
+- cfg->scan_status);
++ bphy_err(wiphy, "Scanning being aborted: status (%lu)\n",
++ cfg->scan_status);
+ return -EAGAIN;
+ }
+ if (test_bit(BRCMF_SCAN_STATUS_SUPPRESS, &cfg->scan_status)) {
+- brcmf_err("Scanning suppressed: status (%lu)\n",
+- cfg->scan_status);
++ bphy_err(wiphy, "Scanning suppressed: status (%lu)\n",
++ cfg->scan_status);
+ return -EAGAIN;
+ }
+ if (test_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state)) {
+- brcmf_err("Connecting: status (%lu)\n", ifp->vif->sme_state);
++ bphy_err(wiphy, "Connecting: status (%lu)\n",
++ ifp->vif->sme_state);
+ return -EAGAIN;
+ }
+
+@@ -1235,7 +1241,7 @@ brcmf_cfg80211_scan(struct wiphy *wiphy,
+ err = brcmf_cfg80211_escan(wiphy, vif, request, NULL);
+
+ if (err)
+- brcmf_err("scan error (%d)\n", err);
++ bphy_err(wiphy, "scan error (%d)\n", err);
+
+ brcmf_dbg(TRACE, "Exit\n");
+ return err;
+@@ -1243,36 +1249,41 @@ brcmf_cfg80211_scan(struct wiphy *wiphy,
+
+ static s32 brcmf_set_rts(struct net_device *ndev, u32 rts_threshold)
+ {
++ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ s32 err = 0;
+
+- err = brcmf_fil_iovar_int_set(netdev_priv(ndev), "rtsthresh",
+- rts_threshold);
++ err = brcmf_fil_iovar_int_set(ifp, "rtsthresh", rts_threshold);
+ if (err)
+- brcmf_err("Error (%d)\n", err);
++ bphy_err(wiphy, "Error (%d)\n", err);
+
+ return err;
+ }
+
+ static s32 brcmf_set_frag(struct net_device *ndev, u32 frag_threshold)
+ {
++ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ s32 err = 0;
+
+- err = brcmf_fil_iovar_int_set(netdev_priv(ndev), "fragthresh",
++ err = brcmf_fil_iovar_int_set(ifp, "fragthresh",
+ frag_threshold);
+ if (err)
+- brcmf_err("Error (%d)\n", err);
++ bphy_err(wiphy, "Error (%d)\n", err);
+
+ return err;
+ }
+
+ static s32 brcmf_set_retry(struct net_device *ndev, u32 retry, bool l)
+ {
++ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ s32 err = 0;
+ u32 cmd = (l ? BRCMF_C_SET_LRL : BRCMF_C_SET_SRL);
+
+- err = brcmf_fil_cmd_int_set(netdev_priv(ndev), cmd, retry);
++ err = brcmf_fil_cmd_int_set(ifp, cmd, retry);
+ if (err) {
+- brcmf_err("cmd (%d) , error (%d)\n", cmd, err);
++ bphy_err(wiphy, "cmd (%d) , error (%d)\n", cmd, err);
+ return err;
+ }
+ return err;
+@@ -1349,6 +1360,7 @@ static u16 brcmf_map_fw_linkdown_reason(
+ static void brcmf_link_down(struct brcmf_cfg80211_vif *vif, u16 reason)
+ {
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(vif->wdev.wiphy);
++ struct wiphy *wiphy = cfg_to_wiphy(cfg);
+ s32 err = 0;
+
+ brcmf_dbg(TRACE, "Enter\n");
+@@ -1358,7 +1370,7 @@ static void brcmf_link_down(struct brcmf
+ err = brcmf_fil_cmd_data_set(vif->ifp,
+ BRCMF_C_DISASSOC, NULL, 0);
+ if (err) {
+- brcmf_err("WLC_DISASSOC failed (%d)\n", err);
++ bphy_err(wiphy, "WLC_DISASSOC failed (%d)\n", err);
+ }
+ if ((vif->wdev.iftype == NL80211_IFTYPE_STATION) ||
+ (vif->wdev.iftype == NL80211_IFTYPE_P2P_CLIENT))
+@@ -1442,7 +1454,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *w
+
+ err = brcmf_fil_iovar_int_set(ifp, "wsec", wsec);
+ if (err) {
+- brcmf_err("wsec failed (%d)\n", err);
++ bphy_err(wiphy, "wsec failed (%d)\n", err);
+ goto done;
+ }
+
+@@ -1454,7 +1466,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *w
+
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_BCNPRD, bcnprd);
+ if (err) {
+- brcmf_err("WLC_SET_BCNPRD failed (%d)\n", err);
++ bphy_err(wiphy, "WLC_SET_BCNPRD failed (%d)\n", err);
+ goto done;
+ }
+
+@@ -1499,7 +1511,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *w
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_CHANNEL,
+ target_channel);
+ if (err) {
+- brcmf_err("WLC_SET_CHANNEL failed (%d)\n", err);
++ bphy_err(wiphy, "WLC_SET_CHANNEL failed (%d)\n", err);
+ goto done;
+ }
+ } else
+@@ -1511,7 +1523,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *w
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_SSID,
+ &join_params, join_params_size);
+ if (err) {
+- brcmf_err("WLC_SET_SSID failed (%d)\n", err);
++ bphy_err(wiphy, "WLC_SET_SSID failed (%d)\n", err);
+ goto done;
+ }
+
+@@ -1547,6 +1559,8 @@ brcmf_cfg80211_leave_ibss(struct wiphy *
+ static s32 brcmf_set_wpa_version(struct net_device *ndev,
+ struct cfg80211_connect_params *sme)
+ {
++ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ struct brcmf_cfg80211_profile *profile = ndev_to_prof(ndev);
+ struct brcmf_cfg80211_security *sec;
+ s32 val = 0;
+@@ -1559,9 +1573,9 @@ static s32 brcmf_set_wpa_version(struct
+ else
+ val = WPA_AUTH_DISABLED;
+ brcmf_dbg(CONN, "setting wpa_auth to 0x%0x\n", val);
+- err = brcmf_fil_bsscfg_int_set(netdev_priv(ndev), "wpa_auth", val);
++ err = brcmf_fil_bsscfg_int_set(ifp, "wpa_auth", val);
+ if (err) {
+- brcmf_err("set wpa_auth failed (%d)\n", err);
++ bphy_err(wiphy, "set wpa_auth failed (%d)\n", err);
+ return err;
+ }
+ sec = &profile->sec;
+@@ -1572,6 +1586,8 @@ static s32 brcmf_set_wpa_version(struct
+ static s32 brcmf_set_auth_type(struct net_device *ndev,
+ struct cfg80211_connect_params *sme)
+ {
++ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ struct brcmf_cfg80211_profile *profile = ndev_to_prof(ndev);
+ struct brcmf_cfg80211_security *sec;
+ s32 val = 0;
+@@ -1592,9 +1608,9 @@ static s32 brcmf_set_auth_type(struct ne
+ break;
+ }
+
+- err = brcmf_fil_bsscfg_int_set(netdev_priv(ndev), "auth", val);
++ err = brcmf_fil_bsscfg_int_set(ifp, "auth", val);
+ if (err) {
+- brcmf_err("set auth failed (%d)\n", err);
++ bphy_err(wiphy, "set auth failed (%d)\n", err);
+ return err;
+ }
+ sec = &profile->sec;
+@@ -1606,6 +1622,8 @@ static s32
+ brcmf_set_wsec_mode(struct net_device *ndev,
+ struct cfg80211_connect_params *sme)
+ {
++ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ struct brcmf_cfg80211_profile *profile = ndev_to_prof(ndev);
+ struct brcmf_cfg80211_security *sec;
+ s32 pval = 0;
+@@ -1629,8 +1647,8 @@ brcmf_set_wsec_mode(struct net_device *n
+ pval = AES_ENABLED;
+ break;
+ default:
+- brcmf_err("invalid cipher pairwise (%d)\n",
+- sme->crypto.ciphers_pairwise[0]);
++ bphy_err(wiphy, "invalid cipher pairwise (%d)\n",
++ sme->crypto.ciphers_pairwise[0]);
+ return -EINVAL;
+ }
+ }
+@@ -1650,8 +1668,8 @@ brcmf_set_wsec_mode(struct net_device *n
+ gval = AES_ENABLED;
+ break;
+ default:
+- brcmf_err("invalid cipher group (%d)\n",
+- sme->crypto.cipher_group);
++ bphy_err(wiphy, "invalid cipher group (%d)\n",
++ sme->crypto.cipher_group);
+ return -EINVAL;
+ }
+ }
+@@ -1664,9 +1682,9 @@ brcmf_set_wsec_mode(struct net_device *n
+ pval = AES_ENABLED;
+
+ wsec = pval | gval;
+- err = brcmf_fil_bsscfg_int_set(netdev_priv(ndev), "wsec", wsec);
++ err = brcmf_fil_bsscfg_int_set(ifp, "wsec", wsec);
+ if (err) {
+- brcmf_err("error (%d)\n", err);
++ bphy_err(wiphy, "error (%d)\n", err);
+ return err;
+ }
+
+@@ -1681,6 +1699,7 @@ static s32
+ brcmf_set_key_mgmt(struct net_device *ndev, struct cfg80211_connect_params *sme)
+ {
+ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ s32 val;
+ s32 err;
+ const struct brcmf_tlv *rsn_ie;
+@@ -1696,7 +1715,7 @@ brcmf_set_key_mgmt(struct net_device *nd
+
+ err = brcmf_fil_bsscfg_int_get(netdev_priv(ndev), "wpa_auth", &val);
+ if (err) {
+- brcmf_err("could not get wpa_auth (%d)\n", err);
++ bphy_err(wiphy, "could not get wpa_auth (%d)\n", err);
+ return err;
+ }
+ if (val & (WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED)) {
+@@ -1708,8 +1727,8 @@ brcmf_set_key_mgmt(struct net_device *nd
+ val = WPA_AUTH_PSK;
+ break;
+ default:
+- brcmf_err("invalid cipher group (%d)\n",
+- sme->crypto.cipher_group);
++ bphy_err(wiphy, "invalid cipher group (%d)\n",
++ sme->crypto.cipher_group);
+ return -EINVAL;
+ }
+ } else if (val & (WPA2_AUTH_PSK | WPA2_AUTH_UNSPECIFIED)) {
+@@ -1727,8 +1746,8 @@ brcmf_set_key_mgmt(struct net_device *nd
+ val = WPA2_AUTH_PSK;
+ break;
+ default:
+- brcmf_err("invalid cipher group (%d)\n",
+- sme->crypto.cipher_group);
++ bphy_err(wiphy, "invalid cipher group (%d)\n",
++ sme->crypto.cipher_group);
+ return -EINVAL;
+ }
+ }
+@@ -1771,7 +1790,7 @@ skip_mfp_config:
+ brcmf_dbg(CONN, "setting wpa_auth to %d\n", val);
+ err = brcmf_fil_bsscfg_int_set(netdev_priv(ndev), "wpa_auth", val);
+ if (err) {
+- brcmf_err("could not set wpa_auth (%d)\n", err);
++ bphy_err(wiphy, "could not set wpa_auth (%d)\n", err);
+ return err;
+ }
+
+@@ -1782,6 +1801,8 @@ static s32
+ brcmf_set_sharedkey(struct net_device *ndev,
+ struct cfg80211_connect_params *sme)
+ {
++ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ struct brcmf_cfg80211_profile *profile = ndev_to_prof(ndev);
+ struct brcmf_cfg80211_security *sec;
+ struct brcmf_wsec_key key;
+@@ -1808,7 +1829,7 @@ brcmf_set_sharedkey(struct net_device *n
+ key.len = (u32) sme->key_len;
+ key.index = (u32) sme->key_idx;
+ if (key.len > sizeof(key.data)) {
+- brcmf_err("Too long key length (%u)\n", key.len);
++ bphy_err(wiphy, "Too long key length (%u)\n", key.len);
+ return -EINVAL;
+ }
+ memcpy(key.data, sme->key, key.len);
+@@ -1821,24 +1842,24 @@ brcmf_set_sharedkey(struct net_device *n
+ key.algo = CRYPTO_ALGO_WEP128;
+ break;
+ default:
+- brcmf_err("Invalid algorithm (%d)\n",
+- sme->crypto.ciphers_pairwise[0]);
++ bphy_err(wiphy, "Invalid algorithm (%d)\n",
++ sme->crypto.ciphers_pairwise[0]);
+ return -EINVAL;
+ }
+ /* Set the new key/index */
+ brcmf_dbg(CONN, "key length (%d) key index (%d) algo (%d)\n",
+ key.len, key.index, key.algo);
+ brcmf_dbg(CONN, "key \"%s\"\n", key.data);
+- err = send_key_to_dongle(netdev_priv(ndev), &key);
++ err = send_key_to_dongle(ifp, &key);
+ if (err)
+ return err;
+
+ if (sec->auth_type == NL80211_AUTHTYPE_SHARED_KEY) {
+ brcmf_dbg(CONN, "set auth_type to shared key\n");
+ val = WL_AUTH_SHARED_KEY; /* shared key */
+- err = brcmf_fil_bsscfg_int_set(netdev_priv(ndev), "auth", val);
++ err = brcmf_fil_bsscfg_int_set(ifp, "auth", val);
+ if (err)
+- brcmf_err("set auth failed (%d)\n", err);
++ bphy_err(wiphy, "set auth failed (%d)\n", err);
+ }
+ return err;
+ }
+@@ -1858,6 +1879,7 @@ enum nl80211_auth_type brcmf_war_auth_ty
+ static void brcmf_set_join_pref(struct brcmf_if *ifp,
+ struct cfg80211_bss_selection *bss_select)
+ {
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ struct brcmf_join_pref_params join_pref_params[2];
+ enum nl80211_band band;
+ int err, i = 0;
+@@ -1896,7 +1918,7 @@ static void brcmf_set_join_pref(struct b
+ err = brcmf_fil_iovar_data_set(ifp, "join_pref", join_pref_params,
+ sizeof(join_pref_params));
+ if (err)
+- brcmf_err("Set join_pref error (%d)\n", err);
++ bphy_err(wiphy, "Set join_pref error (%d)\n", err);
+ }
+
+ static s32
+@@ -1922,7 +1944,7 @@ brcmf_cfg80211_connect(struct wiphy *wip
+ return -EIO;
+
+ if (!sme->ssid) {
+- brcmf_err("Invalid ssid\n");
++ bphy_err(wiphy, "Invalid ssid\n");
+ return -EOPNOTSUPP;
+ }
+
+@@ -1951,7 +1973,7 @@ brcmf_cfg80211_connect(struct wiphy *wip
+ err = brcmf_vif_set_mgmt_ie(ifp->vif, BRCMF_VNDR_IE_ASSOCREQ_FLAG,
+ sme->ie, sme->ie_len);
+ if (err)
+- brcmf_err("Set Assoc REQ IE Failed\n");
++ bphy_err(wiphy, "Set Assoc REQ IE Failed\n");
+ else
+ brcmf_dbg(TRACE, "Applied Vndr IEs for Assoc request\n");
+
+@@ -1972,32 +1994,32 @@ brcmf_cfg80211_connect(struct wiphy *wip
+
+ err = brcmf_set_wpa_version(ndev, sme);
+ if (err) {
+- brcmf_err("wl_set_wpa_version failed (%d)\n", err);
++ bphy_err(wiphy, "wl_set_wpa_version failed (%d)\n", err);
+ goto done;
+ }
+
+ sme->auth_type = brcmf_war_auth_type(ifp, sme->auth_type);
+ err = brcmf_set_auth_type(ndev, sme);
+ if (err) {
+- brcmf_err("wl_set_auth_type failed (%d)\n", err);
++ bphy_err(wiphy, "wl_set_auth_type failed (%d)\n", err);
+ goto done;
+ }
+
+ err = brcmf_set_wsec_mode(ndev, sme);
+ if (err) {
+- brcmf_err("wl_set_set_cipher failed (%d)\n", err);
++ bphy_err(wiphy, "wl_set_set_cipher failed (%d)\n", err);
+ goto done;
+ }
+
+ err = brcmf_set_key_mgmt(ndev, sme);
+ if (err) {
+- brcmf_err("wl_set_key_mgmt failed (%d)\n", err);
++ bphy_err(wiphy, "wl_set_key_mgmt failed (%d)\n", err);
+ goto done;
+ }
+
+ err = brcmf_set_sharedkey(ndev, sme);
+ if (err) {
+- brcmf_err("brcmf_set_sharedkey failed (%d)\n", err);
++ bphy_err(wiphy, "brcmf_set_sharedkey failed (%d)\n", err);
+ goto done;
+ }
+
+@@ -2084,7 +2106,7 @@ brcmf_cfg80211_connect(struct wiphy *wip
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_SSID,
+ &join_params, join_params_size);
+ if (err)
+- brcmf_err("BRCMF_C_SET_SSID failed (%d)\n", err);
++ bphy_err(wiphy, "BRCMF_C_SET_SSID failed (%d)\n", err);
+
+ done:
+ if (err)
+@@ -2115,7 +2137,7 @@ brcmf_cfg80211_disconnect(struct wiphy *
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_DISASSOC,
+ &scbval, sizeof(scbval));
+ if (err)
+- brcmf_err("error (%d)\n", err);
++ bphy_err(wiphy, "error (%d)\n", err);
+
+ brcmf_dbg(TRACE, "Exit\n");
+ return err;
+@@ -2142,7 +2164,7 @@ brcmf_cfg80211_set_tx_power(struct wiphy
+ case NL80211_TX_POWER_LIMITED:
+ case NL80211_TX_POWER_FIXED:
+ if (mbm < 0) {
+- brcmf_err("TX_POWER_FIXED - dbm is negative\n");
++ bphy_err(wiphy, "TX_POWER_FIXED - dbm is negative\n");
+ err = -EINVAL;
+ goto done;
+ }
+@@ -2152,7 +2174,7 @@ brcmf_cfg80211_set_tx_power(struct wiphy
+ qdbm |= WL_TXPWR_OVERRIDE;
+ break;
+ default:
+- brcmf_err("Unsupported type %d\n", type);
++ bphy_err(wiphy, "Unsupported type %d\n", type);
+ err = -EINVAL;
+ goto done;
+ }
+@@ -2160,11 +2182,11 @@ brcmf_cfg80211_set_tx_power(struct wiphy
+ disable = WL_RADIO_SW_DISABLE << 16;
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_RADIO, disable);
+ if (err)
+- brcmf_err("WLC_SET_RADIO error (%d)\n", err);
++ bphy_err(wiphy, "WLC_SET_RADIO error (%d)\n", err);
+
+ err = brcmf_fil_iovar_int_set(ifp, "qtxpower", qdbm);
+ if (err)
+- brcmf_err("qtxpower error (%d)\n", err);
++ bphy_err(wiphy, "qtxpower error (%d)\n", err);
+
+ done:
+ brcmf_dbg(TRACE, "Exit %d (qdbm)\n", qdbm & ~WL_TXPWR_OVERRIDE);
+@@ -2185,7 +2207,7 @@ brcmf_cfg80211_get_tx_power(struct wiphy
+
+ err = brcmf_fil_iovar_int_get(vif->ifp, "qtxpower", &qdbm);
+ if (err) {
+- brcmf_err("error (%d)\n", err);
++ bphy_err(wiphy, "error (%d)\n", err);
+ goto done;
+ }
+ *dbm = (qdbm & ~WL_TXPWR_OVERRIDE) / 4;
+@@ -2211,7 +2233,7 @@ brcmf_cfg80211_config_default_key(struct
+
+ err = brcmf_fil_bsscfg_int_get(ifp, "wsec", &wsec);
+ if (err) {
+- brcmf_err("WLC_GET_WSEC error (%d)\n", err);
++ bphy_err(wiphy, "WLC_GET_WSEC error (%d)\n", err);
+ goto done;
+ }
+
+@@ -2221,7 +2243,7 @@ brcmf_cfg80211_config_default_key(struct
+ err = brcmf_fil_cmd_int_set(ifp,
+ BRCMF_C_SET_KEY_PRIMARY, index);
+ if (err)
+- brcmf_err("error (%d)\n", err);
++ bphy_err(wiphy, "error (%d)\n", err);
+ }
+ done:
+ brcmf_dbg(TRACE, "Exit\n");
+@@ -2285,7 +2307,7 @@ brcmf_cfg80211_add_key(struct wiphy *wip
+
+ if (key_idx >= BRCMF_MAX_DEFAULT_KEYS) {
+ /* we ignore this key index in this case */
+- brcmf_err("invalid key index (%d)\n", key_idx);
++ bphy_err(wiphy, "invalid key index (%d)\n", key_idx);
+ return -EINVAL;
+ }
+
+@@ -2294,7 +2316,7 @@ brcmf_cfg80211_add_key(struct wiphy *wip
+ mac_addr);
+
+ if (params->key_len > sizeof(key->data)) {
+- brcmf_err("Too long key length (%u)\n", params->key_len);
++ bphy_err(wiphy, "Too long key length (%u)\n", params->key_len);
+ return -EINVAL;
+ }
+
+@@ -2348,7 +2370,7 @@ brcmf_cfg80211_add_key(struct wiphy *wip
+ brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_CCMP\n");
+ break;
+ default:
+- brcmf_err("Invalid cipher (0x%x)\n", params->cipher);
++ bphy_err(wiphy, "Invalid cipher (0x%x)\n", params->cipher);
+ err = -EINVAL;
+ goto done;
+ }
+@@ -2359,13 +2381,13 @@ brcmf_cfg80211_add_key(struct wiphy *wip
+
+ err = brcmf_fil_bsscfg_int_get(ifp, "wsec", &wsec);
+ if (err) {
+- brcmf_err("get wsec error (%d)\n", err);
++ bphy_err(wiphy, "get wsec error (%d)\n", err);
+ goto done;
+ }
+ wsec |= val;
+ err = brcmf_fil_bsscfg_int_set(ifp, "wsec", wsec);
+ if (err) {
+- brcmf_err("set wsec error (%d)\n", err);
++ bphy_err(wiphy, "set wsec error (%d)\n", err);
+ goto done;
+ }
+
+@@ -2396,7 +2418,7 @@ brcmf_cfg80211_get_key(struct wiphy *wip
+
+ err = brcmf_fil_bsscfg_int_get(ifp, "wsec", &wsec);
+ if (err) {
+- brcmf_err("WLC_GET_WSEC error (%d)\n", err);
++ bphy_err(wiphy, "WLC_GET_WSEC error (%d)\n", err);
+ /* Ignore this error, may happen during DISASSOC */
+ err = -EAGAIN;
+ goto done;
+@@ -2417,7 +2439,7 @@ brcmf_cfg80211_get_key(struct wiphy *wip
+ params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
+ brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_AES_CMAC\n");
+ } else {
+- brcmf_err("Invalid algo (0x%x)\n", wsec);
++ bphy_err(wiphy, "Invalid algo (0x%x)\n", wsec);
+ err = -EINVAL;
+ goto done;
+ }
+@@ -2447,6 +2469,7 @@ brcmf_cfg80211_config_default_mgmt_key(s
+ static void
+ brcmf_cfg80211_reconfigure_wep(struct brcmf_if *ifp)
+ {
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ s32 err;
+ u8 key_idx;
+ struct brcmf_wsec_key *key;
+@@ -2463,18 +2486,18 @@ brcmf_cfg80211_reconfigure_wep(struct br
+
+ err = send_key_to_dongle(ifp, key);
+ if (err) {
+- brcmf_err("Setting WEP key failed (%d)\n", err);
++ bphy_err(wiphy, "Setting WEP key failed (%d)\n", err);
+ return;
+ }
+ err = brcmf_fil_bsscfg_int_get(ifp, "wsec", &wsec);
+ if (err) {
+- brcmf_err("get wsec error (%d)\n", err);
++ bphy_err(wiphy, "get wsec error (%d)\n", err);
+ return;
+ }
+ wsec |= WEP_ENABLED;
+ err = brcmf_fil_bsscfg_int_set(ifp, "wsec", wsec);
+ if (err)
+- brcmf_err("set wsec error (%d)\n", err);
++ bphy_err(wiphy, "set wsec error (%d)\n", err);
+ }
+
+ static void brcmf_convert_sta_flags(u32 fw_sta_flags, struct station_info *si)
+@@ -2500,6 +2523,7 @@ static void brcmf_convert_sta_flags(u32
+
+ static void brcmf_fill_bss_param(struct brcmf_if *ifp, struct station_info *si)
+ {
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ struct {
+ __le32 len;
+ struct brcmf_bss_info_le bss_le;
+@@ -2515,7 +2539,7 @@ static void brcmf_fill_bss_param(struct
+ err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_BSS_INFO, buf,
+ WL_BSS_INFO_MAX);
+ if (err) {
+- brcmf_err("Failed to get bss info (%d)\n", err);
++ bphy_err(wiphy, "Failed to get bss info (%d)\n", err);
+ goto out_kfree;
+ }
+ si->filled |= BIT(NL80211_STA_INFO_BSS_PARAM);
+@@ -2537,6 +2561,7 @@ static s32
+ brcmf_cfg80211_get_station_ibss(struct brcmf_if *ifp,
+ struct station_info *sinfo)
+ {
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ struct brcmf_scb_val_le scbval;
+ struct brcmf_pktcnt_le pktcnt;
+ s32 err;
+@@ -2546,7 +2571,7 @@ brcmf_cfg80211_get_station_ibss(struct b
+ /* Get the current tx rate */
+ err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_RATE, &rate);
+ if (err < 0) {
+- brcmf_err("BRCMF_C_GET_RATE error (%d)\n", err);
++ bphy_err(wiphy, "BRCMF_C_GET_RATE error (%d)\n", err);
+ return err;
+ }
+ sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE);
+@@ -2556,7 +2581,7 @@ brcmf_cfg80211_get_station_ibss(struct b
+ err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_RSSI, &scbval,
+ sizeof(scbval));
+ if (err) {
+- brcmf_err("BRCMF_C_GET_RSSI error (%d)\n", err);
++ bphy_err(wiphy, "BRCMF_C_GET_RSSI error (%d)\n", err);
+ return err;
+ }
+ rssi = le32_to_cpu(scbval.val);
+@@ -2566,7 +2591,7 @@ brcmf_cfg80211_get_station_ibss(struct b
+ err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_GET_PKTCNTS, &pktcnt,
+ sizeof(pktcnt));
+ if (err) {
+- brcmf_err("BRCMF_C_GET_GET_PKTCNTS error (%d)\n", err);
++ bphy_err(wiphy, "BRCMF_C_GET_GET_PKTCNTS error (%d)\n", err);
+ return err;
+ }
+ sinfo->filled |= BIT(NL80211_STA_INFO_RX_PACKETS) |
+@@ -2614,7 +2639,7 @@ brcmf_cfg80211_get_station(struct wiphy
+ &sta_info_le,
+ sizeof(sta_info_le));
+ if (err < 0) {
+- brcmf_err("GET STA INFO failed, %d\n", err);
++ bphy_err(wiphy, "GET STA INFO failed, %d\n", err);
+ goto done;
+ }
+ }
+@@ -2683,7 +2708,8 @@ brcmf_cfg80211_get_station(struct wiphy
+ err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_RSSI,
+ &scb_val, sizeof(scb_val));
+ if (err) {
+- brcmf_err("Could not get rssi (%d)\n", err);
++ bphy_err(wiphy, "Could not get rssi (%d)\n",
++ err);
+ goto done;
+ } else {
+ rssi = le32_to_cpu(scb_val.val);
+@@ -2714,8 +2740,8 @@ brcmf_cfg80211_dump_station(struct wiphy
+ &cfg->assoclist,
+ sizeof(cfg->assoclist));
+ if (err) {
+- brcmf_err("BRCMF_C_GET_ASSOCLIST unsupported, err=%d\n",
+- err);
++ bphy_err(wiphy, "BRCMF_C_GET_ASSOCLIST unsupported, err=%d\n",
++ err);
+ cfg->assoclist.count = 0;
+ return -EOPNOTSUPP;
+ }
+@@ -2763,9 +2789,9 @@ brcmf_cfg80211_set_power_mgmt(struct wip
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_PM, pm);
+ if (err) {
+ if (err == -ENODEV)
+- brcmf_err("net_device is not ready yet\n");
++ bphy_err(wiphy, "net_device is not ready yet\n");
+ else
+- brcmf_err("error (%d)\n", err);
++ bphy_err(wiphy, "error (%d)\n", err);
+ }
+ done:
+ brcmf_dbg(TRACE, "Exit\n");
+@@ -2789,7 +2815,7 @@ static s32 brcmf_inform_single_bss(struc
+ s32 notify_signal;
+
+ if (le32_to_cpu(bi->length) > WL_BSS_INFO_MAX) {
+- brcmf_err("Bss info is larger than buffer. Discarding\n");
++ bphy_err(wiphy, "Bss info is larger than buffer. Discarding\n");
+ return 0;
+ }
+
+@@ -2847,6 +2873,7 @@ next_bss_le(struct brcmf_scan_results *l
+
+ static s32 brcmf_inform_bss(struct brcmf_cfg80211_info *cfg)
+ {
++ struct wiphy *wiphy = cfg_to_wiphy(cfg);
+ struct brcmf_scan_results *bss_list;
+ struct brcmf_bss_info_le *bi = NULL; /* must be initialized */
+ s32 err = 0;
+@@ -2855,8 +2882,8 @@ static s32 brcmf_inform_bss(struct brcmf
+ bss_list = (struct brcmf_scan_results *)cfg->escan_info.escan_buf;
+ if (bss_list->count != 0 &&
+ bss_list->version != BRCMF_BSS_INFO_VERSION) {
+- brcmf_err("Version %d != WL_BSS_INFO_VERSION\n",
+- bss_list->version);
++ bphy_err(wiphy, "Version %d != WL_BSS_INFO_VERSION\n",
++ bss_list->version);
+ return -EOPNOTSUPP;
+ }
+ brcmf_dbg(SCAN, "scanned AP count (%d)\n", bss_list->count);
+@@ -2900,7 +2927,7 @@ static s32 brcmf_inform_ibss(struct brcm
+ err = brcmf_fil_cmd_data_get(netdev_priv(ndev), BRCMF_C_GET_BSS_INFO,
+ buf, WL_BSS_INFO_MAX);
+ if (err) {
+- brcmf_err("WLC_GET_BSS_INFO failed: %d\n", err);
++ bphy_err(wiphy, "WLC_GET_BSS_INFO failed: %d\n", err);
+ goto CleanUp;
+ }
+
+@@ -2954,6 +2981,7 @@ CleanUp:
+ static s32 brcmf_update_bss_info(struct brcmf_cfg80211_info *cfg,
+ struct brcmf_if *ifp)
+ {
++ struct wiphy *wiphy = cfg_to_wiphy(cfg);
+ struct brcmf_bss_info_le *bi;
+ const struct brcmf_tlv *tim;
+ u16 beacon_interval;
+@@ -2970,7 +2998,7 @@ static s32 brcmf_update_bss_info(struct
+ err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_BSS_INFO,
+ cfg->extra_buf, WL_EXTRA_BUF_MAX);
+ if (err) {
+- brcmf_err("Could not get bss info %d\n", err);
++ bphy_err(wiphy, "Could not get bss info %d\n", err);
+ goto update_bss_info_out;
+ }
+
+@@ -2995,7 +3023,7 @@ static s32 brcmf_update_bss_info(struct
+ u32 var;
+ err = brcmf_fil_iovar_int_get(ifp, "dtim_assoc", &var);
+ if (err) {
+- brcmf_err("wl dtim_assoc failed (%d)\n", err);
++ bphy_err(wiphy, "wl dtim_assoc failed (%d)\n", err);
+ goto update_bss_info_out;
+ }
+ dtim_period = (u8)var;
+@@ -3033,9 +3061,10 @@ static void brcmf_escan_timeout(unsigned
+ {
+ struct brcmf_cfg80211_info *cfg =
+ (struct brcmf_cfg80211_info *)data;
++ struct wiphy *wiphy = cfg_to_wiphy(cfg);
+
+ if (cfg->internal_escan || cfg->scan_request) {
+- brcmf_err("timer expired\n");
++ bphy_err(wiphy, "timer expired\n");
+ schedule_work(&cfg->escan_timeout_work);
+ }
+ }
+@@ -3084,6 +3113,7 @@ brcmf_cfg80211_escan_handler(struct brcm
+ const struct brcmf_event_msg *e, void *data)
+ {
+ struct brcmf_cfg80211_info *cfg = ifp->drvr->config;
++ struct wiphy *wiphy = cfg_to_wiphy(cfg);
+ s32 status;
+ struct brcmf_escan_result_le *escan_result_le;
+ u32 escan_buflen;
+@@ -3100,32 +3130,33 @@ brcmf_cfg80211_escan_handler(struct brcm
+ goto exit;
+
+ if (!test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status)) {
+- brcmf_err("scan not ready, bsscfgidx=%d\n", ifp->bsscfgidx);
++ bphy_err(wiphy, "scan not ready, bsscfgidx=%d\n",
++ ifp->bsscfgidx);
+ return -EPERM;
+ }
+
+ if (status == BRCMF_E_STATUS_PARTIAL) {
+ brcmf_dbg(SCAN, "ESCAN Partial result\n");
+ if (e->datalen < sizeof(*escan_result_le)) {
+- brcmf_err("invalid event data length\n");
++ bphy_err(wiphy, "invalid event data length\n");
+ goto exit;
+ }
+ escan_result_le = (struct brcmf_escan_result_le *) data;
+ if (!escan_result_le) {
+- brcmf_err("Invalid escan result (NULL pointer)\n");
++ bphy_err(wiphy, "Invalid escan result (NULL pointer)\n");
+ goto exit;
+ }
+ escan_buflen = le32_to_cpu(escan_result_le->buflen);
+ if (escan_buflen > BRCMF_ESCAN_BUF_SIZE ||
+ escan_buflen > e->datalen ||
+ escan_buflen < sizeof(*escan_result_le)) {
+- brcmf_err("Invalid escan buffer length: %d\n",
+- escan_buflen);
++ bphy_err(wiphy, "Invalid escan buffer length: %d\n",
++ escan_buflen);
+ goto exit;
+ }
+ if (le16_to_cpu(escan_result_le->bss_count) != 1) {
+- brcmf_err("Invalid bss_count %d: ignoring\n",
+- escan_result_le->bss_count);
++ bphy_err(wiphy, "Invalid bss_count %d: ignoring\n",
++ escan_result_le->bss_count);
+ goto exit;
+ }
+ bss_info_le = &escan_result_le->bss_info_le;
+@@ -3140,8 +3171,8 @@ brcmf_cfg80211_escan_handler(struct brcm
+
+ bi_length = le32_to_cpu(bss_info_le->length);
+ if (bi_length != escan_buflen - WL_ESCAN_RESULTS_FIXED_SIZE) {
+- brcmf_err("Ignoring invalid bss_info length: %d\n",
+- bi_length);
++ bphy_err(wiphy, "Ignoring invalid bss_info length: %d\n",
++ bi_length);
+ goto exit;
+ }
+
+@@ -3149,7 +3180,7 @@ brcmf_cfg80211_escan_handler(struct brcm
+ BIT(NL80211_IFTYPE_ADHOC))) {
+ if (le16_to_cpu(bss_info_le->capability) &
+ WLAN_CAPABILITY_IBSS) {
+- brcmf_err("Ignoring IBSS result\n");
++ bphy_err(wiphy, "Ignoring IBSS result\n");
+ goto exit;
+ }
+ }
+@@ -3157,7 +3188,7 @@ brcmf_cfg80211_escan_handler(struct brcm
+ list = (struct brcmf_scan_results *)
+ cfg->escan_info.escan_buf;
+ if (bi_length > BRCMF_ESCAN_BUF_SIZE - list->buflen) {
+- brcmf_err("Buffer is too small: ignoring\n");
++ bphy_err(wiphy, "Buffer is too small: ignoring\n");
+ goto exit;
+ }
+
+@@ -3346,14 +3377,14 @@ brcmf_notify_sched_scan_results(struct b
+ WARN_ON(status != BRCMF_PNO_SCAN_COMPLETE);
+ brcmf_dbg(SCAN, "PFN NET FOUND event. count: %d\n", result_count);
+ if (!result_count) {
+- brcmf_err("FALSE PNO Event. (pfn_count == 0)\n");
++ bphy_err(wiphy, "FALSE PNO Event. (pfn_count == 0)\n");
+ goto out_err;
+ }
+
+ netinfo_start = brcmf_get_netinfo_array(pfn_result);
+ datalen = e->datalen - ((void *)netinfo_start - (void *)pfn_result);
+ if (datalen < result_count * sizeof(*netinfo)) {
+- brcmf_err("insufficient event data\n");
++ bphy_err(wiphy, "insufficient event data\n");
+ goto out_err;
+ }
+
+@@ -3402,8 +3433,8 @@ brcmf_cfg80211_sched_scan_start(struct w
+ req->n_match_sets, req->n_ssids);
+
+ if (test_bit(BRCMF_SCAN_STATUS_SUPPRESS, &cfg->scan_status)) {
+- brcmf_err("Scanning suppressed: status (%lu)\n",
+- cfg->scan_status);
++ bphy_err(wiphy, "Scanning suppressed: status (%lu)\n",
++ cfg->scan_status);
+ return -EAGAIN;
+ }
+
+@@ -3482,6 +3513,7 @@ brcmf_wowl_nd_results(struct brcmf_if *i
+ void *data)
+ {
+ struct brcmf_cfg80211_info *cfg = ifp->drvr->config;
++ struct wiphy *wiphy = cfg_to_wiphy(cfg);
+ struct brcmf_pno_scanresults_le *pfn_result;
+ struct brcmf_pno_net_info_le *netinfo;
+
+@@ -3500,8 +3532,8 @@ brcmf_wowl_nd_results(struct brcmf_if *i
+ }
+
+ if (le32_to_cpu(pfn_result->count) < 1) {
+- brcmf_err("Invalid result count, expected 1 (%d)\n",
+- le32_to_cpu(pfn_result->count));
++ bphy_err(wiphy, "Invalid result count, expected 1 (%d)\n",
++ le32_to_cpu(pfn_result->count));
+ return -EINVAL;
+ }
+
+@@ -3538,7 +3570,7 @@ static void brcmf_report_wowl_wakeind(st
+ err = brcmf_fil_iovar_data_get(ifp, "wowl_wakeind", &wake_ind_le,
+ sizeof(wake_ind_le));
+ if (err) {
+- brcmf_err("Get wowl_wakeind failed, err = %d\n", err);
++ bphy_err(wiphy, "Get wowl_wakeind failed, err = %d\n", err);
+ return;
+ }
+
+@@ -3579,7 +3611,7 @@ static void brcmf_report_wowl_wakeind(st
+ cfg->wowl.nd_data_completed,
+ BRCMF_ND_INFO_TIMEOUT);
+ if (!timeout)
+- brcmf_err("No result for wowl net detect\n");
++ bphy_err(wiphy, "No result for wowl net detect\n");
+ else
+ wakeup_data.net_detect = cfg->wowl.nd_info;
+ }
+@@ -3787,7 +3819,7 @@ brcmf_cfg80211_set_pmksa(struct wiphy *w
+ cfg->pmk_list.npmk = cpu_to_le32(npmk);
+ }
+ } else {
+- brcmf_err("Too many PMKSA entries cached %d\n", npmk);
++ bphy_err(wiphy, "Too many PMKSA entries cached %d\n", npmk);
+ return -EINVAL;
+ }
+
+@@ -3833,7 +3865,7 @@ brcmf_cfg80211_del_pmksa(struct wiphy *w
+ memset(&pmk[i], 0, sizeof(*pmk));
+ cfg->pmk_list.npmk = cpu_to_le32(npmk - 1);
+ } else {
+- brcmf_err("Cache entry not found\n");
++ bphy_err(wiphy, "Cache entry not found\n");
+ return -EINVAL;
+ }
+
+@@ -3865,24 +3897,25 @@ brcmf_cfg80211_flush_pmksa(struct wiphy
+
+ static s32 brcmf_configure_opensecurity(struct brcmf_if *ifp)
+ {
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ s32 err;
+
+ /* set auth */
+ err = brcmf_fil_bsscfg_int_set(ifp, "auth", 0);
+ if (err < 0) {
+- brcmf_err("auth error %d\n", err);
++ bphy_err(wiphy, "auth error %d\n", err);
+ return err;
+ }
+ /* set wsec */
+ err = brcmf_fil_bsscfg_int_set(ifp, "wsec", 0);
+ if (err < 0) {
+- brcmf_err("wsec error %d\n", err);
++ bphy_err(wiphy, "wsec error %d\n", err);
+ return err;
+ }
+ /* set upper-layer auth */
+ err = brcmf_fil_bsscfg_int_set(ifp, "wpa_auth", WPA_AUTH_NONE);
+ if (err < 0) {
+- brcmf_err("wpa_auth error %d\n", err);
++ bphy_err(wiphy, "wpa_auth error %d\n", err);
+ return err;
+ }
+
+@@ -3902,6 +3935,7 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ const struct brcmf_vs_tlv *wpa_ie,
+ bool is_rsn_ie)
+ {
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ u32 auth = 0; /* d11 open authentication */
+ u16 count;
+ s32 err = 0;
+@@ -3932,13 +3966,13 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ /* check for multicast cipher suite */
+ if (offset + WPA_IE_MIN_OUI_LEN > len) {
+ err = -EINVAL;
+- brcmf_err("no multicast cipher suite\n");
++ bphy_err(wiphy, "no multicast cipher suite\n");
+ goto exit;
+ }
+
+ if (!brcmf_valid_wpa_oui(&data[offset], is_rsn_ie)) {
+ err = -EINVAL;
+- brcmf_err("ivalid OUI\n");
++ bphy_err(wiphy, "ivalid OUI\n");
+ goto exit;
+ }
+ offset += TLV_OUI_LEN;
+@@ -3960,7 +3994,7 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ break;
+ default:
+ err = -EINVAL;
+- brcmf_err("Invalid multi cast cipher info\n");
++ bphy_err(wiphy, "Invalid multi cast cipher info\n");
+ goto exit;
+ }
+
+@@ -3971,13 +4005,13 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ /* Check for unicast suite(s) */
+ if (offset + (WPA_IE_MIN_OUI_LEN * count) > len) {
+ err = -EINVAL;
+- brcmf_err("no unicast cipher suite\n");
++ bphy_err(wiphy, "no unicast cipher suite\n");
+ goto exit;
+ }
+ for (i = 0; i < count; i++) {
+ if (!brcmf_valid_wpa_oui(&data[offset], is_rsn_ie)) {
+ err = -EINVAL;
+- brcmf_err("ivalid OUI\n");
++ bphy_err(wiphy, "ivalid OUI\n");
+ goto exit;
+ }
+ offset += TLV_OUI_LEN;
+@@ -3995,7 +4029,7 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ pval |= AES_ENABLED;
+ break;
+ default:
+- brcmf_err("Invalid unicast security info\n");
++ bphy_err(wiphy, "Invalid unicast security info\n");
+ }
+ offset++;
+ }
+@@ -4005,13 +4039,13 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ /* Check for auth key management suite(s) */
+ if (offset + (WPA_IE_MIN_OUI_LEN * count) > len) {
+ err = -EINVAL;
+- brcmf_err("no auth key mgmt suite\n");
++ bphy_err(wiphy, "no auth key mgmt suite\n");
+ goto exit;
+ }
+ for (i = 0; i < count; i++) {
+ if (!brcmf_valid_wpa_oui(&data[offset], is_rsn_ie)) {
+ err = -EINVAL;
+- brcmf_err("ivalid OUI\n");
++ bphy_err(wiphy, "ivalid OUI\n");
+ goto exit;
+ }
+ offset += TLV_OUI_LEN;
+@@ -4039,7 +4073,7 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ wpa_auth |= WPA2_AUTH_1X_SHA256;
+ break;
+ default:
+- brcmf_err("Invalid key mgmt info\n");
++ bphy_err(wiphy, "Invalid key mgmt info\n");
+ }
+ offset++;
+ }
+@@ -4081,7 +4115,7 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ err = brcmf_fil_bsscfg_int_set(ifp, "wme_bss_disable",
+ wme_bss_disable);
+ if (err < 0) {
+- brcmf_err("wme_bss_disable error %d\n", err);
++ bphy_err(wiphy, "wme_bss_disable error %d\n", err);
+ goto exit;
+ }
+
+@@ -4095,7 +4129,7 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ &data[offset],
+ WPA_IE_MIN_OUI_LEN);
+ if (err < 0) {
+- brcmf_err("bip error %d\n", err);
++ bphy_err(wiphy, "bip error %d\n", err);
+ goto exit;
+ }
+ }
+@@ -4106,13 +4140,13 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ /* set auth */
+ err = brcmf_fil_bsscfg_int_set(ifp, "auth", auth);
+ if (err < 0) {
+- brcmf_err("auth error %d\n", err);
++ bphy_err(wiphy, "auth error %d\n", err);
+ goto exit;
+ }
+ /* set wsec */
+ err = brcmf_fil_bsscfg_int_set(ifp, "wsec", wsec);
+ if (err < 0) {
+- brcmf_err("wsec error %d\n", err);
++ bphy_err(wiphy, "wsec error %d\n", err);
+ goto exit;
+ }
+ /* Configure MFP, this needs to go after wsec otherwise the wsec command
+@@ -4121,14 +4155,14 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MFP)) {
+ err = brcmf_fil_bsscfg_int_set(ifp, "mfp", mfp);
+ if (err < 0) {
+- brcmf_err("mfp error %d\n", err);
++ bphy_err(wiphy, "mfp error %d\n", err);
+ goto exit;
+ }
+ }
+ /* set upper-layer auth */
+ err = brcmf_fil_bsscfg_int_set(ifp, "wpa_auth", wpa_auth);
+ if (err < 0) {
+- brcmf_err("wpa_auth error %d\n", err);
++ bphy_err(wiphy, "wpa_auth error %d\n", err);
+ goto exit;
+ }
+
+@@ -4215,6 +4249,7 @@ s32 brcmf_vif_set_mgmt_ie(struct brcmf_c
+ const u8 *vndr_ie_buf, u32 vndr_ie_len)
+ {
+ struct brcmf_if *ifp;
++ struct wiphy *wiphy;
+ struct vif_saved_ie *saved_ie;
+ s32 err = 0;
+ u8 *iovar_ie_buf;
+@@ -4235,6 +4270,7 @@ s32 brcmf_vif_set_mgmt_ie(struct brcmf_c
+ if (!vif)
+ return -ENODEV;
+ ifp = vif->ifp;
++ wiphy = ifp->drvr->wiphy;
+ saved_ie = &vif->saved_ie;
+
+ brcmf_dbg(TRACE, "bsscfgidx %d, pktflag : 0x%02X\n", ifp->bsscfgidx,
+@@ -4266,13 +4302,13 @@ s32 brcmf_vif_set_mgmt_ie(struct brcmf_c
+ break;
+ default:
+ err = -EPERM;
+- brcmf_err("not suitable type\n");
++ bphy_err(wiphy, "not suitable type\n");
+ goto exit;
+ }
+
+ if (vndr_ie_len > mgmt_ie_buf_len) {
+ err = -ENOMEM;
+- brcmf_err("extra IE size too big\n");
++ bphy_err(wiphy, "extra IE size too big\n");
+ goto exit;
+ }
+
+@@ -4333,8 +4369,8 @@ s32 brcmf_vif_set_mgmt_ie(struct brcmf_c
+ /* verify remained buf size before copy data */
+ if (remained_buf_len < (vndrie_info->vndrie.len +
+ VNDR_IE_VSIE_OFFSET)) {
+- brcmf_err("no space in mgmt_ie_buf: len left %d",
+- remained_buf_len);
++ bphy_err(wiphy, "no space in mgmt_ie_buf: len left %d",
++ remained_buf_len);
+ break;
+ }
+ remained_buf_len -= (vndrie_info->ie_len +
+@@ -4365,7 +4401,7 @@ s32 brcmf_vif_set_mgmt_ie(struct brcmf_c
+ err = brcmf_fil_bsscfg_data_set(ifp, "vndr_ie", iovar_ie_buf,
+ total_ie_buf_len);
+ if (err)
+- brcmf_err("vndr ie set error : %d\n", err);
++ bphy_err(wiphy, "vndr ie set error : %d\n", err);
+ }
+
+ exit:
+@@ -4393,13 +4429,14 @@ static s32
+ brcmf_config_ap_mgmt_ie(struct brcmf_cfg80211_vif *vif,
+ struct cfg80211_beacon_data *beacon)
+ {
++ struct wiphy *wiphy = vif->ifp->drvr->wiphy;
+ s32 err;
+
+ /* Set Beacon IEs to FW */
+ err = brcmf_vif_set_mgmt_ie(vif, BRCMF_VNDR_IE_BEACON_FLAG,
+ beacon->tail, beacon->tail_len);
+ if (err) {
+- brcmf_err("Set Beacon IE Failed\n");
++ bphy_err(wiphy, "Set Beacon IE Failed\n");
+ return err;
+ }
+ brcmf_dbg(TRACE, "Applied Vndr IEs for Beacon\n");
+@@ -4409,7 +4446,7 @@ brcmf_config_ap_mgmt_ie(struct brcmf_cfg
+ beacon->proberesp_ies,
+ beacon->proberesp_ies_len);
+ if (err)
+- brcmf_err("Set Probe Resp IE Failed\n");
++ bphy_err(wiphy, "Set Probe Resp IE Failed\n");
+ else
+ brcmf_dbg(TRACE, "Applied Vndr IEs for Probe Resp\n");
+
+@@ -4518,7 +4555,8 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_REGULATORY,
+ is_11d);
+ if (err < 0) {
+- brcmf_err("Regulatory Set Error, %d\n", err);
++ bphy_err(wiphy, "Regulatory Set Error, %d\n",
++ err);
+ goto exit;
+ }
+ }
+@@ -4526,8 +4564,8 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_BCNPRD,
+ settings->beacon_interval);
+ if (err < 0) {
+- brcmf_err("Beacon Interval Set Error, %d\n",
+- err);
++ bphy_err(wiphy, "Beacon Interval Set Error, %d\n",
++ err);
+ goto exit;
+ }
+ }
+@@ -4535,7 +4573,8 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_DTIMPRD,
+ settings->dtim_period);
+ if (err < 0) {
+- brcmf_err("DTIM Interval Set Error, %d\n", err);
++ bphy_err(wiphy, "DTIM Interval Set Error, %d\n",
++ err);
+ goto exit;
+ }
+ }
+@@ -4545,7 +4584,8 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+ !brcmf_feat_is_enabled(ifp, BRCMF_FEAT_RSDB))) {
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_DOWN, 1);
+ if (err < 0) {
+- brcmf_err("BRCMF_C_DOWN error %d\n", err);
++ bphy_err(wiphy, "BRCMF_C_DOWN error %d\n",
++ err);
+ goto exit;
+ }
+ brcmf_fil_iovar_int_set(ifp, "apsta", 0);
+@@ -4553,7 +4593,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_INFRA, 1);
+ if (err < 0) {
+- brcmf_err("SET INFRA error %d\n", err);
++ bphy_err(wiphy, "SET INFRA error %d\n", err);
+ goto exit;
+ }
+ } else if (WARN_ON(supports_11d && (is_11d != ifp->vif->is_11d))) {
+@@ -4569,7 +4609,8 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_AP, 1);
+ if (err < 0) {
+- brcmf_err("setting AP mode failed %d\n", err);
++ bphy_err(wiphy, "setting AP mode failed %d\n",
++ err);
+ goto exit;
+ }
+ if (!mbss) {
+@@ -4578,14 +4619,14 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+ */
+ err = brcmf_fil_iovar_int_set(ifp, "chanspec", chanspec);
+ if (err < 0) {
+- brcmf_err("Set Channel failed: chspec=%d, %d\n",
+- chanspec, err);
++ bphy_err(wiphy, "Set Channel failed: chspec=%d, %d\n",
++ chanspec, err);
+ goto exit;
+ }
+ }
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_UP, 1);
+ if (err < 0) {
+- brcmf_err("BRCMF_C_UP error (%d)\n", err);
++ bphy_err(wiphy, "BRCMF_C_UP error (%d)\n", err);
+ goto exit;
+ }
+ /* On DOWN the firmware removes the WEP keys, reconfigure
+@@ -4600,14 +4641,14 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_SSID,
+ &join_params, sizeof(join_params));
+ if (err < 0) {
+- brcmf_err("SET SSID error (%d)\n", err);
++ bphy_err(wiphy, "SET SSID error (%d)\n", err);
+ goto exit;
+ }
+
+ if (settings->hidden_ssid) {
+ err = brcmf_fil_iovar_int_set(ifp, "closednet", 1);
+ if (err) {
+- brcmf_err("closednet error (%d)\n", err);
++ bphy_err(wiphy, "closednet error (%d)\n", err);
+ goto exit;
+ }
+ }
+@@ -4616,14 +4657,14 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+ } else if (dev_role == NL80211_IFTYPE_P2P_GO) {
+ err = brcmf_fil_iovar_int_set(ifp, "chanspec", chanspec);
+ if (err < 0) {
+- brcmf_err("Set Channel failed: chspec=%d, %d\n",
+- chanspec, err);
++ bphy_err(wiphy, "Set Channel failed: chspec=%d, %d\n",
++ chanspec, err);
+ goto exit;
+ }
+ err = brcmf_fil_bsscfg_data_set(ifp, "ssid", &ssid_le,
+ sizeof(ssid_le));
+ if (err < 0) {
+- brcmf_err("setting ssid failed %d\n", err);
++ bphy_err(wiphy, "setting ssid failed %d\n", err);
+ goto exit;
+ }
+ bss_enable.bsscfgidx = cpu_to_le32(ifp->bsscfgidx);
+@@ -4631,7 +4672,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+ err = brcmf_fil_iovar_data_set(ifp, "bss", &bss_enable,
+ sizeof(bss_enable));
+ if (err < 0) {
+- brcmf_err("bss_enable config failed %d\n", err);
++ bphy_err(wiphy, "bss_enable config failed %d\n", err);
+ goto exit;
+ }
+
+@@ -4679,13 +4720,13 @@ static int brcmf_cfg80211_stop_ap(struct
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_SSID,
+ &join_params, sizeof(join_params));
+ if (err < 0)
+- brcmf_err("SET SSID error (%d)\n", err);
++ bphy_err(wiphy, "SET SSID error (%d)\n", err);
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_DOWN, 1);
+ if (err < 0)
+- brcmf_err("BRCMF_C_DOWN error %d\n", err);
++ bphy_err(wiphy, "BRCMF_C_DOWN error %d\n", err);
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_AP, 0);
+ if (err < 0)
+- brcmf_err("setting AP mode failed %d\n", err);
++ bphy_err(wiphy, "setting AP mode failed %d\n", err);
+ if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MBSS))
+ brcmf_fil_iovar_int_set(ifp, "mbss", 0);
+ brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_REGULATORY,
+@@ -4693,7 +4734,7 @@ static int brcmf_cfg80211_stop_ap(struct
+ /* Bring device back up so it can be used again */
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_UP, 1);
+ if (err < 0)
+- brcmf_err("BRCMF_C_UP error %d\n", err);
++ bphy_err(wiphy, "BRCMF_C_UP error %d\n", err);
+
+ brcmf_vif_clear_mgmt_ies(ifp->vif);
+ } else {
+@@ -4702,7 +4743,7 @@ static int brcmf_cfg80211_stop_ap(struct
+ err = brcmf_fil_iovar_data_set(ifp, "bss", &bss_enable,
+ sizeof(bss_enable));
+ if (err < 0)
+- brcmf_err("bss_enable config failed %d\n", err);
++ bphy_err(wiphy, "bss_enable config failed %d\n", err);
+ }
+ brcmf_set_mpc(ifp, 1);
+ brcmf_configure_arp_nd_offload(ifp, true);
+@@ -4750,7 +4791,8 @@ brcmf_cfg80211_del_station(struct wiphy
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SCB_DEAUTHENTICATE_FOR_REASON,
+ &scbval, sizeof(scbval));
+ if (err)
+- brcmf_err("SCB_DEAUTHENTICATE_FOR_REASON failed %d\n", err);
++ bphy_err(wiphy, "SCB_DEAUTHENTICATE_FOR_REASON failed %d\n",
++ err);
+
+ brcmf_dbg(TRACE, "Exit\n");
+ return err;
+@@ -4780,7 +4822,7 @@ brcmf_cfg80211_change_station(struct wip
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_SCB_DEAUTHORIZE,
+ (void *)mac, ETH_ALEN);
+ if (err < 0)
+- brcmf_err("Setting SCB (de-)authorize failed, %d\n", err);
++ bphy_err(wiphy, "Setting SCB (de-)authorize failed, %d\n", err);
+
+ return err;
+ }
+@@ -4830,7 +4872,7 @@ brcmf_cfg80211_mgmt_tx(struct wiphy *wip
+ mgmt = (const struct ieee80211_mgmt *)buf;
+
+ if (!ieee80211_is_mgmt(mgmt->frame_control)) {
+- brcmf_err("Driver only allows MGMT packet type\n");
++ bphy_err(wiphy, "Driver only allows MGMT packet type\n");
+ return -EPERM;
+ }
+
+@@ -4861,13 +4903,13 @@ brcmf_cfg80211_mgmt_tx(struct wiphy *wip
+ GFP_KERNEL);
+ } else if (ieee80211_is_action(mgmt->frame_control)) {
+ if (len > BRCMF_FIL_ACTION_FRAME_SIZE + DOT11_MGMT_HDR_LEN) {
+- brcmf_err("invalid action frame length\n");
++ bphy_err(wiphy, "invalid action frame length\n");
+ err = -EINVAL;
+ goto exit;
+ }
+ af_params = kzalloc(sizeof(*af_params), GFP_KERNEL);
+ if (af_params == NULL) {
+- brcmf_err("unable to allocate frame\n");
++ bphy_err(wiphy, "unable to allocate frame\n");
+ err = -ENOMEM;
+ goto exit;
+ }
+@@ -4925,7 +4967,7 @@ brcmf_cfg80211_cancel_remain_on_channel(
+
+ vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif;
+ if (vif == NULL) {
+- brcmf_err("No p2p device available for probe response\n");
++ bphy_err(wiphy, "No p2p device available for probe response\n");
+ err = -ENODEV;
+ goto exit;
+ }
+@@ -4953,7 +4995,7 @@ static int brcmf_cfg80211_get_channel(st
+
+ err = brcmf_fil_iovar_int_get(ifp, "chanspec", &chanspec);
+ if (err) {
+- brcmf_err("chanspec failed (%d)\n", err);
++ bphy_err(wiphy, "chanspec failed (%d)\n", err);
+ return err;
+ }
+
+@@ -5092,7 +5134,7 @@ static int brcmf_cfg80211_tdls_oper(stru
+ ret = brcmf_fil_iovar_data_set(ifp, "tdls_endpoint",
+ &info, sizeof(info));
+ if (ret < 0)
+- brcmf_err("tdls_endpoint iovar failed: ret=%d\n", ret);
++ bphy_err(wiphy, "tdls_endpoint iovar failed: ret=%d\n", ret);
+
+ return ret;
+ }
+@@ -5113,7 +5155,7 @@ brcmf_cfg80211_update_conn_params(struct
+ err = brcmf_vif_set_mgmt_ie(ifp->vif, BRCMF_VNDR_IE_ASSOCREQ_FLAG,
+ sme->ie, sme->ie_len);
+ if (err)
+- brcmf_err("Set Assoc REQ IE Failed\n");
++ bphy_err(wiphy, "Set Assoc REQ IE Failed\n");
+ else
+ brcmf_dbg(TRACE, "Applied Vndr IEs for Assoc request\n");
+
+@@ -5139,7 +5181,7 @@ brcmf_cfg80211_set_rekey_data(struct wip
+ ret = brcmf_fil_iovar_data_set(ifp, "gtk_key_info", &gtk_le,
+ sizeof(gtk_le));
+ if (ret < 0)
+- brcmf_err("gtk_key_info iovar failed: ret=%d\n", ret);
++ bphy_err(wiphy, "gtk_key_info iovar failed: ret=%d\n", ret);
+
+ return ret;
+ }
+@@ -5317,6 +5359,7 @@ static void brcmf_clear_assoc_ies(struct
+ static s32 brcmf_get_assoc_ies(struct brcmf_cfg80211_info *cfg,
+ struct brcmf_if *ifp)
+ {
++ struct wiphy *wiphy = cfg_to_wiphy(cfg);
+ struct brcmf_cfg80211_assoc_ielen_le *assoc_info;
+ struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg);
+ u32 req_len;
+@@ -5328,7 +5371,7 @@ static s32 brcmf_get_assoc_ies(struct br
+ err = brcmf_fil_iovar_data_get(ifp, "assoc_info",
+ cfg->extra_buf, WL_ASSOC_INFO_MAX);
+ if (err) {
+- brcmf_err("could not get assoc info (%d)\n", err);
++ bphy_err(wiphy, "could not get assoc info (%d)\n", err);
+ return err;
+ }
+ assoc_info =
+@@ -5340,7 +5383,7 @@ static s32 brcmf_get_assoc_ies(struct br
+ cfg->extra_buf,
+ WL_ASSOC_INFO_MAX);
+ if (err) {
+- brcmf_err("could not get assoc req (%d)\n", err);
++ bphy_err(wiphy, "could not get assoc req (%d)\n", err);
+ return err;
+ }
+ conn_info->req_ie_len = req_len;
+@@ -5356,7 +5399,7 @@ static s32 brcmf_get_assoc_ies(struct br
+ cfg->extra_buf,
+ WL_ASSOC_INFO_MAX);
+ if (err) {
+- brcmf_err("could not get assoc resp (%d)\n", err);
++ bphy_err(wiphy, "could not get assoc resp (%d)\n", err);
+ return err;
+ }
+ conn_info->resp_ie_len = resp_len;
+@@ -5475,6 +5518,7 @@ brcmf_notify_connect_status_ap(struct br
+ struct net_device *ndev,
+ const struct brcmf_event_msg *e, void *data)
+ {
++ struct wiphy *wiphy = cfg_to_wiphy(cfg);
+ static int generation;
+ u32 event = e->event_code;
+ u32 reason = e->reason;
+@@ -5493,7 +5537,7 @@ brcmf_notify_connect_status_ap(struct br
+ (reason == BRCMF_E_STATUS_SUCCESS)) {
+ memset(&sinfo, 0, sizeof(sinfo));
+ if (!data) {
+- brcmf_err("No IEs present in ASSOC/REASSOC_IND");
++ bphy_err(wiphy, "No IEs present in ASSOC/REASSOC_IND\n");
+ return -EINVAL;
+ }
+ sinfo.assoc_req_ies = data;
+@@ -5774,6 +5818,7 @@ static void init_vif_event(struct brcmf_
+
+ static s32 brcmf_dongle_roam(struct brcmf_if *ifp)
+ {
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ s32 err;
+ u32 bcn_timeout;
+ __le32 roamtrigger[2];
+@@ -5786,7 +5831,7 @@ static s32 brcmf_dongle_roam(struct brcm
+ bcn_timeout = BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_ON;
+ err = brcmf_fil_iovar_int_set(ifp, "bcn_timeout", bcn_timeout);
+ if (err) {
+- brcmf_err("bcn_timeout error (%d)\n", err);
++ bphy_err(wiphy, "bcn_timeout error (%d)\n", err);
+ goto roam_setup_done;
+ }
+
+@@ -5798,7 +5843,7 @@ static s32 brcmf_dongle_roam(struct brcm
+ err = brcmf_fil_iovar_int_set(ifp, "roam_off",
+ ifp->drvr->settings->roamoff);
+ if (err) {
+- brcmf_err("roam_off error (%d)\n", err);
++ bphy_err(wiphy, "roam_off error (%d)\n", err);
+ goto roam_setup_done;
+ }
+
+@@ -5807,7 +5852,7 @@ static s32 brcmf_dongle_roam(struct brcm
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_ROAM_TRIGGER,
+ (void *)roamtrigger, sizeof(roamtrigger));
+ if (err) {
+- brcmf_err("WLC_SET_ROAM_TRIGGER error (%d)\n", err);
++ bphy_err(wiphy, "WLC_SET_ROAM_TRIGGER error (%d)\n", err);
+ goto roam_setup_done;
+ }
+
+@@ -5816,7 +5861,7 @@ static s32 brcmf_dongle_roam(struct brcm
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_ROAM_DELTA,
+ (void *)roam_delta, sizeof(roam_delta));
+ if (err) {
+- brcmf_err("WLC_SET_ROAM_DELTA error (%d)\n", err);
++ bphy_err(wiphy, "WLC_SET_ROAM_DELTA error (%d)\n", err);
+ goto roam_setup_done;
+ }
+
+@@ -5827,25 +5872,26 @@ roam_setup_done:
+ static s32
+ brcmf_dongle_scantime(struct brcmf_if *ifp)
+ {
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ s32 err = 0;
+
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_CHANNEL_TIME,
+ BRCMF_SCAN_CHANNEL_TIME);
+ if (err) {
+- brcmf_err("Scan assoc time error (%d)\n", err);
++ bphy_err(wiphy, "Scan assoc time error (%d)\n", err);
+ goto dongle_scantime_out;
+ }
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_UNASSOC_TIME,
+ BRCMF_SCAN_UNASSOC_TIME);
+ if (err) {
+- brcmf_err("Scan unassoc time error (%d)\n", err);
++ bphy_err(wiphy, "Scan unassoc time error (%d)\n", err);
+ goto dongle_scantime_out;
+ }
+
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_PASSIVE_TIME,
+ BRCMF_SCAN_PASSIVE_TIME);
+ if (err) {
+- brcmf_err("Scan passive time error (%d)\n", err);
++ bphy_err(wiphy, "Scan passive time error (%d)\n", err);
+ goto dongle_scantime_out;
+ }
+
+@@ -5877,10 +5923,10 @@ static void brcmf_update_bw40_channel_fl
+ static int brcmf_construct_chaninfo(struct brcmf_cfg80211_info *cfg,
+ u32 bw_cap[])
+ {
++ struct wiphy *wiphy = cfg_to_wiphy(cfg);
+ struct brcmf_if *ifp = brcmf_get_ifp(cfg->pub, 0);
+ struct ieee80211_supported_band *band;
+ struct ieee80211_channel *channel;
+- struct wiphy *wiphy;
+ struct brcmf_chanspec_list *list;
+ struct brcmu_chan ch;
+ int err;
+@@ -5899,11 +5945,10 @@ static int brcmf_construct_chaninfo(stru
+ err = brcmf_fil_iovar_data_get(ifp, "chanspecs", pbuf,
+ BRCMF_DCMD_MEDLEN);
+ if (err) {
+- brcmf_err("get chanspecs error (%d)\n", err);
++ bphy_err(wiphy, "get chanspecs error (%d)\n", err);
+ goto fail_pbuf;
+ }
+
+- wiphy = cfg_to_wiphy(cfg);
+ band = wiphy->bands[NL80211_BAND_2GHZ];
+ if (band)
+ for (i = 0; i < band->n_channels; i++)
+@@ -5923,7 +5968,8 @@ static int brcmf_construct_chaninfo(stru
+ } else if (ch.band == BRCMU_CHAN_BAND_5G) {
+ band = wiphy->bands[NL80211_BAND_5GHZ];
+ } else {
+- brcmf_err("Invalid channel Spec. 0x%x.\n", ch.chspec);
++ bphy_err(wiphy, "Invalid channel Spec. 0x%x.\n",
++ ch.chspec);
+ continue;
+ }
+ if (!band)
+@@ -5946,8 +5992,8 @@ static int brcmf_construct_chaninfo(stru
+ /* It seems firmware supports some channel we never
+ * considered. Something new in IEEE standard?
+ */
+- brcmf_err("Ignoring unexpected firmware channel %d\n",
+- ch.control_ch_num);
++ bphy_err(wiphy, "Ignoring unexpected firmware channel %d\n",
++ ch.control_ch_num);
+ continue;
+ }
+
+@@ -5993,6 +6039,7 @@ fail_pbuf:
+
+ static int brcmf_enable_bw40_2g(struct brcmf_cfg80211_info *cfg)
+ {
++ struct wiphy *wiphy = cfg_to_wiphy(cfg);
+ struct brcmf_if *ifp = brcmf_get_ifp(cfg->pub, 0);
+ struct ieee80211_supported_band *band;
+ struct brcmf_fil_bwcap_le band_bwcap;
+@@ -6039,7 +6086,7 @@ static int brcmf_enable_bw40_2g(struct b
+ err = brcmf_fil_iovar_data_get(ifp, "chanspecs", pbuf,
+ BRCMF_DCMD_MEDLEN);
+ if (err) {
+- brcmf_err("get chanspecs error (%d)\n", err);
++ bphy_err(wiphy, "get chanspecs error (%d)\n", err);
+ kfree(pbuf);
+ return err;
+ }
+@@ -6070,6 +6117,7 @@ static int brcmf_enable_bw40_2g(struct b
+
+ static void brcmf_get_bwcap(struct brcmf_if *ifp, u32 bw_cap[])
+ {
++ struct wiphy *wiphy = ifp->drvr->wiphy;
+ u32 band, mimo_bwcap;
+ int err;
+
+@@ -6105,7 +6153,7 @@ static void brcmf_get_bwcap(struct brcmf
+ bw_cap[NL80211_BAND_5GHZ] |= WLC_BW_20MHZ_BIT;
+ break;
+ default:
+- brcmf_err("invalid mimo_bw_cap value\n");
++ bphy_err(wiphy, "invalid mimo_bw_cap value\n");
+ }
+ }
+
+@@ -6181,7 +6229,7 @@ static void brcmf_update_vht_cap(struct
+ static int brcmf_setup_wiphybands(struct brcmf_cfg80211_info *cfg)
+ {
+ struct brcmf_if *ifp = brcmf_get_ifp(cfg->pub, 0);
+- struct wiphy *wiphy;
++ struct wiphy *wiphy = cfg_to_wiphy(cfg);
+ u32 nmode = 0;
+ u32 vhtmode = 0;
+ u32 bw_cap[2] = { WLC_BW_20MHZ_BIT, WLC_BW_20MHZ_BIT };
+@@ -6197,7 +6245,7 @@ static int brcmf_setup_wiphybands(struct
+ (void)brcmf_fil_iovar_int_get(ifp, "vhtmode", &vhtmode);
+ err = brcmf_fil_iovar_int_get(ifp, "nmode", &nmode);
+ if (err) {
+- brcmf_err("nmode error (%d)\n", err);
++ bphy_err(wiphy, "nmode error (%d)\n", err);
+ } else {
+ brcmf_get_bwcap(ifp, bw_cap);
+ }
+@@ -6207,7 +6255,7 @@ static int brcmf_setup_wiphybands(struct
+
+ err = brcmf_fil_iovar_int_get(ifp, "rxchain", &rxchain);
+ if (err) {
+- brcmf_err("rxchain error (%d)\n", err);
++ bphy_err(wiphy, "rxchain error (%d)\n", err);
+ nchain = 1;
+ } else {
+ for (nchain = 0; rxchain; nchain++)
+@@ -6217,7 +6265,7 @@ static int brcmf_setup_wiphybands(struct
+
+ err = brcmf_construct_chaninfo(cfg, bw_cap);
+ if (err) {
+- brcmf_err("brcmf_construct_chaninfo failed (%d)\n", err);
++ bphy_err(wiphy, "brcmf_construct_chaninfo failed (%d)\n", err);
+ return err;
+ }
+
+@@ -6229,7 +6277,6 @@ static int brcmf_setup_wiphybands(struct
+ &txbf_bfr_cap);
+ }
+
+- wiphy = cfg_to_wiphy(cfg);
+ for (i = 0; i < ARRAY_SIZE(wiphy->bands); i++) {
+ band = wiphy->bands[i];
+ if (band == NULL)
+@@ -6440,7 +6487,7 @@ static void brcmf_wiphy_wowl_params(stru
+ wowl = kmemdup(&brcmf_wowlan_support, sizeof(brcmf_wowlan_support),
+ GFP_KERNEL);
+ if (!wowl) {
+- brcmf_err("only support basic wowlan features\n");
++ bphy_err(wiphy, "only support basic wowlan features\n");
+ wiphy->wowlan = &brcmf_wowlan_support;
+ return;
+ }
+@@ -6528,7 +6575,7 @@ static int brcmf_setup_wiphy(struct wiph
+ err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_BANDLIST, &bandlist,
+ sizeof(bandlist));
+ if (err) {
+- brcmf_err("could not obtain band info: err=%d\n", err);
++ bphy_err(wiphy, "could not obtain band info: err=%d\n", err);
+ return err;
+ }
+ /* first entry in bandlist is number of bands */
+@@ -6800,8 +6847,8 @@ static void brcmf_cfg80211_reg_notifier(
+ /* ignore non-ISO3166 country codes */
+ for (i = 0; i < 2; i++)
+ if (req->alpha2[i] < 'A' || req->alpha2[i] > 'Z') {
+- brcmf_err("not a ISO3166 code (0x%02x 0x%02x)\n",
+- req->alpha2[0], req->alpha2[1]);
++ bphy_err(wiphy, "not a ISO3166 code (0x%02x 0x%02x)\n",
++ req->alpha2[0], req->alpha2[1]);
+ return;
+ }
+
+@@ -6810,7 +6857,7 @@ static void brcmf_cfg80211_reg_notifier(
+
+ err = brcmf_fil_iovar_data_get(ifp, "country", &ccreq, sizeof(ccreq));
+ if (err) {
+- brcmf_err("Country code iovar returned err = %d\n", err);
++ bphy_err(wiphy, "Country code iovar returned err = %d\n", err);
+ return;
+ }
+
+@@ -6820,7 +6867,7 @@ static void brcmf_cfg80211_reg_notifier(
+
+ err = brcmf_fil_iovar_data_set(ifp, "country", &ccreq, sizeof(ccreq));
+ if (err) {
+- brcmf_err("Firmware rejected country setting\n");
++ bphy_err(wiphy, "Firmware rejected country setting\n");
+ return;
+ }
+ brcmf_setup_wiphybands(cfg);
+@@ -6866,13 +6913,13 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+ u16 *cap = NULL;
+
+ if (!ndev) {
+- brcmf_err("ndev is invalid\n");
++ bphy_err(wiphy, "ndev is invalid\n");
+ return NULL;
+ }
+
+ cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
+ if (!cfg) {
+- brcmf_err("Could not allocate wiphy device\n");
++ bphy_err(wiphy, "Could not allocate wiphy device\n");
+ return NULL;
+ }
+
+@@ -6893,7 +6940,7 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+
+ err = wl_init_priv(cfg);
+ if (err) {
+- brcmf_err("Failed to init iwm_priv (%d)\n", err);
++ bphy_err(wiphy, "Failed to init iwm_priv (%d)\n", err);
+ brcmf_free_vif(vif);
+ goto wiphy_out;
+ }
+@@ -6902,7 +6949,7 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+ /* determine d11 io type before wiphy setup */
+ err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_VERSION, &io_type);
+ if (err) {
+- brcmf_err("Failed to get D11 version (%d)\n", err);
++ bphy_err(wiphy, "Failed to get D11 version (%d)\n", err);
+ goto priv_out;
+ }
+ cfg->d11inf.io_type = (u8)io_type;
+@@ -6936,13 +6983,13 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+ #endif
+ err = wiphy_register(wiphy);
+ if (err < 0) {
+- brcmf_err("Could not register wiphy device (%d)\n", err);
++ bphy_err(wiphy, "Could not register wiphy device (%d)\n", err);
+ goto priv_out;
+ }
+
+ err = brcmf_setup_wiphybands(cfg);
+ if (err) {
+- brcmf_err("Setting wiphy bands failed (%d)\n", err);
++ bphy_err(wiphy, "Setting wiphy bands failed (%d)\n", err);
+ goto wiphy_unreg_out;
+ }
+
+@@ -6960,18 +7007,18 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+
+ err = brcmf_fweh_activate_events(ifp);
+ if (err) {
+- brcmf_err("FWEH activation failed (%d)\n", err);
++ bphy_err(wiphy, "FWEH activation failed (%d)\n", err);
+ goto wiphy_unreg_out;
+ }
+
+ err = brcmf_p2p_attach(cfg, p2pdev_forced);
+ if (err) {
+- brcmf_err("P2P initialisation failed (%d)\n", err);
++ bphy_err(wiphy, "P2P initialisation failed (%d)\n", err);
+ goto wiphy_unreg_out;
+ }
+ err = brcmf_btcoex_attach(cfg);
+ if (err) {
+- brcmf_err("BT-coex initialisation failed (%d)\n", err);
++ bphy_err(wiphy, "BT-coex initialisation failed (%d)\n", err);
+ brcmf_p2p_detach(&cfg->p2p);
+ goto wiphy_unreg_out;
+ }
+@@ -6990,7 +7037,7 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+ /* (re-) activate FWEH event handling */
+ err = brcmf_fweh_activate_events(ifp);
+ if (err) {
+- brcmf_err("FWEH activation failed (%d)\n", err);
++ bphy_err(wiphy, "FWEH activation failed (%d)\n", err);
+ goto detach;
+ }
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
+@@ -62,6 +62,15 @@ void __brcmf_err(struct brcmf_bus *bus,
+ } while (0)
+ #endif
+
++#define bphy_err(wiphy, fmt, ...) \
++ do { \
++ if (IS_ENABLED(CPTCFG_BRCMDBG) || \
++ IS_ENABLED(CPTCFG_BRCM_TRACING) || \
++ net_ratelimit()) \
++ wiphy_err(wiphy, "%s: " fmt, __func__, \
++ ##__VA_ARGS__); \
++ } while (0)
++
+ #if defined(DEBUG) || defined(CPTCFG_BRCM_TRACING)
+
+ /* For debug/tracing purposes treat info messages as errors */
diff --git a/package/kernel/mac80211/patches/339-v5.1-0004-brcmfmac-support-monitor-frames-with-the-hardware-uc.patch b/package/kernel/mac80211/patches/339-v5.1-0004-brcmfmac-support-monitor-frames-with-the-hardware-uc.patch
new file mode 100644
index 0000000000..58f9e9c923
--- /dev/null
+++ b/package/kernel/mac80211/patches/339-v5.1-0004-brcmfmac-support-monitor-frames-with-the-hardware-uc.patch
@@ -0,0 +1,147 @@
+From e665988be29ccea3584528967b432a5cfd801ca4 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Fri, 8 Feb 2019 07:42:30 +0100
+Subject: [PATCH] brcmfmac: support monitor frames with the hardware/ucode
+ header
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+So far there were two monitor frame formats:
+1) 802.11 frames (with frame (sub)type & all addresses)
+2) 802.11 frames with the radiotap header
+
+Testing the latest FullMAC firmwares for 4366b1/4366c0 resulted in
+discovering a new format being used. It seems (almost?) identical to the
+one known from ucode used in SoftMAC devices which is most likely the
+same codebase anyway.
+
+While new firmwares will /announce/ radiotap header support using the
+"rtap" fw capability string it seems no string was added for the new
+ucode header format.
+
+All above means that:
+1) We need new format support when dealing with a received frame
+2) A new feature bit & mapping quirks have to be added manually
+
+As for now only an empty radiotap is being created. Adding support for
+extracting some info (band, channel, signal, etc.) is planned for the
+future.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ .../broadcom/brcm80211/brcmfmac/core.c | 55 +++++++++++++++++++
+ .../broadcom/brcm80211/brcmfmac/feature.c | 4 ++
+ .../broadcom/brcm80211/brcmfmac/feature.h | 4 +-
+ 3 files changed, 62 insertions(+), 1 deletion(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+@@ -43,6 +43,36 @@
+
+ #define BRCMF_BSSIDX_INVALID -1
+
++#define RXS_PBPRES BIT(2)
++
++#define D11_PHY_HDR_LEN 6
++
++struct d11rxhdr_le {
++ __le16 RxFrameSize;
++ u16 PAD;
++ __le16 PhyRxStatus_0;
++ __le16 PhyRxStatus_1;
++ __le16 PhyRxStatus_2;
++ __le16 PhyRxStatus_3;
++ __le16 PhyRxStatus_4;
++ __le16 PhyRxStatus_5;
++ __le16 RxStatus1;
++ __le16 RxStatus2;
++ __le16 RxTSFTime;
++ __le16 RxChan;
++ u8 unknown[12];
++} __packed;
++
++struct wlc_d11rxhdr {
++ struct d11rxhdr_le rxhdr;
++ __le32 tsf_l;
++ s8 rssi;
++ s8 rxpwr0;
++ s8 rxpwr1;
++ s8 do_rssi_ma;
++ s8 rxpwr[4];
++} __packed;
++
+ char *brcmf_ifname(struct brcmf_if *ifp)
+ {
+ if (!ifp)
+@@ -372,6 +402,35 @@ void brcmf_netif_mon_rx(struct brcmf_if
+ {
+ if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MONITOR_FMT_RADIOTAP)) {
+ /* Do nothing */
++ } else if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MONITOR_FMT_HW_RX_HDR)) {
++ struct wlc_d11rxhdr *wlc_rxhdr = (struct wlc_d11rxhdr *)skb->data;
++ struct ieee80211_radiotap_header *radiotap;
++ unsigned int offset;
++ u16 RxStatus1;
++
++ RxStatus1 = le16_to_cpu(wlc_rxhdr->rxhdr.RxStatus1);
++
++ offset = sizeof(struct wlc_d11rxhdr);
++ /* MAC inserts 2 pad bytes for a4 headers or QoS or A-MSDU
++ * subframes
++ */
++ if (RxStatus1 & RXS_PBPRES)
++ offset += 2;
++ offset += D11_PHY_HDR_LEN;
++
++ skb_pull(skb, offset);
++
++ /* TODO: use RX header to fill some radiotap data */
++#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0)
++ radiotap = skb_push(skb, sizeof(*radiotap));
++#else
++ radiotap = (struct ieee80211_radiotap_header *)skb_push(skb, sizeof(*radiotap));
++#endif
++ memset(radiotap, 0, sizeof(*radiotap));
++ radiotap->it_len = cpu_to_le16(sizeof(*radiotap));
++
++ /* TODO: 4 bytes with receive status? */
++ skb->len -= 4;
+ } else {
+ struct ieee80211_radiotap_header *radiotap;
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
+@@ -102,6 +102,10 @@ static const struct brcmf_feat_fwfeat br
+ { "01-6cb8e269", BIT(BRCMF_FEAT_MONITOR) },
+ /* brcmfmac4366b-pcie.bin from linux-firmware.git commit 52442afee990 */
+ { "01-c47a91a4", BIT(BRCMF_FEAT_MONITOR) },
++ /* brcmfmac4366b-pcie.bin from linux-firmware.git commit 211de1679a68 */
++ { "01-801fb449", BIT(BRCMF_FEAT_MONITOR_FMT_HW_RX_HDR) },
++ /* brcmfmac4366c-pcie.bin from linux-firmware.git commit 211de1679a68 */
++ { "01-d2cbb8fd", BIT(BRCMF_FEAT_MONITOR_FMT_HW_RX_HDR) },
+ };
+
+ static void brcmf_feat_firmware_overrides(struct brcmf_pub *drv)
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.h
+@@ -33,6 +33,7 @@
+ * MFP: 802.11w Management Frame Protection.
+ * MONITOR: firmware can pass monitor packets to host.
+ * MONITOR_FMT_RADIOTAP: firmware provides monitor packets with radiotap header
++ * MONITOR_FMT_HW_RX_HDR: firmware provides monitor packets with hw/ucode header
+ */
+ #define BRCMF_FEAT_LIST \
+ BRCMF_FEAT_DEF(MBSS) \
+@@ -48,7 +49,8 @@
+ BRCMF_FEAT_DEF(WOWL_ARP_ND) \
+ BRCMF_FEAT_DEF(MFP) \
+ BRCMF_FEAT_DEF(MONITOR) \
+- BRCMF_FEAT_DEF(MONITOR_FMT_RADIOTAP)
++ BRCMF_FEAT_DEF(MONITOR_FMT_RADIOTAP) \
++ BRCMF_FEAT_DEF(MONITOR_FMT_HW_RX_HDR)
+
+ /*
+ * Quirks:
diff --git a/package/kernel/mac80211/patches/339-v5.1-0005-brcmfmac-print-firmware-reported-ring-status-errors.patch b/package/kernel/mac80211/patches/339-v5.1-0005-brcmfmac-print-firmware-reported-ring-status-errors.patch
new file mode 100644
index 0000000000..f6410a6eab
--- /dev/null
+++ b/package/kernel/mac80211/patches/339-v5.1-0005-brcmfmac-print-firmware-reported-ring-status-errors.patch
@@ -0,0 +1,67 @@
+From c988b78244df8216902e20de536434e2f474a37e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Fri, 8 Feb 2019 15:24:39 +0100
+Subject: [PATCH] brcmfmac: print firmware reported ring status errors
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Firmware is capable of reporting ring status. It's used e.g. to signal
+some problem with a specific ring setup. This patch adds support for
+printing ring & error number which may be useful for debugging setup
+issues.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ .../broadcom/brcm80211/brcmfmac/msgbuf.c | 25 +++++++++++++++++++
+ 1 file changed, 25 insertions(+)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
+@@ -134,6 +134,14 @@ struct msgbuf_completion_hdr {
+ __le16 flow_ring_id;
+ };
+
++/* Data struct for the MSGBUF_TYPE_RING_STATUS */
++struct msgbuf_ring_status {
++ struct msgbuf_common_hdr msg;
++ struct msgbuf_completion_hdr compl_hdr;
++ __le16 write_idx;
++ __le32 rsvd0[5];
++};
++
+ struct msgbuf_rx_event {
+ struct msgbuf_common_hdr msg;
+ struct msgbuf_completion_hdr compl_hdr;
+@@ -1178,6 +1186,19 @@ brcmf_msgbuf_process_rx_complete(struct
+ brcmf_netif_rx(ifp, skb);
+ }
+
++static void brcmf_msgbuf_process_ring_status(struct brcmf_msgbuf *msgbuf,
++ void *buf)
++{
++ struct msgbuf_ring_status *ring_status = buf;
++ int err;
++
++ err = le16_to_cpu(ring_status->compl_hdr.status);
++ if (err) {
++ int ring = le16_to_cpu(ring_status->compl_hdr.flow_ring_id);
++
++ brcmf_err("Firmware reported ring %d error: %d\n", ring, err);
++ }
++}
+
+ static void
+ brcmf_msgbuf_process_flow_ring_create_response(struct brcmf_msgbuf *msgbuf,
+@@ -1239,6 +1260,10 @@ static void brcmf_msgbuf_process_msgtype
+
+ msg = (struct msgbuf_common_hdr *)buf;
+ switch (msg->msgtype) {
++ case MSGBUF_TYPE_RING_STATUS:
++ brcmf_dbg(MSGBUF, "MSGBUF_TYPE_RING_STATUS\n");
++ brcmf_msgbuf_process_ring_status(msgbuf, buf);
++ break;
+ case MSGBUF_TYPE_FLOW_RING_CREATE_CMPLT:
+ brcmf_dbg(MSGBUF, "MSGBUF_TYPE_FLOW_RING_CREATE_CMPLT\n");
+ brcmf_msgbuf_process_flow_ring_create_response(msgbuf, buf);
diff --git a/package/kernel/mac80211/patches/339-v5.1-0006-brcmfmac-improve-code-handling-bandwidth-of-firmware.patch b/package/kernel/mac80211/patches/339-v5.1-0006-brcmfmac-improve-code-handling-bandwidth-of-firmware.patch
new file mode 100644
index 0000000000..b225ed4f34
--- /dev/null
+++ b/package/kernel/mac80211/patches/339-v5.1-0006-brcmfmac-improve-code-handling-bandwidth-of-firmware.patch
@@ -0,0 +1,42 @@
+From f4e183293b871c96c0220dcc549d5ca4c72628ad Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Mon, 11 Feb 2019 23:04:53 +0100
+Subject: [PATCH] brcmfmac: improve code handling bandwidth of firmware
+ reported channels
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+1) Use switch to simplify/improve the code & avoid some duplication
+2) Add warning for unsupported values
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ .../wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 13 ++++++++++---
+ 1 file changed, 10 insertions(+), 3 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+@@ -6003,11 +6003,18 @@ static int brcmf_construct_chaninfo(stru
+ /* assuming the chanspecs order is HT20,
+ * HT40 upper, HT40 lower, and VHT80.
+ */
+- if (ch.bw == BRCMU_CHAN_BW_80) {
++ switch (ch.bw) {
++ case BRCMU_CHAN_BW_80:
+ channel->flags &= ~IEEE80211_CHAN_NO_80MHZ;
+- } else if (ch.bw == BRCMU_CHAN_BW_40) {
++ break;
++ case BRCMU_CHAN_BW_40:
+ brcmf_update_bw40_channel_flag(channel, &ch);
+- } else {
++ break;
++ default:
++ wiphy_warn(wiphy, "Firmware reported unsupported bandwidth %d\n",
++ ch.bw);
++ /* fall through */
++ case BRCMU_CHAN_BW_20:
+ /* enable the channel and disable other bandwidths
+ * for now as mentioned order assure they are enabled
+ * for subsequent chanspecs.
diff --git a/package/kernel/mac80211/patches/339-v5.1-0007-brcmfmac-support-firmware-reporting-160-MHz-channels.patch b/package/kernel/mac80211/patches/339-v5.1-0007-brcmfmac-support-firmware-reporting-160-MHz-channels.patch
new file mode 100644
index 0000000000..a20961a9fa
--- /dev/null
+++ b/package/kernel/mac80211/patches/339-v5.1-0007-brcmfmac-support-firmware-reporting-160-MHz-channels.patch
@@ -0,0 +1,30 @@
+From 30519cbe339a45bd11a57ca8ece07f4f6a1cda2e Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Mon, 11 Feb 2019 23:04:54 +0100
+Subject: [PATCH] brcmfmac: support firmware reporting 160 MHz channels
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+So far 160 MHz channels were treated as 20 MHz ones which was breaking
+support for 40/80 MHz due to the brcmf_construct_chaninfo() logic and
+its assumptions.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c | 3 +++
+ 1 file changed, 3 insertions(+)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+@@ -6004,6 +6004,9 @@ static int brcmf_construct_chaninfo(stru
+ * HT40 upper, HT40 lower, and VHT80.
+ */
+ switch (ch.bw) {
++ case BRCMU_CHAN_BW_160:
++ channel->flags &= ~IEEE80211_CHAN_NO_160MHZ;
++ break;
+ case BRCMU_CHAN_BW_80:
+ channel->flags &= ~IEEE80211_CHAN_NO_80MHZ;
+ break;
diff --git a/package/kernel/mac80211/patches/339-v5.1-0008-brcmfmac-rework-bphy_err-to-take-struct-brcmf_pub-ar.patch b/package/kernel/mac80211/patches/339-v5.1-0008-brcmfmac-rework-bphy_err-to-take-struct-brcmf_pub-ar.patch
new file mode 100644
index 0000000000..1694b42aa4
--- /dev/null
+++ b/package/kernel/mac80211/patches/339-v5.1-0008-brcmfmac-rework-bphy_err-to-take-struct-brcmf_pub-ar.patch
@@ -0,0 +1,2223 @@
+From 16e646768396339b3d354985b99bcd3f1f195a7d Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Fri, 15 Feb 2019 15:45:54 +0100
+Subject: [PATCH] brcmfmac: rework bphy_err() to take struct brcmf_pub argument
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This macro will be used in more places not just the cfg80211.c. It makes
+sense to pass some common struct to it as "struct wiphy" is mostly
+referenced in cfg80211 code only.
+
+A very common one (used above the bus abstraction layer) is struct
+brcmf_pub. Many functions already keep reference to it which will make
+using bphy_err() simpler. It should also allow extending that macro's
+logic if it's ever needed.
+
+This improves code recently added in the commit 3ef005b82e2a ("brcmfmac:
+add bphy_err() and use it in the cfg80211.c").
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ .../broadcom/brcm80211/brcmfmac/cfg80211.c | 510 ++++++++++--------
+ .../broadcom/brcm80211/brcmfmac/debug.h | 4 +-
+ 2 files changed, 281 insertions(+), 233 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+@@ -457,7 +457,7 @@ static void convert_key_from_CPU(struct
+ static int
+ send_key_to_dongle(struct brcmf_if *ifp, struct brcmf_wsec_key *key)
+ {
+- struct wiphy *wiphy = ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = ifp->drvr;
+ int err;
+ struct brcmf_wsec_key_le key_le;
+
+@@ -469,7 +469,7 @@ send_key_to_dongle(struct brcmf_if *ifp,
+ sizeof(key_le));
+
+ if (err)
+- bphy_err(wiphy, "wsec_key error (%d)\n", err);
++ bphy_err(drvr, "wsec_key error (%d)\n", err);
+ return err;
+ }
+
+@@ -550,7 +550,7 @@ static int brcmf_get_first_free_bsscfgid
+
+ static int brcmf_cfg80211_request_ap_if(struct brcmf_if *ifp)
+ {
+- struct wiphy *wiphy = ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = ifp->drvr;
+ struct brcmf_mbss_ssid_le mbss_ssid_le;
+ int bsscfgidx;
+ int err;
+@@ -567,7 +567,7 @@ static int brcmf_cfg80211_request_ap_if(
+ err = brcmf_fil_bsscfg_data_set(ifp, "bsscfg:ssid", &mbss_ssid_le,
+ sizeof(mbss_ssid_le));
+ if (err < 0)
+- bphy_err(wiphy, "setting ssid failed %d\n", err);
++ bphy_err(drvr, "setting ssid failed %d\n", err);
+
+ return err;
+ }
+@@ -586,6 +586,7 @@ struct wireless_dev *brcmf_ap_add_vif(st
+ {
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_if *ifp = netdev_priv(cfg_to_ndev(cfg));
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_cfg80211_vif *vif;
+ int err;
+
+@@ -611,7 +612,7 @@ struct wireless_dev *brcmf_ap_add_vif(st
+ BRCMF_VIF_EVENT_TIMEOUT);
+ brcmf_cfg80211_arm_vif_event(cfg, NULL);
+ if (!err) {
+- bphy_err(wiphy, "timeout occurred\n");
++ bphy_err(drvr, "timeout occurred\n");
+ err = -EIO;
+ goto fail;
+ }
+@@ -619,7 +620,7 @@ struct wireless_dev *brcmf_ap_add_vif(st
+ /* interface created in firmware */
+ ifp = vif->ifp;
+ if (!ifp) {
+- bphy_err(wiphy, "no if pointer provided\n");
++ bphy_err(drvr, "no if pointer provided\n");
+ err = -ENOENT;
+ goto fail;
+ }
+@@ -627,7 +628,7 @@ struct wireless_dev *brcmf_ap_add_vif(st
+ strncpy(ifp->ndev->name, name, sizeof(ifp->ndev->name) - 1);
+ err = brcmf_net_attach(ifp, true);
+ if (err) {
+- bphy_err(wiphy, "Registering netdevice failed\n");
++ bphy_err(drvr, "Registering netdevice failed\n");
+ goto fail;
+ }
+
+@@ -658,13 +659,15 @@ static struct wireless_dev *brcmf_cfg802
+ u32 *flags,
+ struct vif_params *params)
+ {
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct wireless_dev *wdev;
+ int err;
+
+ brcmf_dbg(TRACE, "enter: %s type %d\n", name, type);
+ err = brcmf_vif_add_validate(wiphy_to_cfg(wiphy), type);
+ if (err) {
+- bphy_err(wiphy, "iface validation failed: err=%d\n", err);
++ bphy_err(drvr, "iface validation failed: err=%d\n", err);
+ return ERR_PTR(err);
+ }
+ switch (type) {
+@@ -689,7 +692,7 @@ static struct wireless_dev *brcmf_cfg802
+ }
+
+ if (IS_ERR(wdev))
+- bphy_err(wiphy, "add iface %s type %d failed: err=%d\n", name,
++ bphy_err(drvr, "add iface %s type %d failed: err=%d\n", name,
+ type, (int)PTR_ERR(wdev));
+ else
+ brcmf_cfg80211_update_proto_addr_mode(wdev);
+@@ -705,13 +708,13 @@ static void brcmf_scan_config_mpc(struct
+
+ void brcmf_set_mpc(struct brcmf_if *ifp, int mpc)
+ {
+- struct wiphy *wiphy = ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = ifp->drvr;
+ s32 err = 0;
+
+ if (check_vif_up(ifp->vif)) {
+ err = brcmf_fil_iovar_int_set(ifp, "mpc", mpc);
+ if (err) {
+- bphy_err(wiphy, "fail to set mpc\n");
++ bphy_err(drvr, "fail to set mpc\n");
+ return;
+ }
+ brcmf_dbg(INFO, "MPC : %d\n", mpc);
+@@ -789,6 +792,7 @@ static int brcmf_cfg80211_del_ap_iface(s
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct net_device *ndev = wdev->netdev;
+ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct brcmf_pub *drvr = cfg->pub;
+ int ret;
+ int err;
+
+@@ -796,7 +800,7 @@ static int brcmf_cfg80211_del_ap_iface(s
+
+ err = brcmf_fil_bsscfg_data_set(ifp, "interface_remove", NULL, 0);
+ if (err) {
+- bphy_err(wiphy, "interface_remove failed %d\n", err);
++ bphy_err(drvr, "interface_remove failed %d\n", err);
+ goto err_unarm;
+ }
+
+@@ -804,7 +808,7 @@ static int brcmf_cfg80211_del_ap_iface(s
+ ret = brcmf_cfg80211_wait_vif_event(cfg, BRCMF_E_IF_DEL,
+ BRCMF_VIF_EVENT_TIMEOUT);
+ if (!ret) {
+- bphy_err(wiphy, "timeout occurred\n");
++ bphy_err(drvr, "timeout occurred\n");
+ err = -EIO;
+ goto err_unarm;
+ }
+@@ -867,6 +871,7 @@ brcmf_cfg80211_change_iface(struct wiphy
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_if *ifp = netdev_priv(ndev);
+ struct brcmf_cfg80211_vif *vif = ifp->vif;
++ struct brcmf_pub *drvr = cfg->pub;
+ s32 infra = 0;
+ s32 ap = 0;
+ s32 err = 0;
+@@ -906,13 +911,13 @@ brcmf_cfg80211_change_iface(struct wiphy
+ }
+ err = brcmf_vif_change_validate(wiphy_to_cfg(wiphy), vif, type);
+ if (err) {
+- bphy_err(wiphy, "iface validation failed: err=%d\n", err);
++ bphy_err(drvr, "iface validation failed: err=%d\n", err);
+ return err;
+ }
+ switch (type) {
+ case NL80211_IFTYPE_MONITOR:
+ case NL80211_IFTYPE_WDS:
+- bphy_err(wiphy, "type (%d) : currently we do not support this type\n",
++ bphy_err(drvr, "type (%d) : currently we do not support this type\n",
+ type);
+ return -EOPNOTSUPP;
+ case NL80211_IFTYPE_ADHOC:
+@@ -941,7 +946,7 @@ brcmf_cfg80211_change_iface(struct wiphy
+ } else {
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_INFRA, infra);
+ if (err) {
+- bphy_err(wiphy, "WLC_SET_INFRA error (%d)\n", err);
++ bphy_err(drvr, "WLC_SET_INFRA error (%d)\n", err);
+ err = -EAGAIN;
+ goto done;
+ }
+@@ -1043,7 +1048,7 @@ static s32
+ brcmf_run_escan(struct brcmf_cfg80211_info *cfg, struct brcmf_if *ifp,
+ struct cfg80211_scan_request *request)
+ {
+- struct wiphy *wiphy = cfg_to_wiphy(cfg);
++ struct brcmf_pub *drvr = cfg->pub;
+ s32 params_size = BRCMF_SCAN_PARAMS_FIXED_SIZE +
+ offsetof(struct brcmf_escan_params_le, params_le);
+ struct brcmf_escan_params_le *params;
+@@ -1075,7 +1080,7 @@ brcmf_run_escan(struct brcmf_cfg80211_in
+ if (err == -EBUSY)
+ brcmf_dbg(INFO, "system busy : escan canceled\n");
+ else
+- bphy_err(wiphy, "error (%d)\n", err);
++ bphy_err(drvr, "error (%d)\n", err);
+ }
+
+ kfree(params);
+@@ -1122,6 +1127,7 @@ brcmf_cfg80211_escan(struct wiphy *wiphy
+ {
+ struct brcmf_if *ifp = vif->ifp;
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct cfg80211_ssid *ssids;
+ u32 passive_scan;
+ bool escan_req;
+@@ -1133,22 +1139,22 @@ brcmf_cfg80211_escan(struct wiphy *wiphy
+ brcmf_dbg(SCAN, "START ESCAN\n");
+
+ if (test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status)) {
+- bphy_err(wiphy, "Scanning already: status (%lu)\n",
++ bphy_err(drvr, "Scanning already: status (%lu)\n",
+ cfg->scan_status);
+ return -EAGAIN;
+ }
+ if (test_bit(BRCMF_SCAN_STATUS_ABORT, &cfg->scan_status)) {
+- bphy_err(wiphy, "Scanning being aborted: status (%lu)\n",
++ bphy_err(drvr, "Scanning being aborted: status (%lu)\n",
+ cfg->scan_status);
+ return -EAGAIN;
+ }
+ if (test_bit(BRCMF_SCAN_STATUS_SUPPRESS, &cfg->scan_status)) {
+- bphy_err(wiphy, "Scanning suppressed: status (%lu)\n",
++ bphy_err(drvr, "Scanning suppressed: status (%lu)\n",
+ cfg->scan_status);
+ return -EAGAIN;
+ }
+ if (test_bit(BRCMF_VIF_STATUS_CONNECTING, &ifp->vif->sme_state)) {
+- bphy_err(wiphy, "Connecting: status (%lu)\n",
++ bphy_err(drvr, "Connecting: status (%lu)\n",
+ ifp->vif->sme_state);
+ return -EAGAIN;
+ }
+@@ -1230,6 +1236,8 @@ scan_out:
+ static s32
+ brcmf_cfg80211_scan(struct wiphy *wiphy, struct cfg80211_scan_request *request)
+ {
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_cfg80211_vif *vif;
+ s32 err = 0;
+
+@@ -1241,7 +1249,7 @@ brcmf_cfg80211_scan(struct wiphy *wiphy,
+ err = brcmf_cfg80211_escan(wiphy, vif, request, NULL);
+
+ if (err)
+- bphy_err(wiphy, "scan error (%d)\n", err);
++ bphy_err(drvr, "scan error (%d)\n", err);
+
+ brcmf_dbg(TRACE, "Exit\n");
+ return err;
+@@ -1250,12 +1258,12 @@ brcmf_cfg80211_scan(struct wiphy *wiphy,
+ static s32 brcmf_set_rts(struct net_device *ndev, u32 rts_threshold)
+ {
+ struct brcmf_if *ifp = netdev_priv(ndev);
+- struct wiphy *wiphy = ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = ifp->drvr;
+ s32 err = 0;
+
+ err = brcmf_fil_iovar_int_set(ifp, "rtsthresh", rts_threshold);
+ if (err)
+- bphy_err(wiphy, "Error (%d)\n", err);
++ bphy_err(drvr, "Error (%d)\n", err);
+
+ return err;
+ }
+@@ -1263,13 +1271,13 @@ static s32 brcmf_set_rts(struct net_devi
+ static s32 brcmf_set_frag(struct net_device *ndev, u32 frag_threshold)
+ {
+ struct brcmf_if *ifp = netdev_priv(ndev);
+- struct wiphy *wiphy = ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = ifp->drvr;
+ s32 err = 0;
+
+ err = brcmf_fil_iovar_int_set(ifp, "fragthresh",
+ frag_threshold);
+ if (err)
+- bphy_err(wiphy, "Error (%d)\n", err);
++ bphy_err(drvr, "Error (%d)\n", err);
+
+ return err;
+ }
+@@ -1277,13 +1285,13 @@ static s32 brcmf_set_frag(struct net_dev
+ static s32 brcmf_set_retry(struct net_device *ndev, u32 retry, bool l)
+ {
+ struct brcmf_if *ifp = netdev_priv(ndev);
+- struct wiphy *wiphy = ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = ifp->drvr;
+ s32 err = 0;
+ u32 cmd = (l ? BRCMF_C_SET_LRL : BRCMF_C_SET_SRL);
+
+ err = brcmf_fil_cmd_int_set(ifp, cmd, retry);
+ if (err) {
+- bphy_err(wiphy, "cmd (%d) , error (%d)\n", cmd, err);
++ bphy_err(drvr, "cmd (%d) , error (%d)\n", cmd, err);
+ return err;
+ }
+ return err;
+@@ -1360,7 +1368,7 @@ static u16 brcmf_map_fw_linkdown_reason(
+ static void brcmf_link_down(struct brcmf_cfg80211_vif *vif, u16 reason)
+ {
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(vif->wdev.wiphy);
+- struct wiphy *wiphy = cfg_to_wiphy(cfg);
++ struct brcmf_pub *drvr = cfg->pub;
+ s32 err = 0;
+
+ brcmf_dbg(TRACE, "Enter\n");
+@@ -1370,7 +1378,7 @@ static void brcmf_link_down(struct brcmf
+ err = brcmf_fil_cmd_data_set(vif->ifp,
+ BRCMF_C_DISASSOC, NULL, 0);
+ if (err) {
+- bphy_err(wiphy, "WLC_DISASSOC failed (%d)\n", err);
++ bphy_err(drvr, "WLC_DISASSOC failed (%d)\n", err);
+ }
+ if ((vif->wdev.iftype == NL80211_IFTYPE_STATION) ||
+ (vif->wdev.iftype == NL80211_IFTYPE_P2P_CLIENT))
+@@ -1390,6 +1398,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *w
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_if *ifp = netdev_priv(ndev);
+ struct brcmf_cfg80211_profile *profile = &ifp->vif->profile;
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_join_params join_params;
+ size_t join_params_size = 0;
+ s32 err = 0;
+@@ -1454,7 +1463,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *w
+
+ err = brcmf_fil_iovar_int_set(ifp, "wsec", wsec);
+ if (err) {
+- bphy_err(wiphy, "wsec failed (%d)\n", err);
++ bphy_err(drvr, "wsec failed (%d)\n", err);
+ goto done;
+ }
+
+@@ -1466,7 +1475,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *w
+
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_BCNPRD, bcnprd);
+ if (err) {
+- bphy_err(wiphy, "WLC_SET_BCNPRD failed (%d)\n", err);
++ bphy_err(drvr, "WLC_SET_BCNPRD failed (%d)\n", err);
+ goto done;
+ }
+
+@@ -1511,7 +1520,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *w
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_CHANNEL,
+ target_channel);
+ if (err) {
+- bphy_err(wiphy, "WLC_SET_CHANNEL failed (%d)\n", err);
++ bphy_err(drvr, "WLC_SET_CHANNEL failed (%d)\n", err);
+ goto done;
+ }
+ } else
+@@ -1523,7 +1532,7 @@ brcmf_cfg80211_join_ibss(struct wiphy *w
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_SSID,
+ &join_params, join_params_size);
+ if (err) {
+- bphy_err(wiphy, "WLC_SET_SSID failed (%d)\n", err);
++ bphy_err(drvr, "WLC_SET_SSID failed (%d)\n", err);
+ goto done;
+ }
+
+@@ -1560,8 +1569,8 @@ static s32 brcmf_set_wpa_version(struct
+ struct cfg80211_connect_params *sme)
+ {
+ struct brcmf_if *ifp = netdev_priv(ndev);
+- struct wiphy *wiphy = ifp->drvr->wiphy;
+ struct brcmf_cfg80211_profile *profile = ndev_to_prof(ndev);
++ struct brcmf_pub *drvr = ifp->drvr;
+ struct brcmf_cfg80211_security *sec;
+ s32 val = 0;
+ s32 err = 0;
+@@ -1575,7 +1584,7 @@ static s32 brcmf_set_wpa_version(struct
+ brcmf_dbg(CONN, "setting wpa_auth to 0x%0x\n", val);
+ err = brcmf_fil_bsscfg_int_set(ifp, "wpa_auth", val);
+ if (err) {
+- bphy_err(wiphy, "set wpa_auth failed (%d)\n", err);
++ bphy_err(drvr, "set wpa_auth failed (%d)\n", err);
+ return err;
+ }
+ sec = &profile->sec;
+@@ -1587,8 +1596,8 @@ static s32 brcmf_set_auth_type(struct ne
+ struct cfg80211_connect_params *sme)
+ {
+ struct brcmf_if *ifp = netdev_priv(ndev);
+- struct wiphy *wiphy = ifp->drvr->wiphy;
+ struct brcmf_cfg80211_profile *profile = ndev_to_prof(ndev);
++ struct brcmf_pub *drvr = ifp->drvr;
+ struct brcmf_cfg80211_security *sec;
+ s32 val = 0;
+ s32 err = 0;
+@@ -1610,7 +1619,7 @@ static s32 brcmf_set_auth_type(struct ne
+
+ err = brcmf_fil_bsscfg_int_set(ifp, "auth", val);
+ if (err) {
+- bphy_err(wiphy, "set auth failed (%d)\n", err);
++ bphy_err(drvr, "set auth failed (%d)\n", err);
+ return err;
+ }
+ sec = &profile->sec;
+@@ -1623,8 +1632,8 @@ brcmf_set_wsec_mode(struct net_device *n
+ struct cfg80211_connect_params *sme)
+ {
+ struct brcmf_if *ifp = netdev_priv(ndev);
+- struct wiphy *wiphy = ifp->drvr->wiphy;
+ struct brcmf_cfg80211_profile *profile = ndev_to_prof(ndev);
++ struct brcmf_pub *drvr = ifp->drvr;
+ struct brcmf_cfg80211_security *sec;
+ s32 pval = 0;
+ s32 gval = 0;
+@@ -1647,7 +1656,7 @@ brcmf_set_wsec_mode(struct net_device *n
+ pval = AES_ENABLED;
+ break;
+ default:
+- bphy_err(wiphy, "invalid cipher pairwise (%d)\n",
++ bphy_err(drvr, "invalid cipher pairwise (%d)\n",
+ sme->crypto.ciphers_pairwise[0]);
+ return -EINVAL;
+ }
+@@ -1668,7 +1677,7 @@ brcmf_set_wsec_mode(struct net_device *n
+ gval = AES_ENABLED;
+ break;
+ default:
+- bphy_err(wiphy, "invalid cipher group (%d)\n",
++ bphy_err(drvr, "invalid cipher group (%d)\n",
+ sme->crypto.cipher_group);
+ return -EINVAL;
+ }
+@@ -1684,7 +1693,7 @@ brcmf_set_wsec_mode(struct net_device *n
+ wsec = pval | gval;
+ err = brcmf_fil_bsscfg_int_set(ifp, "wsec", wsec);
+ if (err) {
+- bphy_err(wiphy, "error (%d)\n", err);
++ bphy_err(drvr, "error (%d)\n", err);
+ return err;
+ }
+
+@@ -1699,7 +1708,7 @@ static s32
+ brcmf_set_key_mgmt(struct net_device *ndev, struct cfg80211_connect_params *sme)
+ {
+ struct brcmf_if *ifp = netdev_priv(ndev);
+- struct wiphy *wiphy = ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = ifp->drvr;
+ s32 val;
+ s32 err;
+ const struct brcmf_tlv *rsn_ie;
+@@ -1715,7 +1724,7 @@ brcmf_set_key_mgmt(struct net_device *nd
+
+ err = brcmf_fil_bsscfg_int_get(netdev_priv(ndev), "wpa_auth", &val);
+ if (err) {
+- bphy_err(wiphy, "could not get wpa_auth (%d)\n", err);
++ bphy_err(drvr, "could not get wpa_auth (%d)\n", err);
+ return err;
+ }
+ if (val & (WPA_AUTH_PSK | WPA_AUTH_UNSPECIFIED)) {
+@@ -1727,7 +1736,7 @@ brcmf_set_key_mgmt(struct net_device *nd
+ val = WPA_AUTH_PSK;
+ break;
+ default:
+- bphy_err(wiphy, "invalid cipher group (%d)\n",
++ bphy_err(drvr, "invalid cipher group (%d)\n",
+ sme->crypto.cipher_group);
+ return -EINVAL;
+ }
+@@ -1746,7 +1755,7 @@ brcmf_set_key_mgmt(struct net_device *nd
+ val = WPA2_AUTH_PSK;
+ break;
+ default:
+- bphy_err(wiphy, "invalid cipher group (%d)\n",
++ bphy_err(drvr, "invalid cipher group (%d)\n",
+ sme->crypto.cipher_group);
+ return -EINVAL;
+ }
+@@ -1790,7 +1799,7 @@ skip_mfp_config:
+ brcmf_dbg(CONN, "setting wpa_auth to %d\n", val);
+ err = brcmf_fil_bsscfg_int_set(netdev_priv(ndev), "wpa_auth", val);
+ if (err) {
+- bphy_err(wiphy, "could not set wpa_auth (%d)\n", err);
++ bphy_err(drvr, "could not set wpa_auth (%d)\n", err);
+ return err;
+ }
+
+@@ -1802,7 +1811,7 @@ brcmf_set_sharedkey(struct net_device *n
+ struct cfg80211_connect_params *sme)
+ {
+ struct brcmf_if *ifp = netdev_priv(ndev);
+- struct wiphy *wiphy = ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = ifp->drvr;
+ struct brcmf_cfg80211_profile *profile = ndev_to_prof(ndev);
+ struct brcmf_cfg80211_security *sec;
+ struct brcmf_wsec_key key;
+@@ -1829,7 +1838,7 @@ brcmf_set_sharedkey(struct net_device *n
+ key.len = (u32) sme->key_len;
+ key.index = (u32) sme->key_idx;
+ if (key.len > sizeof(key.data)) {
+- bphy_err(wiphy, "Too long key length (%u)\n", key.len);
++ bphy_err(drvr, "Too long key length (%u)\n", key.len);
+ return -EINVAL;
+ }
+ memcpy(key.data, sme->key, key.len);
+@@ -1842,7 +1851,7 @@ brcmf_set_sharedkey(struct net_device *n
+ key.algo = CRYPTO_ALGO_WEP128;
+ break;
+ default:
+- bphy_err(wiphy, "Invalid algorithm (%d)\n",
++ bphy_err(drvr, "Invalid algorithm (%d)\n",
+ sme->crypto.ciphers_pairwise[0]);
+ return -EINVAL;
+ }
+@@ -1859,7 +1868,7 @@ brcmf_set_sharedkey(struct net_device *n
+ val = WL_AUTH_SHARED_KEY; /* shared key */
+ err = brcmf_fil_bsscfg_int_set(ifp, "auth", val);
+ if (err)
+- bphy_err(wiphy, "set auth failed (%d)\n", err);
++ bphy_err(drvr, "set auth failed (%d)\n", err);
+ }
+ return err;
+ }
+@@ -1879,7 +1888,7 @@ enum nl80211_auth_type brcmf_war_auth_ty
+ static void brcmf_set_join_pref(struct brcmf_if *ifp,
+ struct cfg80211_bss_selection *bss_select)
+ {
+- struct wiphy *wiphy = ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = ifp->drvr;
+ struct brcmf_join_pref_params join_pref_params[2];
+ enum nl80211_band band;
+ int err, i = 0;
+@@ -1918,7 +1927,7 @@ static void brcmf_set_join_pref(struct b
+ err = brcmf_fil_iovar_data_set(ifp, "join_pref", join_pref_params,
+ sizeof(join_pref_params));
+ if (err)
+- bphy_err(wiphy, "Set join_pref error (%d)\n", err);
++ bphy_err(drvr, "Set join_pref error (%d)\n", err);
+ }
+
+ static s32
+@@ -1928,6 +1937,7 @@ brcmf_cfg80211_connect(struct wiphy *wip
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_if *ifp = netdev_priv(ndev);
+ struct ieee80211_channel *chan = sme->channel;
++ struct brcmf_pub *drvr = ifp->drvr;
+ struct brcmf_join_params join_params;
+ size_t join_params_size;
+ const struct brcmf_tlv *rsn_ie;
+@@ -1944,7 +1954,7 @@ brcmf_cfg80211_connect(struct wiphy *wip
+ return -EIO;
+
+ if (!sme->ssid) {
+- bphy_err(wiphy, "Invalid ssid\n");
++ bphy_err(drvr, "Invalid ssid\n");
+ return -EOPNOTSUPP;
+ }
+
+@@ -1973,7 +1983,7 @@ brcmf_cfg80211_connect(struct wiphy *wip
+ err = brcmf_vif_set_mgmt_ie(ifp->vif, BRCMF_VNDR_IE_ASSOCREQ_FLAG,
+ sme->ie, sme->ie_len);
+ if (err)
+- bphy_err(wiphy, "Set Assoc REQ IE Failed\n");
++ bphy_err(drvr, "Set Assoc REQ IE Failed\n");
+ else
+ brcmf_dbg(TRACE, "Applied Vndr IEs for Assoc request\n");
+
+@@ -1994,32 +2004,32 @@ brcmf_cfg80211_connect(struct wiphy *wip
+
+ err = brcmf_set_wpa_version(ndev, sme);
+ if (err) {
+- bphy_err(wiphy, "wl_set_wpa_version failed (%d)\n", err);
++ bphy_err(drvr, "wl_set_wpa_version failed (%d)\n", err);
+ goto done;
+ }
+
+ sme->auth_type = brcmf_war_auth_type(ifp, sme->auth_type);
+ err = brcmf_set_auth_type(ndev, sme);
+ if (err) {
+- bphy_err(wiphy, "wl_set_auth_type failed (%d)\n", err);
++ bphy_err(drvr, "wl_set_auth_type failed (%d)\n", err);
+ goto done;
+ }
+
+ err = brcmf_set_wsec_mode(ndev, sme);
+ if (err) {
+- bphy_err(wiphy, "wl_set_set_cipher failed (%d)\n", err);
++ bphy_err(drvr, "wl_set_set_cipher failed (%d)\n", err);
+ goto done;
+ }
+
+ err = brcmf_set_key_mgmt(ndev, sme);
+ if (err) {
+- bphy_err(wiphy, "wl_set_key_mgmt failed (%d)\n", err);
++ bphy_err(drvr, "wl_set_key_mgmt failed (%d)\n", err);
+ goto done;
+ }
+
+ err = brcmf_set_sharedkey(ndev, sme);
+ if (err) {
+- bphy_err(wiphy, "brcmf_set_sharedkey failed (%d)\n", err);
++ bphy_err(drvr, "brcmf_set_sharedkey failed (%d)\n", err);
+ goto done;
+ }
+
+@@ -2106,7 +2116,7 @@ brcmf_cfg80211_connect(struct wiphy *wip
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_SSID,
+ &join_params, join_params_size);
+ if (err)
+- bphy_err(wiphy, "BRCMF_C_SET_SSID failed (%d)\n", err);
++ bphy_err(drvr, "BRCMF_C_SET_SSID failed (%d)\n", err);
+
+ done:
+ if (err)
+@@ -2119,8 +2129,10 @@ static s32
+ brcmf_cfg80211_disconnect(struct wiphy *wiphy, struct net_device *ndev,
+ u16 reason_code)
+ {
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_if *ifp = netdev_priv(ndev);
+ struct brcmf_cfg80211_profile *profile = &ifp->vif->profile;
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_scb_val_le scbval;
+ s32 err = 0;
+
+@@ -2137,7 +2149,7 @@ brcmf_cfg80211_disconnect(struct wiphy *
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_DISASSOC,
+ &scbval, sizeof(scbval));
+ if (err)
+- bphy_err(wiphy, "error (%d)\n", err);
++ bphy_err(drvr, "error (%d)\n", err);
+
+ brcmf_dbg(TRACE, "Exit\n");
+ return err;
+@@ -2150,6 +2162,7 @@ brcmf_cfg80211_set_tx_power(struct wiphy
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct net_device *ndev = cfg_to_ndev(cfg);
+ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct brcmf_pub *drvr = cfg->pub;
+ s32 err;
+ s32 disable;
+ u32 qdbm = 127;
+@@ -2164,7 +2177,7 @@ brcmf_cfg80211_set_tx_power(struct wiphy
+ case NL80211_TX_POWER_LIMITED:
+ case NL80211_TX_POWER_FIXED:
+ if (mbm < 0) {
+- bphy_err(wiphy, "TX_POWER_FIXED - dbm is negative\n");
++ bphy_err(drvr, "TX_POWER_FIXED - dbm is negative\n");
+ err = -EINVAL;
+ goto done;
+ }
+@@ -2174,7 +2187,7 @@ brcmf_cfg80211_set_tx_power(struct wiphy
+ qdbm |= WL_TXPWR_OVERRIDE;
+ break;
+ default:
+- bphy_err(wiphy, "Unsupported type %d\n", type);
++ bphy_err(drvr, "Unsupported type %d\n", type);
+ err = -EINVAL;
+ goto done;
+ }
+@@ -2182,11 +2195,11 @@ brcmf_cfg80211_set_tx_power(struct wiphy
+ disable = WL_RADIO_SW_DISABLE << 16;
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_RADIO, disable);
+ if (err)
+- bphy_err(wiphy, "WLC_SET_RADIO error (%d)\n", err);
++ bphy_err(drvr, "WLC_SET_RADIO error (%d)\n", err);
+
+ err = brcmf_fil_iovar_int_set(ifp, "qtxpower", qdbm);
+ if (err)
+- bphy_err(wiphy, "qtxpower error (%d)\n", err);
++ bphy_err(drvr, "qtxpower error (%d)\n", err);
+
+ done:
+ brcmf_dbg(TRACE, "Exit %d (qdbm)\n", qdbm & ~WL_TXPWR_OVERRIDE);
+@@ -2197,7 +2210,9 @@ static s32
+ brcmf_cfg80211_get_tx_power(struct wiphy *wiphy, struct wireless_dev *wdev,
+ s32 *dbm)
+ {
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_cfg80211_vif *vif = wdev_to_vif(wdev);
++ struct brcmf_pub *drvr = cfg->pub;
+ s32 qdbm = 0;
+ s32 err;
+
+@@ -2207,7 +2222,7 @@ brcmf_cfg80211_get_tx_power(struct wiphy
+
+ err = brcmf_fil_iovar_int_get(vif->ifp, "qtxpower", &qdbm);
+ if (err) {
+- bphy_err(wiphy, "error (%d)\n", err);
++ bphy_err(drvr, "error (%d)\n", err);
+ goto done;
+ }
+ *dbm = (qdbm & ~WL_TXPWR_OVERRIDE) / 4;
+@@ -2222,6 +2237,7 @@ brcmf_cfg80211_config_default_key(struct
+ u8 key_idx, bool unicast, bool multicast)
+ {
+ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct brcmf_pub *drvr = ifp->drvr;
+ u32 index;
+ u32 wsec;
+ s32 err = 0;
+@@ -2233,7 +2249,7 @@ brcmf_cfg80211_config_default_key(struct
+
+ err = brcmf_fil_bsscfg_int_get(ifp, "wsec", &wsec);
+ if (err) {
+- bphy_err(wiphy, "WLC_GET_WSEC error (%d)\n", err);
++ bphy_err(drvr, "WLC_GET_WSEC error (%d)\n", err);
+ goto done;
+ }
+
+@@ -2243,7 +2259,7 @@ brcmf_cfg80211_config_default_key(struct
+ err = brcmf_fil_cmd_int_set(ifp,
+ BRCMF_C_SET_KEY_PRIMARY, index);
+ if (err)
+- bphy_err(wiphy, "error (%d)\n", err);
++ bphy_err(drvr, "error (%d)\n", err);
+ }
+ done:
+ brcmf_dbg(TRACE, "Exit\n");
+@@ -2292,7 +2308,9 @@ brcmf_cfg80211_add_key(struct wiphy *wip
+ u8 key_idx, bool pairwise, const u8 *mac_addr,
+ struct key_params *params)
+ {
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_wsec_key *key;
+ s32 val;
+ s32 wsec;
+@@ -2307,7 +2325,7 @@ brcmf_cfg80211_add_key(struct wiphy *wip
+
+ if (key_idx >= BRCMF_MAX_DEFAULT_KEYS) {
+ /* we ignore this key index in this case */
+- bphy_err(wiphy, "invalid key index (%d)\n", key_idx);
++ bphy_err(drvr, "invalid key index (%d)\n", key_idx);
+ return -EINVAL;
+ }
+
+@@ -2316,7 +2334,7 @@ brcmf_cfg80211_add_key(struct wiphy *wip
+ mac_addr);
+
+ if (params->key_len > sizeof(key->data)) {
+- bphy_err(wiphy, "Too long key length (%u)\n", params->key_len);
++ bphy_err(drvr, "Too long key length (%u)\n", params->key_len);
+ return -EINVAL;
+ }
+
+@@ -2370,7 +2388,7 @@ brcmf_cfg80211_add_key(struct wiphy *wip
+ brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_CCMP\n");
+ break;
+ default:
+- bphy_err(wiphy, "Invalid cipher (0x%x)\n", params->cipher);
++ bphy_err(drvr, "Invalid cipher (0x%x)\n", params->cipher);
+ err = -EINVAL;
+ goto done;
+ }
+@@ -2381,13 +2399,13 @@ brcmf_cfg80211_add_key(struct wiphy *wip
+
+ err = brcmf_fil_bsscfg_int_get(ifp, "wsec", &wsec);
+ if (err) {
+- bphy_err(wiphy, "get wsec error (%d)\n", err);
++ bphy_err(drvr, "get wsec error (%d)\n", err);
+ goto done;
+ }
+ wsec |= val;
+ err = brcmf_fil_bsscfg_int_set(ifp, "wsec", wsec);
+ if (err) {
+- bphy_err(wiphy, "set wsec error (%d)\n", err);
++ bphy_err(drvr, "set wsec error (%d)\n", err);
+ goto done;
+ }
+
+@@ -2402,9 +2420,11 @@ brcmf_cfg80211_get_key(struct wiphy *wip
+ void (*callback)(void *cookie,
+ struct key_params *params))
+ {
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct key_params params;
+ struct brcmf_if *ifp = netdev_priv(ndev);
+ struct brcmf_cfg80211_profile *profile = &ifp->vif->profile;
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_cfg80211_security *sec;
+ s32 wsec;
+ s32 err = 0;
+@@ -2418,7 +2438,7 @@ brcmf_cfg80211_get_key(struct wiphy *wip
+
+ err = brcmf_fil_bsscfg_int_get(ifp, "wsec", &wsec);
+ if (err) {
+- bphy_err(wiphy, "WLC_GET_WSEC error (%d)\n", err);
++ bphy_err(drvr, "WLC_GET_WSEC error (%d)\n", err);
+ /* Ignore this error, may happen during DISASSOC */
+ err = -EAGAIN;
+ goto done;
+@@ -2439,7 +2459,7 @@ brcmf_cfg80211_get_key(struct wiphy *wip
+ params.cipher = WLAN_CIPHER_SUITE_AES_CMAC;
+ brcmf_dbg(CONN, "WLAN_CIPHER_SUITE_AES_CMAC\n");
+ } else {
+- bphy_err(wiphy, "Invalid algo (0x%x)\n", wsec);
++ bphy_err(drvr, "Invalid algo (0x%x)\n", wsec);
+ err = -EINVAL;
+ goto done;
+ }
+@@ -2469,7 +2489,7 @@ brcmf_cfg80211_config_default_mgmt_key(s
+ static void
+ brcmf_cfg80211_reconfigure_wep(struct brcmf_if *ifp)
+ {
+- struct wiphy *wiphy = ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = ifp->drvr;
+ s32 err;
+ u8 key_idx;
+ struct brcmf_wsec_key *key;
+@@ -2486,18 +2506,18 @@ brcmf_cfg80211_reconfigure_wep(struct br
+
+ err = send_key_to_dongle(ifp, key);
+ if (err) {
+- bphy_err(wiphy, "Setting WEP key failed (%d)\n", err);
++ bphy_err(drvr, "Setting WEP key failed (%d)\n", err);
+ return;
+ }
+ err = brcmf_fil_bsscfg_int_get(ifp, "wsec", &wsec);
+ if (err) {
+- bphy_err(wiphy, "get wsec error (%d)\n", err);
++ bphy_err(drvr, "get wsec error (%d)\n", err);
+ return;
+ }
+ wsec |= WEP_ENABLED;
+ err = brcmf_fil_bsscfg_int_set(ifp, "wsec", wsec);
+ if (err)
+- bphy_err(wiphy, "set wsec error (%d)\n", err);
++ bphy_err(drvr, "set wsec error (%d)\n", err);
+ }
+
+ static void brcmf_convert_sta_flags(u32 fw_sta_flags, struct station_info *si)
+@@ -2523,7 +2543,7 @@ static void brcmf_convert_sta_flags(u32
+
+ static void brcmf_fill_bss_param(struct brcmf_if *ifp, struct station_info *si)
+ {
+- struct wiphy *wiphy = ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = ifp->drvr;
+ struct {
+ __le32 len;
+ struct brcmf_bss_info_le bss_le;
+@@ -2539,7 +2559,7 @@ static void brcmf_fill_bss_param(struct
+ err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_BSS_INFO, buf,
+ WL_BSS_INFO_MAX);
+ if (err) {
+- bphy_err(wiphy, "Failed to get bss info (%d)\n", err);
++ bphy_err(drvr, "Failed to get bss info (%d)\n", err);
+ goto out_kfree;
+ }
+ si->filled |= BIT(NL80211_STA_INFO_BSS_PARAM);
+@@ -2561,7 +2581,7 @@ static s32
+ brcmf_cfg80211_get_station_ibss(struct brcmf_if *ifp,
+ struct station_info *sinfo)
+ {
+- struct wiphy *wiphy = ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = ifp->drvr;
+ struct brcmf_scb_val_le scbval;
+ struct brcmf_pktcnt_le pktcnt;
+ s32 err;
+@@ -2571,7 +2591,7 @@ brcmf_cfg80211_get_station_ibss(struct b
+ /* Get the current tx rate */
+ err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_RATE, &rate);
+ if (err < 0) {
+- bphy_err(wiphy, "BRCMF_C_GET_RATE error (%d)\n", err);
++ bphy_err(drvr, "BRCMF_C_GET_RATE error (%d)\n", err);
+ return err;
+ }
+ sinfo->filled |= BIT(NL80211_STA_INFO_TX_BITRATE);
+@@ -2581,7 +2601,7 @@ brcmf_cfg80211_get_station_ibss(struct b
+ err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_RSSI, &scbval,
+ sizeof(scbval));
+ if (err) {
+- bphy_err(wiphy, "BRCMF_C_GET_RSSI error (%d)\n", err);
++ bphy_err(drvr, "BRCMF_C_GET_RSSI error (%d)\n", err);
+ return err;
+ }
+ rssi = le32_to_cpu(scbval.val);
+@@ -2591,7 +2611,7 @@ brcmf_cfg80211_get_station_ibss(struct b
+ err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_GET_PKTCNTS, &pktcnt,
+ sizeof(pktcnt));
+ if (err) {
+- bphy_err(wiphy, "BRCMF_C_GET_GET_PKTCNTS error (%d)\n", err);
++ bphy_err(drvr, "BRCMF_C_GET_GET_PKTCNTS error (%d)\n", err);
+ return err;
+ }
+ sinfo->filled |= BIT(NL80211_STA_INFO_RX_PACKETS) |
+@@ -2610,7 +2630,9 @@ static s32
+ brcmf_cfg80211_get_station(struct wiphy *wiphy, struct net_device *ndev,
+ const u8 *mac, struct station_info *sinfo)
+ {
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_scb_val_le scb_val;
+ s32 err = 0;
+ struct brcmf_sta_info_le sta_info_le;
+@@ -2639,7 +2661,7 @@ brcmf_cfg80211_get_station(struct wiphy
+ &sta_info_le,
+ sizeof(sta_info_le));
+ if (err < 0) {
+- bphy_err(wiphy, "GET STA INFO failed, %d\n", err);
++ bphy_err(drvr, "GET STA INFO failed, %d\n", err);
+ goto done;
+ }
+ }
+@@ -2708,7 +2730,7 @@ brcmf_cfg80211_get_station(struct wiphy
+ err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_RSSI,
+ &scb_val, sizeof(scb_val));
+ if (err) {
+- bphy_err(wiphy, "Could not get rssi (%d)\n",
++ bphy_err(drvr, "Could not get rssi (%d)\n",
+ err);
+ goto done;
+ } else {
+@@ -2730,6 +2752,7 @@ brcmf_cfg80211_dump_station(struct wiphy
+ {
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct brcmf_pub *drvr = cfg->pub;
+ s32 err;
+
+ brcmf_dbg(TRACE, "Enter, idx %d\n", idx);
+@@ -2740,7 +2763,7 @@ brcmf_cfg80211_dump_station(struct wiphy
+ &cfg->assoclist,
+ sizeof(cfg->assoclist));
+ if (err) {
+- bphy_err(wiphy, "BRCMF_C_GET_ASSOCLIST unsupported, err=%d\n",
++ bphy_err(drvr, "BRCMF_C_GET_ASSOCLIST unsupported, err=%d\n",
+ err);
+ cfg->assoclist.count = 0;
+ return -EOPNOTSUPP;
+@@ -2761,6 +2784,7 @@ brcmf_cfg80211_set_power_mgmt(struct wip
+ s32 err = 0;
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct brcmf_pub *drvr = cfg->pub;
+
+ brcmf_dbg(TRACE, "Enter\n");
+
+@@ -2789,9 +2813,9 @@ brcmf_cfg80211_set_power_mgmt(struct wip
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_PM, pm);
+ if (err) {
+ if (err == -ENODEV)
+- bphy_err(wiphy, "net_device is not ready yet\n");
++ bphy_err(drvr, "net_device is not ready yet\n");
+ else
+- bphy_err(wiphy, "error (%d)\n", err);
++ bphy_err(drvr, "error (%d)\n", err);
+ }
+ done:
+ brcmf_dbg(TRACE, "Exit\n");
+@@ -2802,6 +2826,7 @@ static s32 brcmf_inform_single_bss(struc
+ struct brcmf_bss_info_le *bi)
+ {
+ struct wiphy *wiphy = cfg_to_wiphy(cfg);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct ieee80211_channel *notify_channel;
+ struct cfg80211_bss *bss;
+ struct ieee80211_supported_band *band;
+@@ -2815,7 +2840,7 @@ static s32 brcmf_inform_single_bss(struc
+ s32 notify_signal;
+
+ if (le32_to_cpu(bi->length) > WL_BSS_INFO_MAX) {
+- bphy_err(wiphy, "Bss info is larger than buffer. Discarding\n");
++ bphy_err(drvr, "Bss info is larger than buffer. Discarding\n");
+ return 0;
+ }
+
+@@ -2873,7 +2898,7 @@ next_bss_le(struct brcmf_scan_results *l
+
+ static s32 brcmf_inform_bss(struct brcmf_cfg80211_info *cfg)
+ {
+- struct wiphy *wiphy = cfg_to_wiphy(cfg);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_scan_results *bss_list;
+ struct brcmf_bss_info_le *bi = NULL; /* must be initialized */
+ s32 err = 0;
+@@ -2882,7 +2907,7 @@ static s32 brcmf_inform_bss(struct brcmf
+ bss_list = (struct brcmf_scan_results *)cfg->escan_info.escan_buf;
+ if (bss_list->count != 0 &&
+ bss_list->version != BRCMF_BSS_INFO_VERSION) {
+- bphy_err(wiphy, "Version %d != WL_BSS_INFO_VERSION\n",
++ bphy_err(drvr, "Version %d != WL_BSS_INFO_VERSION\n",
+ bss_list->version);
+ return -EOPNOTSUPP;
+ }
+@@ -2900,6 +2925,7 @@ static s32 brcmf_inform_ibss(struct brcm
+ struct net_device *ndev, const u8 *bssid)
+ {
+ struct wiphy *wiphy = cfg_to_wiphy(cfg);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct ieee80211_channel *notify_channel;
+ struct brcmf_bss_info_le *bi = NULL;
+ struct ieee80211_supported_band *band;
+@@ -2927,7 +2953,7 @@ static s32 brcmf_inform_ibss(struct brcm
+ err = brcmf_fil_cmd_data_get(netdev_priv(ndev), BRCMF_C_GET_BSS_INFO,
+ buf, WL_BSS_INFO_MAX);
+ if (err) {
+- bphy_err(wiphy, "WLC_GET_BSS_INFO failed: %d\n", err);
++ bphy_err(drvr, "WLC_GET_BSS_INFO failed: %d\n", err);
+ goto CleanUp;
+ }
+
+@@ -2981,7 +3007,7 @@ CleanUp:
+ static s32 brcmf_update_bss_info(struct brcmf_cfg80211_info *cfg,
+ struct brcmf_if *ifp)
+ {
+- struct wiphy *wiphy = cfg_to_wiphy(cfg);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_bss_info_le *bi;
+ const struct brcmf_tlv *tim;
+ u16 beacon_interval;
+@@ -2998,7 +3024,7 @@ static s32 brcmf_update_bss_info(struct
+ err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_BSS_INFO,
+ cfg->extra_buf, WL_EXTRA_BUF_MAX);
+ if (err) {
+- bphy_err(wiphy, "Could not get bss info %d\n", err);
++ bphy_err(drvr, "Could not get bss info %d\n", err);
+ goto update_bss_info_out;
+ }
+
+@@ -3023,7 +3049,7 @@ static s32 brcmf_update_bss_info(struct
+ u32 var;
+ err = brcmf_fil_iovar_int_get(ifp, "dtim_assoc", &var);
+ if (err) {
+- bphy_err(wiphy, "wl dtim_assoc failed (%d)\n", err);
++ bphy_err(drvr, "wl dtim_assoc failed (%d)\n", err);
+ goto update_bss_info_out;
+ }
+ dtim_period = (u8)var;
+@@ -3061,10 +3087,10 @@ static void brcmf_escan_timeout(unsigned
+ {
+ struct brcmf_cfg80211_info *cfg =
+ (struct brcmf_cfg80211_info *)data;
+- struct wiphy *wiphy = cfg_to_wiphy(cfg);
++ struct brcmf_pub *drvr = cfg->pub;
+
+ if (cfg->internal_escan || cfg->scan_request) {
+- bphy_err(wiphy, "timer expired\n");
++ bphy_err(drvr, "timer expired\n");
+ schedule_work(&cfg->escan_timeout_work);
+ }
+ }
+@@ -3112,8 +3138,8 @@ static s32
+ brcmf_cfg80211_escan_handler(struct brcmf_if *ifp,
+ const struct brcmf_event_msg *e, void *data)
+ {
+- struct brcmf_cfg80211_info *cfg = ifp->drvr->config;
+- struct wiphy *wiphy = cfg_to_wiphy(cfg);
++ struct brcmf_pub *drvr = ifp->drvr;
++ struct brcmf_cfg80211_info *cfg = drvr->config;
+ s32 status;
+ struct brcmf_escan_result_le *escan_result_le;
+ u32 escan_buflen;
+@@ -3130,7 +3156,7 @@ brcmf_cfg80211_escan_handler(struct brcm
+ goto exit;
+
+ if (!test_bit(BRCMF_SCAN_STATUS_BUSY, &cfg->scan_status)) {
+- bphy_err(wiphy, "scan not ready, bsscfgidx=%d\n",
++ bphy_err(drvr, "scan not ready, bsscfgidx=%d\n",
+ ifp->bsscfgidx);
+ return -EPERM;
+ }
+@@ -3138,24 +3164,24 @@ brcmf_cfg80211_escan_handler(struct brcm
+ if (status == BRCMF_E_STATUS_PARTIAL) {
+ brcmf_dbg(SCAN, "ESCAN Partial result\n");
+ if (e->datalen < sizeof(*escan_result_le)) {
+- bphy_err(wiphy, "invalid event data length\n");
++ bphy_err(drvr, "invalid event data length\n");
+ goto exit;
+ }
+ escan_result_le = (struct brcmf_escan_result_le *) data;
+ if (!escan_result_le) {
+- bphy_err(wiphy, "Invalid escan result (NULL pointer)\n");
++ bphy_err(drvr, "Invalid escan result (NULL pointer)\n");
+ goto exit;
+ }
+ escan_buflen = le32_to_cpu(escan_result_le->buflen);
+ if (escan_buflen > BRCMF_ESCAN_BUF_SIZE ||
+ escan_buflen > e->datalen ||
+ escan_buflen < sizeof(*escan_result_le)) {
+- bphy_err(wiphy, "Invalid escan buffer length: %d\n",
++ bphy_err(drvr, "Invalid escan buffer length: %d\n",
+ escan_buflen);
+ goto exit;
+ }
+ if (le16_to_cpu(escan_result_le->bss_count) != 1) {
+- bphy_err(wiphy, "Invalid bss_count %d: ignoring\n",
++ bphy_err(drvr, "Invalid bss_count %d: ignoring\n",
+ escan_result_le->bss_count);
+ goto exit;
+ }
+@@ -3171,7 +3197,7 @@ brcmf_cfg80211_escan_handler(struct brcm
+
+ bi_length = le32_to_cpu(bss_info_le->length);
+ if (bi_length != escan_buflen - WL_ESCAN_RESULTS_FIXED_SIZE) {
+- bphy_err(wiphy, "Ignoring invalid bss_info length: %d\n",
++ bphy_err(drvr, "Ignoring invalid bss_info length: %d\n",
+ bi_length);
+ goto exit;
+ }
+@@ -3180,7 +3206,7 @@ brcmf_cfg80211_escan_handler(struct brcm
+ BIT(NL80211_IFTYPE_ADHOC))) {
+ if (le16_to_cpu(bss_info_le->capability) &
+ WLAN_CAPABILITY_IBSS) {
+- bphy_err(wiphy, "Ignoring IBSS result\n");
++ bphy_err(drvr, "Ignoring IBSS result\n");
+ goto exit;
+ }
+ }
+@@ -3188,7 +3214,7 @@ brcmf_cfg80211_escan_handler(struct brcm
+ list = (struct brcmf_scan_results *)
+ cfg->escan_info.escan_buf;
+ if (bi_length > BRCMF_ESCAN_BUF_SIZE - list->buflen) {
+- bphy_err(wiphy, "Buffer is too small: ignoring\n");
++ bphy_err(drvr, "Buffer is too small: ignoring\n");
+ goto exit;
+ }
+
+@@ -3345,7 +3371,8 @@ static s32
+ brcmf_notify_sched_scan_results(struct brcmf_if *ifp,
+ const struct brcmf_event_msg *e, void *data)
+ {
+- struct brcmf_cfg80211_info *cfg = ifp->drvr->config;
++ struct brcmf_pub *drvr = ifp->drvr;
++ struct brcmf_cfg80211_info *cfg = drvr->config;
+ struct brcmf_pno_net_info_le *netinfo, *netinfo_start;
+ struct cfg80211_scan_request *request = NULL;
+ struct wiphy *wiphy = cfg_to_wiphy(cfg);
+@@ -3377,14 +3404,14 @@ brcmf_notify_sched_scan_results(struct b
+ WARN_ON(status != BRCMF_PNO_SCAN_COMPLETE);
+ brcmf_dbg(SCAN, "PFN NET FOUND event. count: %d\n", result_count);
+ if (!result_count) {
+- bphy_err(wiphy, "FALSE PNO Event. (pfn_count == 0)\n");
++ bphy_err(drvr, "FALSE PNO Event. (pfn_count == 0)\n");
+ goto out_err;
+ }
+
+ netinfo_start = brcmf_get_netinfo_array(pfn_result);
+ datalen = e->datalen - ((void *)netinfo_start - (void *)pfn_result);
+ if (datalen < result_count * sizeof(*netinfo)) {
+- bphy_err(wiphy, "insufficient event data\n");
++ bphy_err(drvr, "insufficient event data\n");
+ goto out_err;
+ }
+
+@@ -3428,12 +3455,13 @@ brcmf_cfg80211_sched_scan_start(struct w
+ {
+ struct brcmf_if *ifp = netdev_priv(ndev);
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
++ struct brcmf_pub *drvr = cfg->pub;
+
+ brcmf_dbg(SCAN, "Enter n_match_sets:%d n_ssids:%d\n",
+ req->n_match_sets, req->n_ssids);
+
+ if (test_bit(BRCMF_SCAN_STATUS_SUPPRESS, &cfg->scan_status)) {
+- bphy_err(wiphy, "Scanning suppressed: status (%lu)\n",
++ bphy_err(drvr, "Scanning suppressed: status (%lu)\n",
+ cfg->scan_status);
+ return -EAGAIN;
+ }
+@@ -3512,8 +3540,8 @@ static s32
+ brcmf_wowl_nd_results(struct brcmf_if *ifp, const struct brcmf_event_msg *e,
+ void *data)
+ {
+- struct brcmf_cfg80211_info *cfg = ifp->drvr->config;
+- struct wiphy *wiphy = cfg_to_wiphy(cfg);
++ struct brcmf_pub *drvr = ifp->drvr;
++ struct brcmf_cfg80211_info *cfg = drvr->config;
+ struct brcmf_pno_scanresults_le *pfn_result;
+ struct brcmf_pno_net_info_le *netinfo;
+
+@@ -3532,7 +3560,7 @@ brcmf_wowl_nd_results(struct brcmf_if *i
+ }
+
+ if (le32_to_cpu(pfn_result->count) < 1) {
+- bphy_err(wiphy, "Invalid result count, expected 1 (%d)\n",
++ bphy_err(drvr, "Invalid result count, expected 1 (%d)\n",
+ le32_to_cpu(pfn_result->count));
+ return -EINVAL;
+ }
+@@ -3560,6 +3588,7 @@ brcmf_wowl_nd_results(struct brcmf_if *i
+ static void brcmf_report_wowl_wakeind(struct wiphy *wiphy, struct brcmf_if *ifp)
+ {
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_wowl_wakeind_le wake_ind_le;
+ struct cfg80211_wowlan_wakeup wakeup_data;
+ struct cfg80211_wowlan_wakeup *wakeup;
+@@ -3570,7 +3599,7 @@ static void brcmf_report_wowl_wakeind(st
+ err = brcmf_fil_iovar_data_get(ifp, "wowl_wakeind", &wake_ind_le,
+ sizeof(wake_ind_le));
+ if (err) {
+- bphy_err(wiphy, "Get wowl_wakeind failed, err = %d\n", err);
++ bphy_err(drvr, "Get wowl_wakeind failed, err = %d\n", err);
+ return;
+ }
+
+@@ -3611,7 +3640,7 @@ static void brcmf_report_wowl_wakeind(st
+ cfg->wowl.nd_data_completed,
+ BRCMF_ND_INFO_TIMEOUT);
+ if (!timeout)
+- bphy_err(wiphy, "No result for wowl net detect\n");
++ bphy_err(drvr, "No result for wowl net detect\n");
+ else
+ wakeup_data.net_detect = cfg->wowl.nd_info;
+ }
+@@ -3800,6 +3829,7 @@ brcmf_cfg80211_set_pmksa(struct wiphy *w
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_if *ifp = netdev_priv(ndev);
+ struct brcmf_pmksa *pmk = &cfg->pmk_list.pmk[0];
++ struct brcmf_pub *drvr = cfg->pub;
+ s32 err;
+ u32 npmk, i;
+
+@@ -3819,7 +3849,7 @@ brcmf_cfg80211_set_pmksa(struct wiphy *w
+ cfg->pmk_list.npmk = cpu_to_le32(npmk);
+ }
+ } else {
+- bphy_err(wiphy, "Too many PMKSA entries cached %d\n", npmk);
++ bphy_err(drvr, "Too many PMKSA entries cached %d\n", npmk);
+ return -EINVAL;
+ }
+
+@@ -3842,6 +3872,7 @@ brcmf_cfg80211_del_pmksa(struct wiphy *w
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_if *ifp = netdev_priv(ndev);
+ struct brcmf_pmksa *pmk = &cfg->pmk_list.pmk[0];
++ struct brcmf_pub *drvr = cfg->pub;
+ s32 err;
+ u32 npmk, i;
+
+@@ -3865,7 +3896,7 @@ brcmf_cfg80211_del_pmksa(struct wiphy *w
+ memset(&pmk[i], 0, sizeof(*pmk));
+ cfg->pmk_list.npmk = cpu_to_le32(npmk - 1);
+ } else {
+- bphy_err(wiphy, "Cache entry not found\n");
++ bphy_err(drvr, "Cache entry not found\n");
+ return -EINVAL;
+ }
+
+@@ -3897,25 +3928,25 @@ brcmf_cfg80211_flush_pmksa(struct wiphy
+
+ static s32 brcmf_configure_opensecurity(struct brcmf_if *ifp)
+ {
+- struct wiphy *wiphy = ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = ifp->drvr;
+ s32 err;
+
+ /* set auth */
+ err = brcmf_fil_bsscfg_int_set(ifp, "auth", 0);
+ if (err < 0) {
+- bphy_err(wiphy, "auth error %d\n", err);
++ bphy_err(drvr, "auth error %d\n", err);
+ return err;
+ }
+ /* set wsec */
+ err = brcmf_fil_bsscfg_int_set(ifp, "wsec", 0);
+ if (err < 0) {
+- bphy_err(wiphy, "wsec error %d\n", err);
++ bphy_err(drvr, "wsec error %d\n", err);
+ return err;
+ }
+ /* set upper-layer auth */
+ err = brcmf_fil_bsscfg_int_set(ifp, "wpa_auth", WPA_AUTH_NONE);
+ if (err < 0) {
+- bphy_err(wiphy, "wpa_auth error %d\n", err);
++ bphy_err(drvr, "wpa_auth error %d\n", err);
+ return err;
+ }
+
+@@ -3935,7 +3966,7 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ const struct brcmf_vs_tlv *wpa_ie,
+ bool is_rsn_ie)
+ {
+- struct wiphy *wiphy = ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = ifp->drvr;
+ u32 auth = 0; /* d11 open authentication */
+ u16 count;
+ s32 err = 0;
+@@ -3966,13 +3997,13 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ /* check for multicast cipher suite */
+ if (offset + WPA_IE_MIN_OUI_LEN > len) {
+ err = -EINVAL;
+- bphy_err(wiphy, "no multicast cipher suite\n");
++ bphy_err(drvr, "no multicast cipher suite\n");
+ goto exit;
+ }
+
+ if (!brcmf_valid_wpa_oui(&data[offset], is_rsn_ie)) {
+ err = -EINVAL;
+- bphy_err(wiphy, "ivalid OUI\n");
++ bphy_err(drvr, "ivalid OUI\n");
+ goto exit;
+ }
+ offset += TLV_OUI_LEN;
+@@ -3994,7 +4025,7 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ break;
+ default:
+ err = -EINVAL;
+- bphy_err(wiphy, "Invalid multi cast cipher info\n");
++ bphy_err(drvr, "Invalid multi cast cipher info\n");
+ goto exit;
+ }
+
+@@ -4005,13 +4036,13 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ /* Check for unicast suite(s) */
+ if (offset + (WPA_IE_MIN_OUI_LEN * count) > len) {
+ err = -EINVAL;
+- bphy_err(wiphy, "no unicast cipher suite\n");
++ bphy_err(drvr, "no unicast cipher suite\n");
+ goto exit;
+ }
+ for (i = 0; i < count; i++) {
+ if (!brcmf_valid_wpa_oui(&data[offset], is_rsn_ie)) {
+ err = -EINVAL;
+- bphy_err(wiphy, "ivalid OUI\n");
++ bphy_err(drvr, "ivalid OUI\n");
+ goto exit;
+ }
+ offset += TLV_OUI_LEN;
+@@ -4029,7 +4060,7 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ pval |= AES_ENABLED;
+ break;
+ default:
+- bphy_err(wiphy, "Invalid unicast security info\n");
++ bphy_err(drvr, "Invalid unicast security info\n");
+ }
+ offset++;
+ }
+@@ -4039,13 +4070,13 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ /* Check for auth key management suite(s) */
+ if (offset + (WPA_IE_MIN_OUI_LEN * count) > len) {
+ err = -EINVAL;
+- bphy_err(wiphy, "no auth key mgmt suite\n");
++ bphy_err(drvr, "no auth key mgmt suite\n");
+ goto exit;
+ }
+ for (i = 0; i < count; i++) {
+ if (!brcmf_valid_wpa_oui(&data[offset], is_rsn_ie)) {
+ err = -EINVAL;
+- bphy_err(wiphy, "ivalid OUI\n");
++ bphy_err(drvr, "ivalid OUI\n");
+ goto exit;
+ }
+ offset += TLV_OUI_LEN;
+@@ -4073,7 +4104,7 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ wpa_auth |= WPA2_AUTH_1X_SHA256;
+ break;
+ default:
+- bphy_err(wiphy, "Invalid key mgmt info\n");
++ bphy_err(drvr, "Invalid key mgmt info\n");
+ }
+ offset++;
+ }
+@@ -4115,7 +4146,7 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ err = brcmf_fil_bsscfg_int_set(ifp, "wme_bss_disable",
+ wme_bss_disable);
+ if (err < 0) {
+- bphy_err(wiphy, "wme_bss_disable error %d\n", err);
++ bphy_err(drvr, "wme_bss_disable error %d\n", err);
+ goto exit;
+ }
+
+@@ -4129,7 +4160,7 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ &data[offset],
+ WPA_IE_MIN_OUI_LEN);
+ if (err < 0) {
+- bphy_err(wiphy, "bip error %d\n", err);
++ bphy_err(drvr, "bip error %d\n", err);
+ goto exit;
+ }
+ }
+@@ -4140,13 +4171,13 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ /* set auth */
+ err = brcmf_fil_bsscfg_int_set(ifp, "auth", auth);
+ if (err < 0) {
+- bphy_err(wiphy, "auth error %d\n", err);
++ bphy_err(drvr, "auth error %d\n", err);
+ goto exit;
+ }
+ /* set wsec */
+ err = brcmf_fil_bsscfg_int_set(ifp, "wsec", wsec);
+ if (err < 0) {
+- bphy_err(wiphy, "wsec error %d\n", err);
++ bphy_err(drvr, "wsec error %d\n", err);
+ goto exit;
+ }
+ /* Configure MFP, this needs to go after wsec otherwise the wsec command
+@@ -4155,14 +4186,14 @@ brcmf_configure_wpaie(struct brcmf_if *i
+ if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MFP)) {
+ err = brcmf_fil_bsscfg_int_set(ifp, "mfp", mfp);
+ if (err < 0) {
+- bphy_err(wiphy, "mfp error %d\n", err);
++ bphy_err(drvr, "mfp error %d\n", err);
+ goto exit;
+ }
+ }
+ /* set upper-layer auth */
+ err = brcmf_fil_bsscfg_int_set(ifp, "wpa_auth", wpa_auth);
+ if (err < 0) {
+- bphy_err(wiphy, "wpa_auth error %d\n", err);
++ bphy_err(drvr, "wpa_auth error %d\n", err);
+ goto exit;
+ }
+
+@@ -4248,8 +4279,8 @@ brcmf_vndr_ie(u8 *iebuf, s32 pktflag, u8
+ s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 pktflag,
+ const u8 *vndr_ie_buf, u32 vndr_ie_len)
+ {
++ struct brcmf_pub *drvr;
+ struct brcmf_if *ifp;
+- struct wiphy *wiphy;
+ struct vif_saved_ie *saved_ie;
+ s32 err = 0;
+ u8 *iovar_ie_buf;
+@@ -4270,7 +4301,7 @@ s32 brcmf_vif_set_mgmt_ie(struct brcmf_c
+ if (!vif)
+ return -ENODEV;
+ ifp = vif->ifp;
+- wiphy = ifp->drvr->wiphy;
++ drvr = ifp->drvr;
+ saved_ie = &vif->saved_ie;
+
+ brcmf_dbg(TRACE, "bsscfgidx %d, pktflag : 0x%02X\n", ifp->bsscfgidx,
+@@ -4302,13 +4333,13 @@ s32 brcmf_vif_set_mgmt_ie(struct brcmf_c
+ break;
+ default:
+ err = -EPERM;
+- bphy_err(wiphy, "not suitable type\n");
++ bphy_err(drvr, "not suitable type\n");
+ goto exit;
+ }
+
+ if (vndr_ie_len > mgmt_ie_buf_len) {
+ err = -ENOMEM;
+- bphy_err(wiphy, "extra IE size too big\n");
++ bphy_err(drvr, "extra IE size too big\n");
+ goto exit;
+ }
+
+@@ -4369,7 +4400,7 @@ s32 brcmf_vif_set_mgmt_ie(struct brcmf_c
+ /* verify remained buf size before copy data */
+ if (remained_buf_len < (vndrie_info->vndrie.len +
+ VNDR_IE_VSIE_OFFSET)) {
+- bphy_err(wiphy, "no space in mgmt_ie_buf: len left %d",
++ bphy_err(drvr, "no space in mgmt_ie_buf: len left %d",
+ remained_buf_len);
+ break;
+ }
+@@ -4401,7 +4432,7 @@ s32 brcmf_vif_set_mgmt_ie(struct brcmf_c
+ err = brcmf_fil_bsscfg_data_set(ifp, "vndr_ie", iovar_ie_buf,
+ total_ie_buf_len);
+ if (err)
+- bphy_err(wiphy, "vndr ie set error : %d\n", err);
++ bphy_err(drvr, "vndr ie set error : %d\n", err);
+ }
+
+ exit:
+@@ -4429,14 +4460,14 @@ static s32
+ brcmf_config_ap_mgmt_ie(struct brcmf_cfg80211_vif *vif,
+ struct cfg80211_beacon_data *beacon)
+ {
+- struct wiphy *wiphy = vif->ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = vif->ifp->drvr;
+ s32 err;
+
+ /* Set Beacon IEs to FW */
+ err = brcmf_vif_set_mgmt_ie(vif, BRCMF_VNDR_IE_BEACON_FLAG,
+ beacon->tail, beacon->tail_len);
+ if (err) {
+- bphy_err(wiphy, "Set Beacon IE Failed\n");
++ bphy_err(drvr, "Set Beacon IE Failed\n");
+ return err;
+ }
+ brcmf_dbg(TRACE, "Applied Vndr IEs for Beacon\n");
+@@ -4446,7 +4477,7 @@ brcmf_config_ap_mgmt_ie(struct brcmf_cfg
+ beacon->proberesp_ies,
+ beacon->proberesp_ies_len);
+ if (err)
+- bphy_err(wiphy, "Set Probe Resp IE Failed\n");
++ bphy_err(drvr, "Set Probe Resp IE Failed\n");
+ else
+ brcmf_dbg(TRACE, "Applied Vndr IEs for Probe Resp\n");
+
+@@ -4460,6 +4491,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+ s32 ie_offset;
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct brcmf_pub *drvr = cfg->pub;
+ const struct brcmf_tlv *ssid_ie;
+ const struct brcmf_tlv *country_ie;
+ struct brcmf_ssid_le ssid_le;
+@@ -4555,7 +4587,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_REGULATORY,
+ is_11d);
+ if (err < 0) {
+- bphy_err(wiphy, "Regulatory Set Error, %d\n",
++ bphy_err(drvr, "Regulatory Set Error, %d\n",
+ err);
+ goto exit;
+ }
+@@ -4564,7 +4596,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_BCNPRD,
+ settings->beacon_interval);
+ if (err < 0) {
+- bphy_err(wiphy, "Beacon Interval Set Error, %d\n",
++ bphy_err(drvr, "Beacon Interval Set Error, %d\n",
+ err);
+ goto exit;
+ }
+@@ -4573,7 +4605,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_DTIMPRD,
+ settings->dtim_period);
+ if (err < 0) {
+- bphy_err(wiphy, "DTIM Interval Set Error, %d\n",
++ bphy_err(drvr, "DTIM Interval Set Error, %d\n",
+ err);
+ goto exit;
+ }
+@@ -4584,7 +4616,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+ !brcmf_feat_is_enabled(ifp, BRCMF_FEAT_RSDB))) {
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_DOWN, 1);
+ if (err < 0) {
+- bphy_err(wiphy, "BRCMF_C_DOWN error %d\n",
++ bphy_err(drvr, "BRCMF_C_DOWN error %d\n",
+ err);
+ goto exit;
+ }
+@@ -4593,7 +4625,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_INFRA, 1);
+ if (err < 0) {
+- bphy_err(wiphy, "SET INFRA error %d\n", err);
++ bphy_err(drvr, "SET INFRA error %d\n", err);
+ goto exit;
+ }
+ } else if (WARN_ON(supports_11d && (is_11d != ifp->vif->is_11d))) {
+@@ -4609,7 +4641,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_AP, 1);
+ if (err < 0) {
+- bphy_err(wiphy, "setting AP mode failed %d\n",
++ bphy_err(drvr, "setting AP mode failed %d\n",
+ err);
+ goto exit;
+ }
+@@ -4619,14 +4651,14 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+ */
+ err = brcmf_fil_iovar_int_set(ifp, "chanspec", chanspec);
+ if (err < 0) {
+- bphy_err(wiphy, "Set Channel failed: chspec=%d, %d\n",
++ bphy_err(drvr, "Set Channel failed: chspec=%d, %d\n",
+ chanspec, err);
+ goto exit;
+ }
+ }
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_UP, 1);
+ if (err < 0) {
+- bphy_err(wiphy, "BRCMF_C_UP error (%d)\n", err);
++ bphy_err(drvr, "BRCMF_C_UP error (%d)\n", err);
+ goto exit;
+ }
+ /* On DOWN the firmware removes the WEP keys, reconfigure
+@@ -4641,14 +4673,14 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_SSID,
+ &join_params, sizeof(join_params));
+ if (err < 0) {
+- bphy_err(wiphy, "SET SSID error (%d)\n", err);
++ bphy_err(drvr, "SET SSID error (%d)\n", err);
+ goto exit;
+ }
+
+ if (settings->hidden_ssid) {
+ err = brcmf_fil_iovar_int_set(ifp, "closednet", 1);
+ if (err) {
+- bphy_err(wiphy, "closednet error (%d)\n", err);
++ bphy_err(drvr, "closednet error (%d)\n", err);
+ goto exit;
+ }
+ }
+@@ -4657,14 +4689,14 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+ } else if (dev_role == NL80211_IFTYPE_P2P_GO) {
+ err = brcmf_fil_iovar_int_set(ifp, "chanspec", chanspec);
+ if (err < 0) {
+- bphy_err(wiphy, "Set Channel failed: chspec=%d, %d\n",
++ bphy_err(drvr, "Set Channel failed: chspec=%d, %d\n",
+ chanspec, err);
+ goto exit;
+ }
+ err = brcmf_fil_bsscfg_data_set(ifp, "ssid", &ssid_le,
+ sizeof(ssid_le));
+ if (err < 0) {
+- bphy_err(wiphy, "setting ssid failed %d\n", err);
++ bphy_err(drvr, "setting ssid failed %d\n", err);
+ goto exit;
+ }
+ bss_enable.bsscfgidx = cpu_to_le32(ifp->bsscfgidx);
+@@ -4672,7 +4704,7 @@ brcmf_cfg80211_start_ap(struct wiphy *wi
+ err = brcmf_fil_iovar_data_set(ifp, "bss", &bss_enable,
+ sizeof(bss_enable));
+ if (err < 0) {
+- bphy_err(wiphy, "bss_enable config failed %d\n", err);
++ bphy_err(drvr, "bss_enable config failed %d\n", err);
+ goto exit;
+ }
+
+@@ -4695,7 +4727,9 @@ exit:
+
+ static int brcmf_cfg80211_stop_ap(struct wiphy *wiphy, struct net_device *ndev)
+ {
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct brcmf_pub *drvr = cfg->pub;
+ s32 err;
+ struct brcmf_fil_bss_enable_le bss_enable;
+ struct brcmf_join_params join_params;
+@@ -4720,13 +4754,13 @@ static int brcmf_cfg80211_stop_ap(struct
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_SSID,
+ &join_params, sizeof(join_params));
+ if (err < 0)
+- bphy_err(wiphy, "SET SSID error (%d)\n", err);
++ bphy_err(drvr, "SET SSID error (%d)\n", err);
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_DOWN, 1);
+ if (err < 0)
+- bphy_err(wiphy, "BRCMF_C_DOWN error %d\n", err);
++ bphy_err(drvr, "BRCMF_C_DOWN error %d\n", err);
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_AP, 0);
+ if (err < 0)
+- bphy_err(wiphy, "setting AP mode failed %d\n", err);
++ bphy_err(drvr, "setting AP mode failed %d\n", err);
+ if (brcmf_feat_is_enabled(ifp, BRCMF_FEAT_MBSS))
+ brcmf_fil_iovar_int_set(ifp, "mbss", 0);
+ brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_REGULATORY,
+@@ -4734,7 +4768,7 @@ static int brcmf_cfg80211_stop_ap(struct
+ /* Bring device back up so it can be used again */
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_UP, 1);
+ if (err < 0)
+- bphy_err(wiphy, "BRCMF_C_UP error %d\n", err);
++ bphy_err(drvr, "BRCMF_C_UP error %d\n", err);
+
+ brcmf_vif_clear_mgmt_ies(ifp->vif);
+ } else {
+@@ -4743,7 +4777,7 @@ static int brcmf_cfg80211_stop_ap(struct
+ err = brcmf_fil_iovar_data_set(ifp, "bss", &bss_enable,
+ sizeof(bss_enable));
+ if (err < 0)
+- bphy_err(wiphy, "bss_enable config failed %d\n", err);
++ bphy_err(drvr, "bss_enable config failed %d\n", err);
+ }
+ brcmf_set_mpc(ifp, 1);
+ brcmf_configure_arp_nd_offload(ifp, true);
+@@ -4772,6 +4806,7 @@ brcmf_cfg80211_del_station(struct wiphy
+ struct station_del_parameters *params)
+ {
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_scb_val_le scbval;
+ struct brcmf_if *ifp = netdev_priv(ndev);
+ s32 err;
+@@ -4791,7 +4826,7 @@ brcmf_cfg80211_del_station(struct wiphy
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SCB_DEAUTHENTICATE_FOR_REASON,
+ &scbval, sizeof(scbval));
+ if (err)
+- bphy_err(wiphy, "SCB_DEAUTHENTICATE_FOR_REASON failed %d\n",
++ bphy_err(drvr, "SCB_DEAUTHENTICATE_FOR_REASON failed %d\n",
+ err);
+
+ brcmf_dbg(TRACE, "Exit\n");
+@@ -4802,7 +4837,9 @@ static int
+ brcmf_cfg80211_change_station(struct wiphy *wiphy, struct net_device *ndev,
+ const u8 *mac, struct station_parameters *params)
+ {
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_if *ifp = netdev_priv(ndev);
++ struct brcmf_pub *drvr = cfg->pub;
+ s32 err;
+
+ brcmf_dbg(TRACE, "Enter, MAC %pM, mask 0x%04x set 0x%04x\n", mac,
+@@ -4822,7 +4859,7 @@ brcmf_cfg80211_change_station(struct wip
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_SCB_DEAUTHORIZE,
+ (void *)mac, ETH_ALEN);
+ if (err < 0)
+- bphy_err(wiphy, "Setting SCB (de-)authorize failed, %d\n", err);
++ bphy_err(drvr, "Setting SCB (de-)authorize failed, %d\n", err);
+
+ return err;
+ }
+@@ -4852,6 +4889,7 @@ brcmf_cfg80211_mgmt_tx(struct wiphy *wip
+ {
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct ieee80211_channel *chan = params->chan;
++ struct brcmf_pub *drvr = cfg->pub;
+ const u8 *buf = params->buf;
+ size_t len = params->len;
+ const struct ieee80211_mgmt *mgmt;
+@@ -4872,7 +4910,7 @@ brcmf_cfg80211_mgmt_tx(struct wiphy *wip
+ mgmt = (const struct ieee80211_mgmt *)buf;
+
+ if (!ieee80211_is_mgmt(mgmt->frame_control)) {
+- bphy_err(wiphy, "Driver only allows MGMT packet type\n");
++ bphy_err(drvr, "Driver only allows MGMT packet type\n");
+ return -EPERM;
+ }
+
+@@ -4903,13 +4941,13 @@ brcmf_cfg80211_mgmt_tx(struct wiphy *wip
+ GFP_KERNEL);
+ } else if (ieee80211_is_action(mgmt->frame_control)) {
+ if (len > BRCMF_FIL_ACTION_FRAME_SIZE + DOT11_MGMT_HDR_LEN) {
+- bphy_err(wiphy, "invalid action frame length\n");
++ bphy_err(drvr, "invalid action frame length\n");
+ err = -EINVAL;
+ goto exit;
+ }
+ af_params = kzalloc(sizeof(*af_params), GFP_KERNEL);
+ if (af_params == NULL) {
+- bphy_err(wiphy, "unable to allocate frame\n");
++ bphy_err(drvr, "unable to allocate frame\n");
+ err = -ENOMEM;
+ goto exit;
+ }
+@@ -4960,6 +4998,7 @@ brcmf_cfg80211_cancel_remain_on_channel(
+ u64 cookie)
+ {
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_cfg80211_vif *vif;
+ int err = 0;
+
+@@ -4967,7 +5006,7 @@ brcmf_cfg80211_cancel_remain_on_channel(
+
+ vif = cfg->p2p.bss_idx[P2PAPI_BSSCFG_DEVICE].vif;
+ if (vif == NULL) {
+- bphy_err(wiphy, "No p2p device available for probe response\n");
++ bphy_err(drvr, "No p2p device available for probe response\n");
+ err = -ENODEV;
+ goto exit;
+ }
+@@ -4982,6 +5021,7 @@ static int brcmf_cfg80211_get_channel(st
+ {
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct net_device *ndev = wdev->netdev;
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_if *ifp;
+ struct brcmu_chan ch;
+ enum nl80211_band band = 0;
+@@ -4995,7 +5035,7 @@ static int brcmf_cfg80211_get_channel(st
+
+ err = brcmf_fil_iovar_int_get(ifp, "chanspec", &chanspec);
+ if (err) {
+- bphy_err(wiphy, "chanspec failed (%d)\n", err);
++ bphy_err(drvr, "chanspec failed (%d)\n", err);
+ return err;
+ }
+
+@@ -5117,6 +5157,8 @@ static int brcmf_cfg80211_tdls_oper(stru
+ struct net_device *ndev, const u8 *peer,
+ enum nl80211_tdls_operation oper)
+ {
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_if *ifp;
+ struct brcmf_tdls_iovar_le info;
+ int ret = 0;
+@@ -5134,7 +5176,7 @@ static int brcmf_cfg80211_tdls_oper(stru
+ ret = brcmf_fil_iovar_data_set(ifp, "tdls_endpoint",
+ &info, sizeof(info));
+ if (ret < 0)
+- bphy_err(wiphy, "tdls_endpoint iovar failed: ret=%d\n", ret);
++ bphy_err(drvr, "tdls_endpoint iovar failed: ret=%d\n", ret);
+
+ return ret;
+ }
+@@ -5145,6 +5187,8 @@ brcmf_cfg80211_update_conn_params(struct
+ struct cfg80211_connect_params *sme,
+ u32 changed)
+ {
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_if *ifp;
+ int err;
+
+@@ -5155,7 +5199,7 @@ brcmf_cfg80211_update_conn_params(struct
+ err = brcmf_vif_set_mgmt_ie(ifp->vif, BRCMF_VNDR_IE_ASSOCREQ_FLAG,
+ sme->ie, sme->ie_len);
+ if (err)
+- bphy_err(wiphy, "Set Assoc REQ IE Failed\n");
++ bphy_err(drvr, "Set Assoc REQ IE Failed\n");
+ else
+ brcmf_dbg(TRACE, "Applied Vndr IEs for Assoc request\n");
+
+@@ -5167,6 +5211,8 @@ static int
+ brcmf_cfg80211_set_rekey_data(struct wiphy *wiphy, struct net_device *ndev,
+ struct cfg80211_gtk_rekey_data *gtk)
+ {
++ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_if *ifp = netdev_priv(ndev);
+ struct brcmf_gtk_keyinfo_le gtk_le;
+ int ret;
+@@ -5181,7 +5227,7 @@ brcmf_cfg80211_set_rekey_data(struct wip
+ ret = brcmf_fil_iovar_data_set(ifp, "gtk_key_info", &gtk_le,
+ sizeof(gtk_le));
+ if (ret < 0)
+- bphy_err(wiphy, "gtk_key_info iovar failed: ret=%d\n", ret);
++ bphy_err(drvr, "gtk_key_info iovar failed: ret=%d\n", ret);
+
+ return ret;
+ }
+@@ -5359,7 +5405,7 @@ static void brcmf_clear_assoc_ies(struct
+ static s32 brcmf_get_assoc_ies(struct brcmf_cfg80211_info *cfg,
+ struct brcmf_if *ifp)
+ {
+- struct wiphy *wiphy = cfg_to_wiphy(cfg);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_cfg80211_assoc_ielen_le *assoc_info;
+ struct brcmf_cfg80211_connect_info *conn_info = cfg_to_conn(cfg);
+ u32 req_len;
+@@ -5371,7 +5417,7 @@ static s32 brcmf_get_assoc_ies(struct br
+ err = brcmf_fil_iovar_data_get(ifp, "assoc_info",
+ cfg->extra_buf, WL_ASSOC_INFO_MAX);
+ if (err) {
+- bphy_err(wiphy, "could not get assoc info (%d)\n", err);
++ bphy_err(drvr, "could not get assoc info (%d)\n", err);
+ return err;
+ }
+ assoc_info =
+@@ -5383,7 +5429,7 @@ static s32 brcmf_get_assoc_ies(struct br
+ cfg->extra_buf,
+ WL_ASSOC_INFO_MAX);
+ if (err) {
+- bphy_err(wiphy, "could not get assoc req (%d)\n", err);
++ bphy_err(drvr, "could not get assoc req (%d)\n", err);
+ return err;
+ }
+ conn_info->req_ie_len = req_len;
+@@ -5399,7 +5445,7 @@ static s32 brcmf_get_assoc_ies(struct br
+ cfg->extra_buf,
+ WL_ASSOC_INFO_MAX);
+ if (err) {
+- bphy_err(wiphy, "could not get assoc resp (%d)\n", err);
++ bphy_err(drvr, "could not get assoc resp (%d)\n", err);
+ return err;
+ }
+ conn_info->resp_ie_len = resp_len;
+@@ -5518,7 +5564,7 @@ brcmf_notify_connect_status_ap(struct br
+ struct net_device *ndev,
+ const struct brcmf_event_msg *e, void *data)
+ {
+- struct wiphy *wiphy = cfg_to_wiphy(cfg);
++ struct brcmf_pub *drvr = cfg->pub;
+ static int generation;
+ u32 event = e->event_code;
+ u32 reason = e->reason;
+@@ -5537,7 +5583,7 @@ brcmf_notify_connect_status_ap(struct br
+ (reason == BRCMF_E_STATUS_SUCCESS)) {
+ memset(&sinfo, 0, sizeof(sinfo));
+ if (!data) {
+- bphy_err(wiphy, "No IEs present in ASSOC/REASSOC_IND\n");
++ bphy_err(drvr, "No IEs present in ASSOC/REASSOC_IND\n");
+ return -EINVAL;
+ }
+ sinfo.assoc_req_ies = data;
+@@ -5818,7 +5864,7 @@ static void init_vif_event(struct brcmf_
+
+ static s32 brcmf_dongle_roam(struct brcmf_if *ifp)
+ {
+- struct wiphy *wiphy = ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = ifp->drvr;
+ s32 err;
+ u32 bcn_timeout;
+ __le32 roamtrigger[2];
+@@ -5831,7 +5877,7 @@ static s32 brcmf_dongle_roam(struct brcm
+ bcn_timeout = BRCMF_DEFAULT_BCN_TIMEOUT_ROAM_ON;
+ err = brcmf_fil_iovar_int_set(ifp, "bcn_timeout", bcn_timeout);
+ if (err) {
+- bphy_err(wiphy, "bcn_timeout error (%d)\n", err);
++ bphy_err(drvr, "bcn_timeout error (%d)\n", err);
+ goto roam_setup_done;
+ }
+
+@@ -5843,7 +5889,7 @@ static s32 brcmf_dongle_roam(struct brcm
+ err = brcmf_fil_iovar_int_set(ifp, "roam_off",
+ ifp->drvr->settings->roamoff);
+ if (err) {
+- bphy_err(wiphy, "roam_off error (%d)\n", err);
++ bphy_err(drvr, "roam_off error (%d)\n", err);
+ goto roam_setup_done;
+ }
+
+@@ -5852,7 +5898,7 @@ static s32 brcmf_dongle_roam(struct brcm
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_ROAM_TRIGGER,
+ (void *)roamtrigger, sizeof(roamtrigger));
+ if (err) {
+- bphy_err(wiphy, "WLC_SET_ROAM_TRIGGER error (%d)\n", err);
++ bphy_err(drvr, "WLC_SET_ROAM_TRIGGER error (%d)\n", err);
+ goto roam_setup_done;
+ }
+
+@@ -5861,7 +5907,7 @@ static s32 brcmf_dongle_roam(struct brcm
+ err = brcmf_fil_cmd_data_set(ifp, BRCMF_C_SET_ROAM_DELTA,
+ (void *)roam_delta, sizeof(roam_delta));
+ if (err) {
+- bphy_err(wiphy, "WLC_SET_ROAM_DELTA error (%d)\n", err);
++ bphy_err(drvr, "WLC_SET_ROAM_DELTA error (%d)\n", err);
+ goto roam_setup_done;
+ }
+
+@@ -5872,26 +5918,26 @@ roam_setup_done:
+ static s32
+ brcmf_dongle_scantime(struct brcmf_if *ifp)
+ {
+- struct wiphy *wiphy = ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = ifp->drvr;
+ s32 err = 0;
+
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_CHANNEL_TIME,
+ BRCMF_SCAN_CHANNEL_TIME);
+ if (err) {
+- bphy_err(wiphy, "Scan assoc time error (%d)\n", err);
++ bphy_err(drvr, "Scan assoc time error (%d)\n", err);
+ goto dongle_scantime_out;
+ }
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_UNASSOC_TIME,
+ BRCMF_SCAN_UNASSOC_TIME);
+ if (err) {
+- bphy_err(wiphy, "Scan unassoc time error (%d)\n", err);
++ bphy_err(drvr, "Scan unassoc time error (%d)\n", err);
+ goto dongle_scantime_out;
+ }
+
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_PASSIVE_TIME,
+ BRCMF_SCAN_PASSIVE_TIME);
+ if (err) {
+- bphy_err(wiphy, "Scan passive time error (%d)\n", err);
++ bphy_err(drvr, "Scan passive time error (%d)\n", err);
+ goto dongle_scantime_out;
+ }
+
+@@ -5924,7 +5970,8 @@ static int brcmf_construct_chaninfo(stru
+ u32 bw_cap[])
+ {
+ struct wiphy *wiphy = cfg_to_wiphy(cfg);
+- struct brcmf_if *ifp = brcmf_get_ifp(cfg->pub, 0);
++ struct brcmf_pub *drvr = cfg->pub;
++ struct brcmf_if *ifp = brcmf_get_ifp(drvr, 0);
+ struct ieee80211_supported_band *band;
+ struct ieee80211_channel *channel;
+ struct brcmf_chanspec_list *list;
+@@ -5945,7 +5992,7 @@ static int brcmf_construct_chaninfo(stru
+ err = brcmf_fil_iovar_data_get(ifp, "chanspecs", pbuf,
+ BRCMF_DCMD_MEDLEN);
+ if (err) {
+- bphy_err(wiphy, "get chanspecs error (%d)\n", err);
++ bphy_err(drvr, "get chanspecs error (%d)\n", err);
+ goto fail_pbuf;
+ }
+
+@@ -5968,7 +6015,7 @@ static int brcmf_construct_chaninfo(stru
+ } else if (ch.band == BRCMU_CHAN_BAND_5G) {
+ band = wiphy->bands[NL80211_BAND_5GHZ];
+ } else {
+- bphy_err(wiphy, "Invalid channel Spec. 0x%x.\n",
++ bphy_err(drvr, "Invalid channel Spec. 0x%x.\n",
+ ch.chspec);
+ continue;
+ }
+@@ -5992,7 +6039,7 @@ static int brcmf_construct_chaninfo(stru
+ /* It seems firmware supports some channel we never
+ * considered. Something new in IEEE standard?
+ */
+- bphy_err(wiphy, "Ignoring unexpected firmware channel %d\n",
++ bphy_err(drvr, "Ignoring unexpected firmware channel %d\n",
+ ch.control_ch_num);
+ continue;
+ }
+@@ -6049,8 +6096,8 @@ fail_pbuf:
+
+ static int brcmf_enable_bw40_2g(struct brcmf_cfg80211_info *cfg)
+ {
+- struct wiphy *wiphy = cfg_to_wiphy(cfg);
+- struct brcmf_if *ifp = brcmf_get_ifp(cfg->pub, 0);
++ struct brcmf_pub *drvr = cfg->pub;
++ struct brcmf_if *ifp = brcmf_get_ifp(drvr, 0);
+ struct ieee80211_supported_band *band;
+ struct brcmf_fil_bwcap_le band_bwcap;
+ struct brcmf_chanspec_list *list;
+@@ -6096,7 +6143,7 @@ static int brcmf_enable_bw40_2g(struct b
+ err = brcmf_fil_iovar_data_get(ifp, "chanspecs", pbuf,
+ BRCMF_DCMD_MEDLEN);
+ if (err) {
+- bphy_err(wiphy, "get chanspecs error (%d)\n", err);
++ bphy_err(drvr, "get chanspecs error (%d)\n", err);
+ kfree(pbuf);
+ return err;
+ }
+@@ -6127,7 +6174,7 @@ static int brcmf_enable_bw40_2g(struct b
+
+ static void brcmf_get_bwcap(struct brcmf_if *ifp, u32 bw_cap[])
+ {
+- struct wiphy *wiphy = ifp->drvr->wiphy;
++ struct brcmf_pub *drvr = ifp->drvr;
+ u32 band, mimo_bwcap;
+ int err;
+
+@@ -6163,7 +6210,7 @@ static void brcmf_get_bwcap(struct brcmf
+ bw_cap[NL80211_BAND_5GHZ] |= WLC_BW_20MHZ_BIT;
+ break;
+ default:
+- bphy_err(wiphy, "invalid mimo_bw_cap value\n");
++ bphy_err(drvr, "invalid mimo_bw_cap value\n");
+ }
+ }
+
+@@ -6238,7 +6285,8 @@ static void brcmf_update_vht_cap(struct
+
+ static int brcmf_setup_wiphybands(struct brcmf_cfg80211_info *cfg)
+ {
+- struct brcmf_if *ifp = brcmf_get_ifp(cfg->pub, 0);
++ struct brcmf_pub *drvr = cfg->pub;
++ struct brcmf_if *ifp = brcmf_get_ifp(drvr, 0);
+ struct wiphy *wiphy = cfg_to_wiphy(cfg);
+ u32 nmode = 0;
+ u32 vhtmode = 0;
+@@ -6255,7 +6303,7 @@ static int brcmf_setup_wiphybands(struct
+ (void)brcmf_fil_iovar_int_get(ifp, "vhtmode", &vhtmode);
+ err = brcmf_fil_iovar_int_get(ifp, "nmode", &nmode);
+ if (err) {
+- bphy_err(wiphy, "nmode error (%d)\n", err);
++ bphy_err(drvr, "nmode error (%d)\n", err);
+ } else {
+ brcmf_get_bwcap(ifp, bw_cap);
+ }
+@@ -6265,7 +6313,7 @@ static int brcmf_setup_wiphybands(struct
+
+ err = brcmf_fil_iovar_int_get(ifp, "rxchain", &rxchain);
+ if (err) {
+- bphy_err(wiphy, "rxchain error (%d)\n", err);
++ bphy_err(drvr, "rxchain error (%d)\n", err);
+ nchain = 1;
+ } else {
+ for (nchain = 0; rxchain; nchain++)
+@@ -6275,7 +6323,7 @@ static int brcmf_setup_wiphybands(struct
+
+ err = brcmf_construct_chaninfo(cfg, bw_cap);
+ if (err) {
+- bphy_err(wiphy, "brcmf_construct_chaninfo failed (%d)\n", err);
++ bphy_err(drvr, "brcmf_construct_chaninfo failed (%d)\n", err);
+ return err;
+ }
+
+@@ -6492,12 +6540,13 @@ static void brcmf_wiphy_wowl_params(stru
+ {
+ #ifdef CONFIG_PM
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct wiphy_wowlan_support *wowl;
+
+ wowl = kmemdup(&brcmf_wowlan_support, sizeof(brcmf_wowlan_support),
+ GFP_KERNEL);
+ if (!wowl) {
+- bphy_err(wiphy, "only support basic wowlan features\n");
++ bphy_err(drvr, "only support basic wowlan features\n");
+ wiphy->wowlan = &brcmf_wowlan_support;
+ return;
+ }
+@@ -6585,7 +6634,7 @@ static int brcmf_setup_wiphy(struct wiph
+ err = brcmf_fil_cmd_data_get(ifp, BRCMF_C_GET_BANDLIST, &bandlist,
+ sizeof(bandlist));
+ if (err) {
+- bphy_err(wiphy, "could not obtain band info: err=%d\n", err);
++ bphy_err(drvr, "could not obtain band info: err=%d\n", err);
+ return err;
+ }
+ /* first entry in bandlist is number of bands */
+@@ -6846,6 +6895,7 @@ static void brcmf_cfg80211_reg_notifier(
+ {
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_if *ifp = brcmf_get_ifp(cfg->pub, 0);
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_fil_country_le ccreq;
+ s32 err;
+ int i;
+@@ -6857,7 +6907,7 @@ static void brcmf_cfg80211_reg_notifier(
+ /* ignore non-ISO3166 country codes */
+ for (i = 0; i < 2; i++)
+ if (req->alpha2[i] < 'A' || req->alpha2[i] > 'Z') {
+- bphy_err(wiphy, "not a ISO3166 code (0x%02x 0x%02x)\n",
++ bphy_err(drvr, "not a ISO3166 code (0x%02x 0x%02x)\n",
+ req->alpha2[0], req->alpha2[1]);
+ return;
+ }
+@@ -6867,7 +6917,7 @@ static void brcmf_cfg80211_reg_notifier(
+
+ err = brcmf_fil_iovar_data_get(ifp, "country", &ccreq, sizeof(ccreq));
+ if (err) {
+- bphy_err(wiphy, "Country code iovar returned err = %d\n", err);
++ bphy_err(drvr, "Country code iovar returned err = %d\n", err);
+ return;
+ }
+
+@@ -6877,7 +6927,7 @@ static void brcmf_cfg80211_reg_notifier(
+
+ err = brcmf_fil_iovar_data_set(ifp, "country", &ccreq, sizeof(ccreq));
+ if (err) {
+- bphy_err(wiphy, "Firmware rejected country setting\n");
++ bphy_err(drvr, "Firmware rejected country setting\n");
+ return;
+ }
+ brcmf_setup_wiphybands(cfg);
+@@ -6923,13 +6973,13 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+ u16 *cap = NULL;
+
+ if (!ndev) {
+- bphy_err(wiphy, "ndev is invalid\n");
++ bphy_err(drvr, "ndev is invalid\n");
+ return NULL;
+ }
+
+ cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
+ if (!cfg) {
+- bphy_err(wiphy, "Could not allocate wiphy device\n");
++ bphy_err(drvr, "Could not allocate wiphy device\n");
+ return NULL;
+ }
+
+@@ -6950,7 +7000,7 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+
+ err = wl_init_priv(cfg);
+ if (err) {
+- bphy_err(wiphy, "Failed to init iwm_priv (%d)\n", err);
++ bphy_err(drvr, "Failed to init iwm_priv (%d)\n", err);
+ brcmf_free_vif(vif);
+ goto wiphy_out;
+ }
+@@ -6959,7 +7009,7 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+ /* determine d11 io type before wiphy setup */
+ err = brcmf_fil_cmd_int_get(ifp, BRCMF_C_GET_VERSION, &io_type);
+ if (err) {
+- bphy_err(wiphy, "Failed to get D11 version (%d)\n", err);
++ bphy_err(drvr, "Failed to get D11 version (%d)\n", err);
+ goto priv_out;
+ }
+ cfg->d11inf.io_type = (u8)io_type;
+@@ -6993,13 +7043,13 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+ #endif
+ err = wiphy_register(wiphy);
+ if (err < 0) {
+- bphy_err(wiphy, "Could not register wiphy device (%d)\n", err);
++ bphy_err(drvr, "Could not register wiphy device (%d)\n", err);
+ goto priv_out;
+ }
+
+ err = brcmf_setup_wiphybands(cfg);
+ if (err) {
+- bphy_err(wiphy, "Setting wiphy bands failed (%d)\n", err);
++ bphy_err(drvr, "Setting wiphy bands failed (%d)\n", err);
+ goto wiphy_unreg_out;
+ }
+
+@@ -7017,18 +7067,18 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+
+ err = brcmf_fweh_activate_events(ifp);
+ if (err) {
+- bphy_err(wiphy, "FWEH activation failed (%d)\n", err);
++ bphy_err(drvr, "FWEH activation failed (%d)\n", err);
+ goto wiphy_unreg_out;
+ }
+
+ err = brcmf_p2p_attach(cfg, p2pdev_forced);
+ if (err) {
+- bphy_err(wiphy, "P2P initialisation failed (%d)\n", err);
++ bphy_err(drvr, "P2P initialisation failed (%d)\n", err);
+ goto wiphy_unreg_out;
+ }
+ err = brcmf_btcoex_attach(cfg);
+ if (err) {
+- bphy_err(wiphy, "BT-coex initialisation failed (%d)\n", err);
++ bphy_err(drvr, "BT-coex initialisation failed (%d)\n", err);
+ brcmf_p2p_detach(&cfg->p2p);
+ goto wiphy_unreg_out;
+ }
+@@ -7047,7 +7097,7 @@ struct brcmf_cfg80211_info *brcmf_cfg802
+ /* (re-) activate FWEH event handling */
+ err = brcmf_fweh_activate_events(ifp);
+ if (err) {
+- bphy_err(wiphy, "FWEH activation failed (%d)\n", err);
++ bphy_err(drvr, "FWEH activation failed (%d)\n", err);
+ goto detach;
+ }
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
+@@ -62,12 +62,12 @@ void __brcmf_err(struct brcmf_bus *bus,
+ } while (0)
+ #endif
+
+-#define bphy_err(wiphy, fmt, ...) \
++#define bphy_err(drvr, fmt, ...) \
+ do { \
+ if (IS_ENABLED(CPTCFG_BRCMDBG) || \
+ IS_ENABLED(CPTCFG_BRCM_TRACING) || \
+ net_ratelimit()) \
+- wiphy_err(wiphy, "%s: " fmt, __func__, \
++ wiphy_err((drvr)->wiphy, "%s: " fmt, __func__, \
+ ##__VA_ARGS__); \
+ } while (0)
+
diff --git a/package/kernel/mac80211/patches/339-v5.1-0009-brcmfmac-use-bphy_err-in-all-wiphy-related-code.patch b/package/kernel/mac80211/patches/339-v5.1-0009-brcmfmac-use-bphy_err-in-all-wiphy-related-code.patch
new file mode 100644
index 0000000000..066ad99e91
--- /dev/null
+++ b/package/kernel/mac80211/patches/339-v5.1-0009-brcmfmac-use-bphy_err-in-all-wiphy-related-code.patch
@@ -0,0 +1,1584 @@
+From dcb1471bc6d0541d636c7ecd9239573304842884 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Tue, 19 Feb 2019 23:42:19 +0100
+Subject: [PATCH] brcmfmac: use bphy_err() in all wiphy-related code
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+This recently added macro provides more meaningful error messages thanks
+to identifying a specific wiphy. It's especially important on systems
+with few cards supported by the same (brcmfmac) driver.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ .../broadcom/brcm80211/brcmfmac/bcdc.c | 22 ++---
+ .../broadcom/brcm80211/brcmfmac/common.c | 39 ++++----
+ .../broadcom/brcm80211/brcmfmac/core.c | 74 ++++++++--------
+ .../broadcom/brcm80211/brcmfmac/feature.c | 8 +-
+ .../broadcom/brcm80211/brcmfmac/fweh.c | 25 +++---
+ .../broadcom/brcm80211/brcmfmac/fwil.c | 10 +--
+ .../broadcom/brcm80211/brcmfmac/fwsignal.c | 38 ++++----
+ .../broadcom/brcm80211/brcmfmac/msgbuf.c | 65 ++++++++------
+ .../broadcom/brcm80211/brcmfmac/p2p.c | 88 +++++++++++--------
+ .../broadcom/brcm80211/brcmfmac/pno.c | 22 +++--
+ .../broadcom/brcm80211/brcmfmac/proto.c | 6 +-
+ 11 files changed, 224 insertions(+), 173 deletions(-)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/bcdc.c
+@@ -169,8 +169,8 @@ brcmf_proto_bcdc_query_dcmd(struct brcmf
+
+ ret = brcmf_proto_bcdc_msg(drvr, ifidx, cmd, buf, len, false);
+ if (ret < 0) {
+- brcmf_err("brcmf_proto_bcdc_msg failed w/status %d\n",
+- ret);
++ bphy_err(drvr, "brcmf_proto_bcdc_msg failed w/status %d\n",
++ ret);
+ goto done;
+ }
+
+@@ -186,9 +186,9 @@ retry:
+ if ((id < bcdc->reqid) && (++retries < RETRIES))
+ goto retry;
+ if (id != bcdc->reqid) {
+- brcmf_err("%s: unexpected request id %d (expected %d)\n",
+- brcmf_ifname(brcmf_get_ifp(drvr, ifidx)), id,
+- bcdc->reqid);
++ bphy_err(drvr, "%s: unexpected request id %d (expected %d)\n",
++ brcmf_ifname(brcmf_get_ifp(drvr, ifidx)), id,
++ bcdc->reqid);
+ ret = -EINVAL;
+ goto done;
+ }
+@@ -234,9 +234,9 @@ brcmf_proto_bcdc_set_dcmd(struct brcmf_p
+ id = (flags & BCDC_DCMD_ID_MASK) >> BCDC_DCMD_ID_SHIFT;
+
+ if (id != bcdc->reqid) {
+- brcmf_err("%s: unexpected request id %d (expected %d)\n",
+- brcmf_ifname(brcmf_get_ifp(drvr, ifidx)), id,
+- bcdc->reqid);
++ bphy_err(drvr, "%s: unexpected request id %d (expected %d)\n",
++ brcmf_ifname(brcmf_get_ifp(drvr, ifidx)), id,
++ bcdc->reqid);
+ ret = -EINVAL;
+ goto done;
+ }
+@@ -299,8 +299,8 @@ brcmf_proto_bcdc_hdrpull(struct brcmf_pu
+ }
+ if (((h->flags & BCDC_FLAG_VER_MASK) >> BCDC_FLAG_VER_SHIFT) !=
+ BCDC_PROTO_VER) {
+- brcmf_err("%s: non-BCDC packet received, flags 0x%x\n",
+- brcmf_ifname(tmp_if), h->flags);
++ bphy_err(drvr, "%s: non-BCDC packet received, flags 0x%x\n",
++ brcmf_ifname(tmp_if), h->flags);
+ return -EBADE;
+ }
+
+@@ -379,7 +379,7 @@ int brcmf_proto_bcdc_attach(struct brcmf
+
+ /* ensure that the msg buf directly follows the cdc msg struct */
+ if ((unsigned long)(&bcdc->msg + 1) != (unsigned long)bcdc->buf) {
+- brcmf_err("struct brcmf_proto_bcdc is not correctly defined\n");
++ bphy_err(drvr, "struct brcmf_proto_bcdc is not correctly defined\n");
+ goto fail;
+ }
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+@@ -89,6 +89,7 @@ struct brcmf_mp_global_t brcmf_mp_global
+
+ void brcmf_c_set_joinpref_default(struct brcmf_if *ifp)
+ {
++ struct brcmf_pub *drvr = ifp->drvr;
+ struct brcmf_join_pref_params join_pref_params[2];
+ int err;
+
+@@ -105,11 +106,12 @@ void brcmf_c_set_joinpref_default(struct
+ err = brcmf_fil_iovar_data_set(ifp, "join_pref", join_pref_params,
+ sizeof(join_pref_params));
+ if (err)
+- brcmf_err("Set join_pref error (%d)\n", err);
++ bphy_err(drvr, "Set join_pref error (%d)\n", err);
+ }
+
+ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
+ {
++ struct brcmf_pub *drvr = ifp->drvr;
+ s8 eventmask[BRCMF_EVENTING_MASK_LEN];
+ u8 buf[BRCMF_DCMD_SMLEN];
+ struct brcmf_rev_info_le revinfo;
+@@ -121,7 +123,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
+ err = brcmf_fil_iovar_data_get(ifp, "cur_etheraddr", ifp->mac_addr,
+ sizeof(ifp->mac_addr));
+ if (err < 0) {
+- brcmf_err("Retrieving cur_etheraddr failed, %d\n", err);
++ bphy_err(drvr, "Retrieving cur_etheraddr failed, %d\n", err);
+ goto done;
+ }
+ memcpy(ifp->drvr->wiphy->perm_addr, ifp->drvr->mac, ETH_ALEN);
+@@ -131,7 +133,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
+ &revinfo, sizeof(revinfo));
+ ri = &ifp->drvr->revinfo;
+ if (err < 0) {
+- brcmf_err("retrieving revision info failed, %d\n", err);
++ bphy_err(drvr, "retrieving revision info failed, %d\n", err);
+ } else {
+ ri->vendorid = le32_to_cpu(revinfo.vendorid);
+ ri->deviceid = le32_to_cpu(revinfo.deviceid);
+@@ -158,8 +160,8 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
+ strcpy(buf, "ver");
+ err = brcmf_fil_iovar_data_get(ifp, "ver", buf, sizeof(buf));
+ if (err < 0) {
+- brcmf_err("Retrieving version information failed, %d\n",
+- err);
++ bphy_err(drvr, "Retrieving version information failed, %d\n",
++ err);
+ goto done;
+ }
+ ptr = (char *)buf;
+@@ -175,7 +177,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
+ /* set mpc */
+ err = brcmf_fil_iovar_int_set(ifp, "mpc", 1);
+ if (err) {
+- brcmf_err("failed setting mpc\n");
++ bphy_err(drvr, "failed setting mpc\n");
+ goto done;
+ }
+
+@@ -185,14 +187,14 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
+ err = brcmf_fil_iovar_data_get(ifp, "event_msgs", eventmask,
+ BRCMF_EVENTING_MASK_LEN);
+ if (err) {
+- brcmf_err("Get event_msgs error (%d)\n", err);
++ bphy_err(drvr, "Get event_msgs error (%d)\n", err);
+ goto done;
+ }
+ setbit(eventmask, BRCMF_E_IF);
+ err = brcmf_fil_iovar_data_set(ifp, "event_msgs", eventmask,
+ BRCMF_EVENTING_MASK_LEN);
+ if (err) {
+- brcmf_err("Set event_msgs error (%d)\n", err);
++ bphy_err(drvr, "Set event_msgs error (%d)\n", err);
+ goto done;
+ }
+
+@@ -200,8 +202,8 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_CHANNEL_TIME,
+ BRCMF_DEFAULT_SCAN_CHANNEL_TIME);
+ if (err) {
+- brcmf_err("BRCMF_C_SET_SCAN_CHANNEL_TIME error (%d)\n",
+- err);
++ bphy_err(drvr, "BRCMF_C_SET_SCAN_CHANNEL_TIME error (%d)\n",
++ err);
+ goto done;
+ }
+
+@@ -209,8 +211,8 @@ int brcmf_c_preinit_dcmds(struct brcmf_i
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_SCAN_UNASSOC_TIME,
+ BRCMF_DEFAULT_SCAN_UNASSOC_TIME);
+ if (err) {
+- brcmf_err("BRCMF_C_SET_SCAN_UNASSOC_TIME error (%d)\n",
+- err);
++ bphy_err(drvr, "BRCMF_C_SET_SCAN_UNASSOC_TIME error (%d)\n",
++ err);
+ goto done;
+ }
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+@@ -90,7 +90,7 @@ struct brcmf_if *brcmf_get_ifp(struct br
+ s32 bsscfgidx;
+
+ if (ifidx < 0 || ifidx >= BRCMF_MAX_IFS) {
+- brcmf_err("ifidx %d out of range\n", ifidx);
++ bphy_err(drvr, "ifidx %d out of range\n", ifidx);
+ return NULL;
+ }
+
+@@ -104,7 +104,9 @@ struct brcmf_if *brcmf_get_ifp(struct br
+
+ static void _brcmf_set_multicast_list(struct work_struct *work)
+ {
+- struct brcmf_if *ifp;
++ struct brcmf_if *ifp = container_of(work, struct brcmf_if,
++ multicast_work);
++ struct brcmf_pub *drvr = ifp->drvr;
+ struct net_device *ndev;
+ struct netdev_hw_addr *ha;
+ u32 cmd_value, cnt;
+@@ -113,8 +115,6 @@ static void _brcmf_set_multicast_list(st
+ u32 buflen;
+ s32 err;
+
+- ifp = container_of(work, struct brcmf_if, multicast_work);
+-
+ brcmf_dbg(TRACE, "Enter, bsscfgidx=%d\n", ifp->bsscfgidx);
+
+ ndev = ifp->ndev;
+@@ -144,7 +144,7 @@ static void _brcmf_set_multicast_list(st
+
+ err = brcmf_fil_iovar_data_set(ifp, "mcast_list", buf, buflen);
+ if (err < 0) {
+- brcmf_err("Setting mcast_list failed, %d\n", err);
++ bphy_err(drvr, "Setting mcast_list failed, %d\n", err);
+ cmd_value = cnt ? true : cmd_value;
+ }
+
+@@ -157,24 +157,24 @@ static void _brcmf_set_multicast_list(st
+ */
+ err = brcmf_fil_iovar_int_set(ifp, "allmulti", cmd_value);
+ if (err < 0)
+- brcmf_err("Setting allmulti failed, %d\n", err);
++ bphy_err(drvr, "Setting allmulti failed, %d\n", err);
+
+ /*Finally, pick up the PROMISC flag */
+ cmd_value = (ndev->flags & IFF_PROMISC) ? true : false;
+ err = brcmf_fil_cmd_int_set(ifp, BRCMF_C_SET_PROMISC, cmd_value);
+ if (err < 0)
+- brcmf_err("Setting BRCMF_C_SET_PROMISC failed, %d\n",
+- err);
++ bphy_err(drvr, "Setting BRCMF_C_SET_PROMISC failed, %d\n",
++ err);
+ }
+
+ #if IS_ENABLED(CONFIG_IPV6)
+ static void _brcmf_update_ndtable(struct work_struct *work)
+ {
+- struct brcmf_if *ifp;
++ struct brcmf_if *ifp = container_of(work, struct brcmf_if,
++ ndoffload_work);
++ struct brcmf_pub *drvr = ifp->drvr;
+ int i, ret;
+
+- ifp = container_of(work, struct brcmf_if, ndoffload_work);
+-
+ /* clear the table in firmware */
+ ret = brcmf_fil_iovar_data_set(ifp, "nd_hostip_clear", NULL, 0);
+ if (ret) {
+@@ -187,7 +187,7 @@ static void _brcmf_update_ndtable(struct
+ &ifp->ipv6_addr_tbl[i],
+ sizeof(struct in6_addr));
+ if (ret)
+- brcmf_err("add nd ip err %d\n", ret);
++ bphy_err(drvr, "add nd ip err %d\n", ret);
+ }
+ }
+ #else
+@@ -200,6 +200,7 @@ static int brcmf_netdev_set_mac_address(
+ {
+ struct brcmf_if *ifp = netdev_priv(ndev);
+ struct sockaddr *sa = (struct sockaddr *)addr;
++ struct brcmf_pub *drvr = ifp->drvr;
+ int err;
+
+ brcmf_dbg(TRACE, "Enter, bsscfgidx=%d\n", ifp->bsscfgidx);
+@@ -207,7 +208,7 @@ static int brcmf_netdev_set_mac_address(
+ err = brcmf_fil_iovar_data_set(ifp, "cur_etheraddr", sa->sa_data,
+ ETH_ALEN);
+ if (err < 0) {
+- brcmf_err("Setting cur_etheraddr failed, %d\n", err);
++ bphy_err(drvr, "Setting cur_etheraddr failed, %d\n", err);
+ } else {
+ brcmf_dbg(TRACE, "updated to %pM\n", sa->sa_data);
+ memcpy(ifp->mac_addr, sa->sa_data, ETH_ALEN);
+@@ -266,7 +267,7 @@ static netdev_tx_t brcmf_netdev_start_xm
+
+ /* Can the device send data? */
+ if (drvr->bus_if->state != BRCMF_BUS_UP) {
+- brcmf_err("xmit rejected state=%d\n", drvr->bus_if->state);
++ bphy_err(drvr, "xmit rejected state=%d\n", drvr->bus_if->state);
+ netif_stop_queue(ndev);
+ dev_kfree_skb(skb);
+ ret = -ENODEV;
+@@ -604,7 +605,7 @@ static int brcmf_netdev_open(struct net_
+
+ /* If bus is not ready, can't continue */
+ if (bus_if->state != BRCMF_BUS_UP) {
+- brcmf_err("failed bus is not ready\n");
++ bphy_err(drvr, "failed bus is not ready\n");
+ return -EAGAIN;
+ }
+
+@@ -618,7 +619,7 @@ static int brcmf_netdev_open(struct net_
+ ndev->features &= ~NETIF_F_IP_CSUM;
+
+ if (brcmf_cfg80211_up(ndev)) {
+- brcmf_err("failed to bring up cfg80211\n");
++ bphy_err(drvr, "failed to bring up cfg80211\n");
+ return -EIO;
+ }
+
+@@ -663,7 +664,7 @@ int brcmf_net_attach(struct brcmf_if *if
+ else
+ err = register_netdev(ndev);
+ if (err != 0) {
+- brcmf_err("couldn't register the net device\n");
++ bphy_err(drvr, "couldn't register the net device\n");
+ goto fail;
+ }
+
+@@ -739,6 +740,7 @@ static const struct net_device_ops brcmf
+
+ static int brcmf_net_p2p_attach(struct brcmf_if *ifp)
+ {
++ struct brcmf_pub *drvr = ifp->drvr;
+ struct net_device *ndev;
+
+ brcmf_dbg(TRACE, "Enter, bsscfgidx=%d mac=%pM\n", ifp->bsscfgidx,
+@@ -751,7 +753,7 @@ static int brcmf_net_p2p_attach(struct b
+ memcpy(ndev->dev_addr, ifp->mac_addr, ETH_ALEN);
+
+ if (register_netdev(ndev) != 0) {
+- brcmf_err("couldn't register the p2p net device\n");
++ bphy_err(drvr, "couldn't register the p2p net device\n");
+ goto fail;
+ }
+
+@@ -781,8 +783,8 @@ struct brcmf_if *brcmf_add_if(struct brc
+ */
+ if (ifp) {
+ if (ifidx) {
+- brcmf_err("ERROR: netdev:%s already exists\n",
+- ifp->ndev->name);
++ bphy_err(drvr, "ERROR: netdev:%s already exists\n",
++ ifp->ndev->name);
+ netif_stop_queue(ifp->ndev);
+ brcmf_net_detach(ifp->ndev, false);
+ drvr->iflist[bsscfgidx] = NULL;
+@@ -840,7 +842,7 @@ static void brcmf_del_if(struct brcmf_pu
+ ifp = drvr->iflist[bsscfgidx];
+ drvr->iflist[bsscfgidx] = NULL;
+ if (!ifp) {
+- brcmf_err("Null interface, bsscfgidx=%d\n", bsscfgidx);
++ bphy_err(drvr, "Null interface, bsscfgidx=%d\n", bsscfgidx);
+ return;
+ }
+ brcmf_dbg(TRACE, "Enter, bsscfgidx=%d, ifidx=%d\n", bsscfgidx,
+@@ -890,16 +892,17 @@ static int brcmf_psm_watchdog_notify(str
+ const struct brcmf_event_msg *evtmsg,
+ void *data)
+ {
++ struct brcmf_pub *drvr = ifp->drvr;
+ int err;
+
+ brcmf_dbg(TRACE, "enter: bsscfgidx=%d\n", ifp->bsscfgidx);
+
+- brcmf_err("PSM's watchdog has fired!\n");
++ bphy_err(drvr, "PSM's watchdog has fired!\n");
+
+ err = brcmf_debug_create_memdump(ifp->drvr->bus_if, data,
+ evtmsg->datalen);
+ if (err)
+- brcmf_err("Failed to get memory dump, %d\n", err);
++ bphy_err(drvr, "Failed to get memory dump, %d\n", err);
+
+ return err;
+ }
+@@ -943,7 +946,7 @@ static int brcmf_inetaddr_changed(struct
+ ret = brcmf_fil_iovar_data_get(ifp, "arp_hostip", addr_table,
+ sizeof(addr_table));
+ if (ret) {
+- brcmf_err("fail to get arp ip table err:%d\n", ret);
++ bphy_err(drvr, "fail to get arp ip table err:%d\n", ret);
+ return NOTIFY_OK;
+ }
+
+@@ -960,7 +963,7 @@ static int brcmf_inetaddr_changed(struct
+ ret = brcmf_fil_iovar_data_set(ifp, "arp_hostip",
+ &ifa->ifa_address, sizeof(ifa->ifa_address));
+ if (ret)
+- brcmf_err("add arp ip err %d\n", ret);
++ bphy_err(drvr, "add arp ip err %d\n", ret);
+ }
+ break;
+ case NETDEV_DOWN:
+@@ -972,8 +975,8 @@ static int brcmf_inetaddr_changed(struct
+ ret = brcmf_fil_iovar_data_set(ifp, "arp_hostip_clear",
+ NULL, 0);
+ if (ret) {
+- brcmf_err("fail to clear arp ip table err:%d\n",
+- ret);
++ bphy_err(drvr, "fail to clear arp ip table err:%d\n",
++ ret);
+ return NOTIFY_OK;
+ }
+ for (i = 0; i < ARPOL_MAX_ENTRIES; i++) {
+@@ -983,8 +986,8 @@ static int brcmf_inetaddr_changed(struct
+ &addr_table[i],
+ sizeof(addr_table[i]));
+ if (ret)
+- brcmf_err("add arp ip err %d\n",
+- ret);
++ bphy_err(drvr, "add arp ip err %d\n",
++ ret);
+ }
+ }
+ break;
+@@ -1161,7 +1164,7 @@ int brcmf_bus_started(struct device *dev
+ return 0;
+
+ fail:
+- brcmf_err("failed: %d\n", ret);
++ bphy_err(drvr, "failed: %d\n", ret);
+ if (drvr->config) {
+ brcmf_cfg80211_detach(drvr->config);
+ drvr->config = NULL;
+@@ -1220,7 +1223,7 @@ int brcmf_attach(struct device *dev, str
+ /* Attach and link in the protocol */
+ ret = brcmf_proto_attach(drvr);
+ if (ret != 0) {
+- brcmf_err("brcmf_prot_attach failed\n");
++ bphy_err(drvr, "brcmf_prot_attach failed\n");
+ goto fail;
+ }
+
+@@ -1330,6 +1333,7 @@ static int brcmf_get_pend_8021x_cnt(stru
+
+ int brcmf_netdev_wait_pend8021x(struct brcmf_if *ifp)
+ {
++ struct brcmf_pub *drvr = ifp->drvr;
+ int err;
+
+ err = wait_event_timeout(ifp->pend_8021x_wait,
+@@ -1337,7 +1341,7 @@ int brcmf_netdev_wait_pend8021x(struct b
+ MAX_WAIT_FOR_8021X_TX);
+
+ if (!err)
+- brcmf_err("Timed out waiting for no pending 802.1x packets\n");
++ bphy_err(drvr, "Timed out waiting for no pending 802.1x packets\n");
+
+ return !err;
+ }
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/feature.c
+@@ -158,13 +158,14 @@ static void brcmf_feat_iovar_int_get(str
+ #define MAX_CAPS_BUFFER_SIZE 768
+ static void brcmf_feat_firmware_capabilities(struct brcmf_if *ifp)
+ {
++ struct brcmf_pub *drvr = ifp->drvr;
+ char caps[MAX_CAPS_BUFFER_SIZE];
+ enum brcmf_feat_id id;
+ int i, err;
+
+ err = brcmf_fil_iovar_data_get(ifp, "cap", caps, sizeof(caps));
+ if (err) {
+- brcmf_err("could not get firmware cap (%d)\n", err);
++ bphy_err(drvr, "could not get firmware cap (%d)\n", err);
+ return;
+ }
+
+@@ -189,14 +190,15 @@ static void brcmf_feat_firmware_capabili
+ static int brcmf_feat_fwcap_debugfs_read(struct seq_file *seq, void *data)
+ {
+ struct brcmf_bus *bus_if = dev_get_drvdata(seq->private);
+- struct brcmf_if *ifp = brcmf_get_ifp(bus_if->drvr, 0);
++ struct brcmf_pub *drvr = bus_if->drvr;
++ struct brcmf_if *ifp = brcmf_get_ifp(drvr, 0);
+ char caps[MAX_CAPS_BUFFER_SIZE + 1] = { };
+ char *tmp;
+ int err;
+
+ err = brcmf_fil_iovar_data_get(ifp, "cap", caps, sizeof(caps));
+ if (err) {
+- brcmf_err("could not get firmware cap (%d)\n", err);
++ bphy_err(drvr, "could not get firmware cap (%d)\n", err);
+ return err;
+ }
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
+@@ -102,7 +102,8 @@ static void brcmf_fweh_queue_event(struc
+ schedule_work(&fweh->event_work);
+ }
+
+-static int brcmf_fweh_call_event_handler(struct brcmf_if *ifp,
++static int brcmf_fweh_call_event_handler(struct brcmf_pub *drvr,
++ struct brcmf_if *ifp,
+ enum brcmf_fweh_event_code code,
+ struct brcmf_event_msg *emsg,
+ void *data)
+@@ -117,9 +118,9 @@ static int brcmf_fweh_call_event_handler
+ if (fweh->evt_handler[code])
+ err = fweh->evt_handler[code](ifp, emsg, data);
+ else
+- brcmf_err("unhandled event %d ignored\n", code);
++ bphy_err(drvr, "unhandled event %d ignored\n", code);
+ } else {
+- brcmf_err("no interface object\n");
++ bphy_err(drvr, "no interface object\n");
+ }
+ return err;
+ }
+@@ -158,7 +159,7 @@ static void brcmf_fweh_handle_if_event(s
+ return;
+ }
+ if (ifevent->ifidx >= BRCMF_MAX_IFS) {
+- brcmf_err("invalid interface index: %u\n", ifevent->ifidx);
++ bphy_err(drvr, "invalid interface index: %u\n", ifevent->ifidx);
+ return;
+ }
+
+@@ -181,7 +182,8 @@ static void brcmf_fweh_handle_if_event(s
+ if (ifp && ifevent->action == BRCMF_E_IF_CHANGE)
+ brcmf_fws_reset_interface(ifp);
+
+- err = brcmf_fweh_call_event_handler(ifp, emsg->event_code, emsg, data);
++ err = brcmf_fweh_call_event_handler(drvr, ifp, emsg->event_code, emsg,
++ data);
+
+ if (ifp && ifevent->action == BRCMF_E_IF_DEL) {
+ bool armed = brcmf_cfg80211_vif_event_armed(drvr->config);
+@@ -273,11 +275,11 @@ static void brcmf_fweh_event_worker(stru
+ ifp = drvr->iflist[0];
+ else
+ ifp = drvr->iflist[emsg.bsscfgidx];
+- err = brcmf_fweh_call_event_handler(ifp, event->code, &emsg,
+- event->data);
++ err = brcmf_fweh_call_event_handler(drvr, ifp, event->code,
++ &emsg, event->data);
+ if (err) {
+- brcmf_err("event handler failed (%d)\n",
+- event->code);
++ bphy_err(drvr, "event handler failed (%d)\n",
++ event->code);
+ err = 0;
+ }
+ event_free:
+@@ -344,7 +346,7 @@ int brcmf_fweh_register(struct brcmf_pub
+ brcmf_fweh_handler_t handler)
+ {
+ if (drvr->fweh.evt_handler[code]) {
+- brcmf_err("event code %d already registered\n", code);
++ bphy_err(drvr, "event code %d already registered\n", code);
+ return -ENOSPC;
+ }
+ drvr->fweh.evt_handler[code] = handler;
+@@ -374,6 +376,7 @@ void brcmf_fweh_unregister(struct brcmf_
+ */
+ int brcmf_fweh_activate_events(struct brcmf_if *ifp)
+ {
++ struct brcmf_pub *drvr = ifp->drvr;
+ int i, err;
+ s8 eventmask[BRCMF_EVENTING_MASK_LEN];
+
+@@ -393,7 +396,7 @@ int brcmf_fweh_activate_events(struct br
+ err = brcmf_fil_iovar_data_set(ifp, "event_msgs",
+ eventmask, BRCMF_EVENTING_MASK_LEN);
+ if (err)
+- brcmf_err("Set event_msgs error (%d)\n", err);
++ bphy_err(drvr, "Set event_msgs error (%d)\n", err);
+
+ return err;
+ }
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil.c
+@@ -110,7 +110,7 @@ brcmf_fil_cmd_data(struct brcmf_if *ifp,
+ s32 err;
+
+ if (drvr->bus_if->state != BRCMF_BUS_UP) {
+- brcmf_err("bus is down. we have nothing to do.\n");
++ bphy_err(drvr, "bus is down. we have nothing to do.\n");
+ return -EIO;
+ }
+
+@@ -236,7 +236,7 @@ brcmf_fil_iovar_data_set(struct brcmf_if
+ buflen, true);
+ } else {
+ err = -EPERM;
+- brcmf_err("Creating iovar failed\n");
++ bphy_err(drvr, "Creating iovar failed\n");
+ }
+
+ mutex_unlock(&drvr->proto_block);
+@@ -262,7 +262,7 @@ brcmf_fil_iovar_data_get(struct brcmf_if
+ memcpy(data, drvr->proto_buf, len);
+ } else {
+ err = -EPERM;
+- brcmf_err("Creating iovar failed\n");
++ bphy_err(drvr, "Creating iovar failed\n");
+ }
+
+ brcmf_dbg(FIL, "ifidx=%d, name=%s, len=%d\n", ifp->ifidx, name, len);
+@@ -360,7 +360,7 @@ brcmf_fil_bsscfg_data_set(struct brcmf_i
+ buflen, true);
+ } else {
+ err = -EPERM;
+- brcmf_err("Creating bsscfg failed\n");
++ bphy_err(drvr, "Creating bsscfg failed\n");
+ }
+
+ mutex_unlock(&drvr->proto_block);
+@@ -386,7 +386,7 @@ brcmf_fil_bsscfg_data_get(struct brcmf_i
+ memcpy(data, drvr->proto_buf, len);
+ } else {
+ err = -EPERM;
+- brcmf_err("Creating bsscfg failed\n");
++ bphy_err(drvr, "Creating bsscfg failed\n");
+ }
+ brcmf_dbg(FIL, "ifidx=%d, bsscfgidx=%d, name=%s, len=%d\n", ifp->ifidx,
+ ifp->bsscfgidx, name, len);
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwsignal.c
+@@ -1250,6 +1250,7 @@ static int brcmf_fws_enq(struct brcmf_fw
+ enum brcmf_fws_skb_state state, int fifo,
+ struct sk_buff *p)
+ {
++ struct brcmf_pub *drvr = fws->drvr;
+ int prec = 2 * fifo;
+ u32 *qfull_stat = &fws->stats.delayq_full_error;
+ struct brcmf_fws_mac_descriptor *entry;
+@@ -1262,7 +1263,7 @@ static int brcmf_fws_enq(struct brcmf_fw
+
+ entry = brcmf_skbcb(p)->mac;
+ if (entry == NULL) {
+- brcmf_err("no mac descriptor found for skb %p\n", p);
++ bphy_err(drvr, "no mac descriptor found for skb %p\n", p);
+ return -ENOENT;
+ }
+
+@@ -1452,6 +1453,7 @@ static int
+ brcmf_fws_txs_process(struct brcmf_fws_info *fws, u8 flags, u32 hslot,
+ u32 genbit, u16 seq)
+ {
++ struct brcmf_pub *drvr = fws->drvr;
+ u32 fifo;
+ int ret;
+ bool remove_from_hanger = true;
+@@ -1475,12 +1477,12 @@ brcmf_fws_txs_process(struct brcmf_fws_i
+ else if (flags == BRCMF_FWS_TXSTATUS_HOST_TOSSED)
+ fws->stats.txs_host_tossed++;
+ else
+- brcmf_err("unexpected txstatus\n");
++ bphy_err(drvr, "unexpected txstatus\n");
+
+ ret = brcmf_fws_hanger_poppkt(&fws->hanger, hslot, &skb,
+ remove_from_hanger);
+ if (ret != 0) {
+- brcmf_err("no packet in hanger slot: hslot=%d\n", hslot);
++ bphy_err(drvr, "no packet in hanger slot: hslot=%d\n", hslot);
+ return ret;
+ }
+
+@@ -1586,12 +1588,13 @@ static int brcmf_fws_notify_credit_map(s
+ const struct brcmf_event_msg *e,
+ void *data)
+ {
+- struct brcmf_fws_info *fws = ifp->drvr->fws;
++ struct brcmf_pub *drvr = ifp->drvr;
++ struct brcmf_fws_info *fws = drvr->fws;
+ int i;
+ u8 *credits = data;
+
+ if (e->datalen < BRCMF_FWS_FIFO_COUNT) {
+- brcmf_err("event payload too small (%d)\n", e->datalen);
++ bphy_err(drvr, "event payload too small (%d)\n", e->datalen);
+ return -EINVAL;
+ }
+ if (fws->creditmap_received)
+@@ -1653,6 +1656,7 @@ static void brcmf_rxreorder_get_skb_list
+
+ void brcmf_fws_rxreorder(struct brcmf_if *ifp, struct sk_buff *pkt)
+ {
++ struct brcmf_pub *drvr = ifp->drvr;
+ u8 *reorder_data;
+ u8 flow_id, max_idx, cur_idx, exp_idx, end_idx;
+ struct brcmf_ampdu_rx_reorder *rfi;
+@@ -1667,7 +1671,7 @@ void brcmf_fws_rxreorder(struct brcmf_if
+
+ /* validate flags and flow id */
+ if (flags == 0xFF) {
+- brcmf_err("invalid flags...so ignore this packet\n");
++ bphy_err(drvr, "invalid flags...so ignore this packet\n");
+ brcmf_netif_rx(ifp, pkt);
+ return;
+ }
+@@ -1704,7 +1708,7 @@ void brcmf_fws_rxreorder(struct brcmf_if
+ flow_id, max_idx);
+ rfi = kzalloc(buf_size, GFP_ATOMIC);
+ if (rfi == NULL) {
+- brcmf_err("failed to alloc buffer\n");
++ bphy_err(drvr, "failed to alloc buffer\n");
+ brcmf_netif_rx(ifp, pkt);
+ return;
+ }
+@@ -1969,6 +1973,7 @@ static u8 brcmf_fws_precommit_skb(struct
+ static void brcmf_fws_rollback_toq(struct brcmf_fws_info *fws,
+ struct sk_buff *skb, int fifo)
+ {
++ struct brcmf_pub *drvr = fws->drvr;
+ struct brcmf_fws_mac_descriptor *entry;
+ struct sk_buff *pktout;
+ int qidx, hslot;
+@@ -1982,11 +1987,11 @@ static void brcmf_fws_rollback_toq(struc
+
+ pktout = brcmu_pktq_penq_head(&entry->psq, qidx, skb);
+ if (pktout == NULL) {
+- brcmf_err("%s queue %d full\n", entry->name, qidx);
++ bphy_err(drvr, "%s queue %d full\n", entry->name, qidx);
+ rc = -ENOSPC;
+ }
+ } else {
+- brcmf_err("%s entry removed\n", entry->name);
++ bphy_err(drvr, "%s entry removed\n", entry->name);
+ rc = -ENOENT;
+ }
+
+@@ -2120,7 +2125,7 @@ int brcmf_fws_process_skb(struct brcmf_i
+ brcmf_fws_enq(fws, BRCMF_FWS_SKBSTATE_DELAYED, fifo, skb);
+ brcmf_fws_schedule_deq(fws);
+ } else {
+- brcmf_err("drop skb: no hanger slot\n");
++ bphy_err(drvr, "drop skb: no hanger slot\n");
+ brcmf_txfinalize(ifp, skb, false);
+ rc = -ENOMEM;
+ }
+@@ -2339,7 +2344,7 @@ int brcmf_fws_init(struct brcmf_pub *drv
+
+ fws->fws_wq = create_singlethread_workqueue("brcmf_fws_wq");
+ if (fws->fws_wq == NULL) {
+- brcmf_err("workqueue creation failed\n");
++ bphy_err(drvr, "workqueue creation failed\n");
+ rc = -EBADF;
+ goto fail;
+ }
+@@ -2355,13 +2360,13 @@ int brcmf_fws_init(struct brcmf_pub *drv
+ rc = brcmf_fweh_register(drvr, BRCMF_E_FIFO_CREDIT_MAP,
+ brcmf_fws_notify_credit_map);
+ if (rc < 0) {
+- brcmf_err("register credit map handler failed\n");
++ bphy_err(drvr, "register credit map handler failed\n");
+ goto fail;
+ }
+ rc = brcmf_fweh_register(drvr, BRCMF_E_BCMC_CREDIT_SUPPORT,
+ brcmf_fws_notify_bcmc_credit_support);
+ if (rc < 0) {
+- brcmf_err("register bcmc credit handler failed\n");
++ bphy_err(drvr, "register bcmc credit handler failed\n");
+ brcmf_fweh_unregister(drvr, BRCMF_E_FIFO_CREDIT_MAP);
+ goto fail;
+ }
+@@ -2373,7 +2378,7 @@ int brcmf_fws_init(struct brcmf_pub *drv
+ fws->fw_signals = true;
+ ifp = brcmf_get_ifp(drvr, 0);
+ if (brcmf_fil_iovar_int_set(ifp, "tlv", tlv)) {
+- brcmf_err("failed to set bdcv2 tlv signaling\n");
++ bphy_err(drvr, "failed to set bdcv2 tlv signaling\n");
+ fws->fcmode = BRCMF_FWS_FCMODE_NONE;
+ fws->fw_signals = false;
+ }
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
+@@ -439,7 +439,7 @@ static int brcmf_msgbuf_tx_ioctl(struct
+ brcmf_commonring_lock(commonring);
+ ret_ptr = brcmf_commonring_reserve_for_write(commonring);
+ if (!ret_ptr) {
+- brcmf_err("Failed to reserve space in commonring\n");
++ bphy_err(drvr, "Failed to reserve space in commonring\n");
+ brcmf_commonring_unlock(commonring);
+ return -ENOMEM;
+ }
+@@ -502,7 +502,7 @@ static int brcmf_msgbuf_query_dcmd(struc
+
+ timeout = brcmf_msgbuf_ioctl_resp_wait(msgbuf);
+ if (!timeout) {
+- brcmf_err("Timeout on response for query command\n");
++ bphy_err(drvr, "Timeout on response for query command\n");
+ return -EIO;
+ }
+
+@@ -578,6 +578,7 @@ static u32
+ brcmf_msgbuf_flowring_create_worker(struct brcmf_msgbuf *msgbuf,
+ struct brcmf_msgbuf_work_item *work)
+ {
++ struct brcmf_pub *drvr = msgbuf->drvr;
+ struct msgbuf_tx_flowring_create_req *create;
+ struct brcmf_commonring *commonring;
+ void *ret_ptr;
+@@ -593,7 +594,7 @@ brcmf_msgbuf_flowring_create_worker(stru
+ &msgbuf->flowring_dma_handle[flowid],
+ GFP_KERNEL);
+ if (!dma_buf) {
+- brcmf_err("dma_alloc_coherent failed\n");
++ bphy_err(drvr, "dma_alloc_coherent failed\n");
+ brcmf_flowring_delete(msgbuf->flow, flowid);
+ return BRCMF_FLOWRING_INVALID_ID;
+ }
+@@ -606,7 +607,7 @@ brcmf_msgbuf_flowring_create_worker(stru
+ brcmf_commonring_lock(commonring);
+ ret_ptr = brcmf_commonring_reserve_for_write(commonring);
+ if (!ret_ptr) {
+- brcmf_err("Failed to reserve space in commonring\n");
++ bphy_err(drvr, "Failed to reserve space in commonring\n");
+ brcmf_commonring_unlock(commonring);
+ brcmf_msgbuf_remove_flowring(msgbuf, flowid);
+ return BRCMF_FLOWRING_INVALID_ID;
+@@ -633,7 +634,7 @@ brcmf_msgbuf_flowring_create_worker(stru
+ err = brcmf_commonring_write_complete(commonring);
+ brcmf_commonring_unlock(commonring);
+ if (err) {
+- brcmf_err("Failed to write commonring\n");
++ bphy_err(drvr, "Failed to write commonring\n");
+ brcmf_msgbuf_remove_flowring(msgbuf, flowid);
+ return BRCMF_FLOWRING_INVALID_ID;
+ }
+@@ -692,6 +693,7 @@ static u32 brcmf_msgbuf_flowring_create(
+ static void brcmf_msgbuf_txflow(struct brcmf_msgbuf *msgbuf, u16 flowid)
+ {
+ struct brcmf_flowring *flow = msgbuf->flow;
++ struct brcmf_pub *drvr = msgbuf->drvr;
+ struct brcmf_commonring *commonring;
+ void *ret_ptr;
+ u32 count;
+@@ -711,8 +713,8 @@ static void brcmf_msgbuf_txflow(struct b
+ while (brcmf_flowring_qlen(flow, flowid)) {
+ skb = brcmf_flowring_dequeue(flow, flowid);
+ if (skb == NULL) {
+- brcmf_err("No SKB, but qlen %d\n",
+- brcmf_flowring_qlen(flow, flowid));
++ bphy_err(drvr, "No SKB, but qlen %d\n",
++ brcmf_flowring_qlen(flow, flowid));
+ break;
+ }
+ skb_orphan(skb);
+@@ -720,7 +722,7 @@ static void brcmf_msgbuf_txflow(struct b
+ msgbuf->tx_pktids, skb, ETH_HLEN,
+ &physaddr, &pktid)) {
+ brcmf_flowring_reinsert(flow, flowid, skb);
+- brcmf_err("No PKTID available !!\n");
++ bphy_err(drvr, "No PKTID available !!\n");
+ break;
+ }
+ ret_ptr = brcmf_commonring_reserve_for_write(commonring);
+@@ -891,6 +893,7 @@ brcmf_msgbuf_process_txstatus(struct brc
+
+ static u32 brcmf_msgbuf_rxbuf_data_post(struct brcmf_msgbuf *msgbuf, u32 count)
+ {
++ struct brcmf_pub *drvr = msgbuf->drvr;
+ struct brcmf_commonring *commonring;
+ void *ret_ptr;
+ struct sk_buff *skb;
+@@ -918,7 +921,7 @@ static u32 brcmf_msgbuf_rxbuf_data_post(
+ skb = brcmu_pkt_buf_get_skb(BRCMF_MSGBUF_MAX_PKT_SIZE);
+
+ if (skb == NULL) {
+- brcmf_err("Failed to alloc SKB\n");
++ bphy_err(drvr, "Failed to alloc SKB\n");
+ brcmf_commonring_write_cancel(commonring, alloced - i);
+ break;
+ }
+@@ -928,7 +931,7 @@ static u32 brcmf_msgbuf_rxbuf_data_post(
+ msgbuf->rx_pktids, skb, 0,
+ &physaddr, &pktid)) {
+ dev_kfree_skb_any(skb);
+- brcmf_err("No PKTID available !!\n");
++ bphy_err(drvr, "No PKTID available !!\n");
+ brcmf_commonring_write_cancel(commonring, alloced - i);
+ break;
+ }
+@@ -998,6 +1001,7 @@ static u32
+ brcmf_msgbuf_rxbuf_ctrl_post(struct brcmf_msgbuf *msgbuf, bool event_buf,
+ u32 count)
+ {
++ struct brcmf_pub *drvr = msgbuf->drvr;
+ struct brcmf_commonring *commonring;
+ void *ret_ptr;
+ struct sk_buff *skb;
+@@ -1015,7 +1019,7 @@ brcmf_msgbuf_rxbuf_ctrl_post(struct brcm
+ count,
+ &alloced);
+ if (!ret_ptr) {
+- brcmf_err("Failed to reserve space in commonring\n");
++ bphy_err(drvr, "Failed to reserve space in commonring\n");
+ brcmf_commonring_unlock(commonring);
+ return 0;
+ }
+@@ -1027,7 +1031,7 @@ brcmf_msgbuf_rxbuf_ctrl_post(struct brcm
+ skb = brcmu_pkt_buf_get_skb(BRCMF_MSGBUF_MAX_PKT_SIZE);
+
+ if (skb == NULL) {
+- brcmf_err("Failed to alloc SKB\n");
++ bphy_err(drvr, "Failed to alloc SKB\n");
+ brcmf_commonring_write_cancel(commonring, alloced - i);
+ break;
+ }
+@@ -1037,7 +1041,7 @@ brcmf_msgbuf_rxbuf_ctrl_post(struct brcm
+ msgbuf->rx_pktids, skb, 0,
+ &physaddr, &pktid)) {
+ dev_kfree_skb_any(skb);
+- brcmf_err("No PKTID available !!\n");
++ bphy_err(drvr, "No PKTID available !!\n");
+ brcmf_commonring_write_cancel(commonring, alloced - i);
+ break;
+ }
+@@ -1089,6 +1093,7 @@ static void brcmf_msgbuf_rxbuf_event_pos
+
+ static void brcmf_msgbuf_process_event(struct brcmf_msgbuf *msgbuf, void *buf)
+ {
++ struct brcmf_pub *drvr = msgbuf->drvr;
+ struct msgbuf_rx_event *event;
+ u32 idx;
+ u16 buflen;
+@@ -1115,8 +1120,8 @@ static void brcmf_msgbuf_process_event(s
+
+ ifp = brcmf_get_ifp(msgbuf->drvr, event->msg.ifidx);
+ if (!ifp || !ifp->ndev) {
+- brcmf_err("Received pkt for invalid ifidx %d\n",
+- event->msg.ifidx);
++ bphy_err(drvr, "Received pkt for invalid ifidx %d\n",
++ event->msg.ifidx);
+ goto exit;
+ }
+
+@@ -1132,6 +1137,7 @@ exit:
+ static void
+ brcmf_msgbuf_process_rx_complete(struct brcmf_msgbuf *msgbuf, void *buf)
+ {
++ struct brcmf_pub *drvr = msgbuf->drvr;
+ struct msgbuf_rx_complete *rx_complete;
+ struct sk_buff *skb;
+ u16 data_offset;
+@@ -1165,7 +1171,7 @@ brcmf_msgbuf_process_rx_complete(struct
+ ifp = msgbuf->drvr->mon_if;
+
+ if (!ifp) {
+- brcmf_err("Received unexpected monitor pkt\n");
++ bphy_err(drvr, "Received unexpected monitor pkt\n");
+ brcmu_pkt_buf_free_skb(skb);
+ return;
+ }
+@@ -1176,8 +1182,8 @@ brcmf_msgbuf_process_rx_complete(struct
+
+ ifp = brcmf_get_ifp(msgbuf->drvr, rx_complete->msg.ifidx);
+ if (!ifp || !ifp->ndev) {
+- brcmf_err("Received pkt for invalid ifidx %d\n",
+- rx_complete->msg.ifidx);
++ bphy_err(drvr, "Received pkt for invalid ifidx %d\n",
++ rx_complete->msg.ifidx);
+ brcmu_pkt_buf_free_skb(skb);
+ return;
+ }
+@@ -1190,13 +1196,15 @@ static void brcmf_msgbuf_process_ring_st
+ void *buf)
+ {
+ struct msgbuf_ring_status *ring_status = buf;
++ struct brcmf_pub *drvr = msgbuf->drvr;
+ int err;
+
+ err = le16_to_cpu(ring_status->compl_hdr.status);
+ if (err) {
+ int ring = le16_to_cpu(ring_status->compl_hdr.flow_ring_id);
+
+- brcmf_err("Firmware reported ring %d error: %d\n", ring, err);
++ bphy_err(drvr, "Firmware reported ring %d error: %d\n", ring,
++ err);
+ }
+ }
+
+@@ -1204,6 +1212,7 @@ static void
+ brcmf_msgbuf_process_flow_ring_create_response(struct brcmf_msgbuf *msgbuf,
+ void *buf)
+ {
++ struct brcmf_pub *drvr = msgbuf->drvr;
+ struct msgbuf_flowring_create_resp *flowring_create_resp;
+ u16 status;
+ u16 flowid;
+@@ -1215,7 +1224,7 @@ brcmf_msgbuf_process_flow_ring_create_re
+ status = le16_to_cpu(flowring_create_resp->compl_hdr.status);
+
+ if (status) {
+- brcmf_err("Flowring creation failed, code %d\n", status);
++ bphy_err(drvr, "Flowring creation failed, code %d\n", status);
+ brcmf_msgbuf_remove_flowring(msgbuf, flowid);
+ return;
+ }
+@@ -1232,6 +1241,7 @@ static void
+ brcmf_msgbuf_process_flow_ring_delete_response(struct brcmf_msgbuf *msgbuf,
+ void *buf)
+ {
++ struct brcmf_pub *drvr = msgbuf->drvr;
+ struct msgbuf_flowring_delete_resp *flowring_delete_resp;
+ u16 status;
+ u16 flowid;
+@@ -1243,7 +1253,7 @@ brcmf_msgbuf_process_flow_ring_delete_re
+ status = le16_to_cpu(flowring_delete_resp->compl_hdr.status);
+
+ if (status) {
+- brcmf_err("Flowring deletion failed, code %d\n", status);
++ bphy_err(drvr, "Flowring deletion failed, code %d\n", status);
+ brcmf_flowring_delete(msgbuf->flow, flowid);
+ return;
+ }
+@@ -1256,6 +1266,7 @@ brcmf_msgbuf_process_flow_ring_delete_re
+
+ static void brcmf_msgbuf_process_msgtype(struct brcmf_msgbuf *msgbuf, void *buf)
+ {
++ struct brcmf_pub *drvr = msgbuf->drvr;
+ struct msgbuf_common_hdr *msg;
+
+ msg = (struct msgbuf_common_hdr *)buf;
+@@ -1292,7 +1303,7 @@ static void brcmf_msgbuf_process_msgtype
+ brcmf_msgbuf_process_rx_complete(msgbuf, buf);
+ break;
+ default:
+- brcmf_err("Unsupported msgtype %d\n", msg->msgtype);
++ bphy_err(drvr, "Unsupported msgtype %d\n", msg->msgtype);
+ break;
+ }
+ }
+@@ -1375,7 +1386,7 @@ void brcmf_msgbuf_delete_flowring(struct
+ brcmf_commonring_lock(commonring);
+ ret_ptr = brcmf_commonring_reserve_for_write(commonring);
+ if (!ret_ptr) {
+- brcmf_err("FW unaware, flowring will be removed !!\n");
++ bphy_err(drvr, "FW unaware, flowring will be removed !!\n");
+ brcmf_commonring_unlock(commonring);
+ brcmf_msgbuf_remove_flowring(msgbuf, flowid);
+ return;
+@@ -1399,7 +1410,7 @@ void brcmf_msgbuf_delete_flowring(struct
+ err = brcmf_commonring_write_complete(commonring);
+ brcmf_commonring_unlock(commonring);
+ if (err) {
+- brcmf_err("Failed to submit RING_DELETE, flowring will be removed\n");
++ bphy_err(drvr, "Failed to submit RING_DELETE, flowring will be removed\n");
+ brcmf_msgbuf_remove_flowring(msgbuf, flowid);
+ }
+ }
+@@ -1469,8 +1480,8 @@ int brcmf_proto_msgbuf_attach(struct brc
+ if_msgbuf = drvr->bus_if->msgbuf;
+
+ if (if_msgbuf->max_flowrings >= BRCMF_FLOWRING_HASHSIZE) {
+- brcmf_err("driver not configured for this many flowrings %d\n",
+- if_msgbuf->max_flowrings);
++ bphy_err(drvr, "driver not configured for this many flowrings %d\n",
++ if_msgbuf->max_flowrings);
+ if_msgbuf->max_flowrings = BRCMF_FLOWRING_HASHSIZE - 1;
+ }
+
+@@ -1480,7 +1491,7 @@ int brcmf_proto_msgbuf_attach(struct brc
+
+ msgbuf->txflow_wq = create_singlethread_workqueue("msgbuf_txflow");
+ if (msgbuf->txflow_wq == NULL) {
+- brcmf_err("workqueue creation failed\n");
++ bphy_err(drvr, "workqueue creation failed\n");
+ goto fail;
+ }
+ INIT_WORK(&msgbuf->txflow_work, brcmf_msgbuf_txflow_worker);
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
+@@ -434,6 +434,7 @@ static void brcmf_p2p_print_actframe(boo
+ */
+ static int brcmf_p2p_set_firmware(struct brcmf_if *ifp, u8 *p2p_mac)
+ {
++ struct brcmf_pub *drvr = ifp->drvr;
+ s32 ret = 0;
+
+ brcmf_fil_cmd_int_set(ifp, BRCMF_C_DOWN, 1);
+@@ -450,7 +451,7 @@ static int brcmf_p2p_set_firmware(struct
+ ret = brcmf_fil_iovar_data_set(ifp, "p2p_da_override", p2p_mac,
+ ETH_ALEN);
+ if (ret)
+- brcmf_err("failed to update device address ret %d\n", ret);
++ bphy_err(drvr, "failed to update device address ret %d\n", ret);
+
+ return ret;
+ }
+@@ -572,13 +573,14 @@ static s32 brcmf_p2p_deinit_discovery(st
+ */
+ static int brcmf_p2p_enable_discovery(struct brcmf_p2p_info *p2p)
+ {
++ struct brcmf_pub *drvr = p2p->cfg->pub;
+ struct brcmf_cfg80211_vif *vif;
+ s32 ret = 0;
+
+ brcmf_dbg(TRACE, "enter\n");
+ vif = p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif;
+ if (!vif) {
+- brcmf_err("P2P config device not available\n");
++ bphy_err(drvr, "P2P config device not available\n");
+ ret = -EPERM;
+ goto exit;
+ }
+@@ -592,13 +594,13 @@ static int brcmf_p2p_enable_discovery(st
+ vif = p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif;
+ ret = brcmf_fil_iovar_int_set(vif->ifp, "p2p_disc", 1);
+ if (ret < 0) {
+- brcmf_err("set p2p_disc error\n");
++ bphy_err(drvr, "set p2p_disc error\n");
+ goto exit;
+ }
+ vif = p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif;
+ ret = brcmf_p2p_set_discover_state(vif->ifp, WL_P2P_DISC_ST_SCAN, 0, 0);
+ if (ret < 0) {
+- brcmf_err("unable to set WL_P2P_DISC_ST_SCAN\n");
++ bphy_err(drvr, "unable to set WL_P2P_DISC_ST_SCAN\n");
+ goto exit;
+ }
+
+@@ -610,7 +612,7 @@ static int brcmf_p2p_enable_discovery(st
+ */
+ ret = brcmf_fil_bsscfg_int_set(vif->ifp, "wsec", AES_ENABLED);
+ if (ret < 0) {
+- brcmf_err("wsec error %d\n", ret);
++ bphy_err(drvr, "wsec error %d\n", ret);
+ goto exit;
+ }
+
+@@ -632,6 +634,7 @@ static s32 brcmf_p2p_escan(struct brcmf_
+ u16 chanspecs[], s32 search_state,
+ enum p2p_bss_type bss_type)
+ {
++ struct brcmf_pub *drvr = p2p->cfg->pub;
+ s32 ret = 0;
+ s32 memsize = offsetof(struct brcmf_p2p_scan_le,
+ eparams.params_le.channel_list);
+@@ -650,7 +653,7 @@ static s32 brcmf_p2p_escan(struct brcmf_
+
+ vif = p2p->bss_idx[bss_type].vif;
+ if (vif == NULL) {
+- brcmf_err("no vif for bss type %d\n", bss_type);
++ bphy_err(drvr, "no vif for bss type %d\n", bss_type);
+ ret = -EINVAL;
+ goto exit;
+ }
+@@ -678,7 +681,7 @@ static s32 brcmf_p2p_escan(struct brcmf_
+ BRCMF_P2P_WILDCARD_SSID_LEN);
+ break;
+ default:
+- brcmf_err(" invalid search state %d\n", search_state);
++ bphy_err(drvr, " invalid search state %d\n", search_state);
+ ret = -EINVAL;
+ goto exit;
+ }
+@@ -765,6 +768,7 @@ static s32 brcmf_p2p_run_escan(struct br
+ struct cfg80211_scan_request *request)
+ {
+ struct brcmf_p2p_info *p2p = &cfg->p2p;
++ struct brcmf_pub *drvr = cfg->pub;
+ s32 err = 0;
+ s32 search_state = WL_P2P_DISC_ST_SCAN;
+ struct brcmf_cfg80211_vif *vif;
+@@ -827,7 +831,7 @@ static s32 brcmf_p2p_run_escan(struct br
+ }
+ exit:
+ if (err)
+- brcmf_err("error (%d)\n", err);
++ bphy_err(drvr, "error (%d)\n", err);
+ return err;
+ }
+
+@@ -924,19 +928,20 @@ int brcmf_p2p_scan_prep(struct wiphy *wi
+ static s32
+ brcmf_p2p_discover_listen(struct brcmf_p2p_info *p2p, u16 channel, u32 duration)
+ {
++ struct brcmf_pub *drvr = p2p->cfg->pub;
+ struct brcmf_cfg80211_vif *vif;
+ struct brcmu_chan ch;
+ s32 err = 0;
+
+ vif = p2p->bss_idx[P2PAPI_BSSCFG_DEVICE].vif;
+ if (!vif) {
+- brcmf_err("Discovery is not set, so we have nothing to do\n");
++ bphy_err(drvr, "Discovery is not set, so we have nothing to do\n");
+ err = -EPERM;
+ goto exit;
+ }
+
+ if (test_bit(BRCMF_P2P_STATUS_DISCOVER_LISTEN, &p2p->status)) {
+- brcmf_err("Previous LISTEN is not completed yet\n");
++ bphy_err(drvr, "Previous LISTEN is not completed yet\n");
+ /* WAR: prevent cookie mismatch in wpa_supplicant return OK */
+ goto exit;
+ }
+@@ -1053,6 +1058,7 @@ void brcmf_p2p_cancel_remain_on_channel(
+ */
+ static s32 brcmf_p2p_act_frm_search(struct brcmf_p2p_info *p2p, u16 channel)
+ {
++ struct brcmf_pub *drvr = p2p->cfg->pub;
+ s32 err;
+ u32 channel_cnt;
+ u16 *default_chan_list;
+@@ -1068,7 +1074,7 @@ static s32 brcmf_p2p_act_frm_search(stru
+ default_chan_list = kzalloc(channel_cnt * sizeof(*default_chan_list),
+ GFP_KERNEL);
+ if (default_chan_list == NULL) {
+- brcmf_err("channel list allocation failed\n");
++ bphy_err(drvr, "channel list allocation failed\n");
+ err = -ENOMEM;
+ goto exit;
+ }
+@@ -1110,6 +1116,7 @@ static void brcmf_p2p_afx_handler(struct
+ struct brcmf_p2p_info *p2p = container_of(afx_hdl,
+ struct brcmf_p2p_info,
+ afx_hdl);
++ struct brcmf_pub *drvr = p2p->cfg->pub;
+ s32 err;
+
+ if (!afx_hdl->is_active)
+@@ -1123,7 +1130,7 @@ static void brcmf_p2p_afx_handler(struct
+ err = brcmf_p2p_act_frm_search(p2p, afx_hdl->peer_listen_chan);
+
+ if (err) {
+- brcmf_err("ERROR occurred! value is (%d)\n", err);
++ bphy_err(drvr, "ERROR occurred! value is (%d)\n", err);
+ if (test_bit(BRCMF_P2P_STATUS_FINDING_COMMON_CHANNEL,
+ &p2p->status))
+ complete(&afx_hdl->act_frm_scan);
+@@ -1345,7 +1352,8 @@ int brcmf_p2p_notify_action_frame_rx(str
+ const struct brcmf_event_msg *e,
+ void *data)
+ {
+- struct brcmf_cfg80211_info *cfg = ifp->drvr->config;
++ struct brcmf_pub *drvr = ifp->drvr;
++ struct brcmf_cfg80211_info *cfg = drvr->config;
+ struct brcmf_p2p_info *p2p = &cfg->p2p;
+ struct afx_hdl *afx_hdl = &p2p->afx_hdl;
+ struct wireless_dev *wdev;
+@@ -1416,7 +1424,7 @@ int brcmf_p2p_notify_action_frame_rx(str
+ mgmt_frame = kzalloc(offsetof(struct ieee80211_mgmt, u) +
+ mgmt_frame_len, GFP_KERNEL);
+ if (!mgmt_frame) {
+- brcmf_err("No memory available for action frame\n");
++ bphy_err(drvr, "No memory available for action frame\n");
+ return -ENOMEM;
+ }
+ memcpy(mgmt_frame->da, ifp->mac_addr, ETH_ALEN);
+@@ -1499,6 +1507,7 @@ int brcmf_p2p_notify_action_tx_complete(
+ static s32 brcmf_p2p_tx_action_frame(struct brcmf_p2p_info *p2p,
+ struct brcmf_fil_af_params_le *af_params)
+ {
++ struct brcmf_pub *drvr = p2p->cfg->pub;
+ struct brcmf_cfg80211_vif *vif;
+ s32 err = 0;
+ s32 timeout = 0;
+@@ -1513,7 +1522,7 @@ static s32 brcmf_p2p_tx_action_frame(str
+ err = brcmf_fil_bsscfg_data_set(vif->ifp, "actframe", af_params,
+ sizeof(*af_params));
+ if (err) {
+- brcmf_err(" sending action frame has failed\n");
++ bphy_err(drvr, " sending action frame has failed\n");
+ goto exit;
+ }
+
+@@ -1563,6 +1572,7 @@ static s32 brcmf_p2p_pub_af_tx(struct br
+ struct brcmf_config_af_params *config_af_params)
+ {
+ struct brcmf_p2p_info *p2p = &cfg->p2p;
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_fil_action_frame_le *action_frame;
+ struct brcmf_p2p_pub_act_frame *act_frm;
+ s32 err = 0;
+@@ -1641,8 +1651,8 @@ static s32 brcmf_p2p_pub_af_tx(struct br
+ config_af_params->extra_listen = false;
+ break;
+ default:
+- brcmf_err("Unknown p2p pub act frame subtype: %d\n",
+- act_frm->subtype);
++ bphy_err(drvr, "Unknown p2p pub act frame subtype: %d\n",
++ act_frm->subtype);
+ err = -EINVAL;
+ }
+ return err;
+@@ -1664,6 +1674,7 @@ bool brcmf_p2p_send_action_frame(struct
+ struct brcmf_fil_action_frame_le *action_frame;
+ struct brcmf_config_af_params config_af_params;
+ struct afx_hdl *afx_hdl = &p2p->afx_hdl;
++ struct brcmf_pub *drvr = cfg->pub;
+ u16 action_frame_len;
+ bool ack = false;
+ u8 category;
+@@ -1699,7 +1710,7 @@ bool brcmf_p2p_send_action_frame(struct
+ if (brcmf_p2p_pub_af_tx(cfg, af_params, &config_af_params)) {
+ /* Just send unknown subtype frame with */
+ /* default parameters. */
+- brcmf_err("P2P Public action frame, unknown subtype.\n");
++ bphy_err(drvr, "P2P Public action frame, unknown subtype.\n");
+ }
+ } else if (brcmf_p2p_is_gas_action(action_frame->data,
+ action_frame_len)) {
+@@ -1721,7 +1732,7 @@ bool brcmf_p2p_send_action_frame(struct
+ af_params->dwell_time =
+ cpu_to_le32(P2P_AF_MIN_DWELL_TIME);
+ } else {
+- brcmf_err("Unknown action type: %d\n", action);
++ bphy_err(drvr, "Unknown action type: %d\n", action);
+ goto exit;
+ }
+ } else if (brcmf_p2p_is_p2p_action(action_frame->data,
+@@ -1729,8 +1740,8 @@ bool brcmf_p2p_send_action_frame(struct
+ /* do not configure anything. it will be */
+ /* sent with a default configuration */
+ } else {
+- brcmf_err("Unknown Frame: category 0x%x, action 0x%x\n",
+- category, action);
++ bphy_err(drvr, "Unknown Frame: category 0x%x, action 0x%x\n",
++ category, action);
+ return false;
+ }
+
+@@ -1768,7 +1779,7 @@ bool brcmf_p2p_send_action_frame(struct
+
+ if (brcmf_p2p_af_searching_channel(p2p) ==
+ P2P_INVALID_CHANNEL) {
+- brcmf_err("Couldn't find peer's channel.\n");
++ bphy_err(drvr, "Couldn't find peer's channel.\n");
+ goto exit;
+ }
+
+@@ -1790,7 +1801,8 @@ bool brcmf_p2p_send_action_frame(struct
+ tx_retry++;
+ }
+ if (ack == false) {
+- brcmf_err("Failed to send Action Frame(retry %d)\n", tx_retry);
++ bphy_err(drvr, "Failed to send Action Frame(retry %d)\n",
++ tx_retry);
+ clear_bit(BRCMF_P2P_STATUS_GO_NEG_PHASE, &p2p->status);
+ }
+
+@@ -1972,6 +1984,7 @@ int brcmf_p2p_ifchange(struct brcmf_cfg8
+ enum brcmf_fil_p2p_if_types if_type)
+ {
+ struct brcmf_p2p_info *p2p = &cfg->p2p;
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_cfg80211_vif *vif;
+ struct brcmf_fil_p2p_if_le if_request;
+ s32 err;
+@@ -1981,13 +1994,13 @@ int brcmf_p2p_ifchange(struct brcmf_cfg8
+
+ vif = p2p->bss_idx[P2PAPI_BSSCFG_PRIMARY].vif;
+ if (!vif) {
+- brcmf_err("vif for P2PAPI_BSSCFG_PRIMARY does not exist\n");
++ bphy_err(drvr, "vif for P2PAPI_BSSCFG_PRIMARY does not exist\n");
+ return -EPERM;
+ }
+ brcmf_notify_escan_complete(cfg, vif->ifp, true, true);
+ vif = p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif;
+ if (!vif) {
+- brcmf_err("vif for P2PAPI_BSSCFG_CONNECTION does not exist\n");
++ bphy_err(drvr, "vif for P2PAPI_BSSCFG_CONNECTION does not exist\n");
+ return -EPERM;
+ }
+ brcmf_set_mpc(vif->ifp, 0);
+@@ -2005,7 +2018,7 @@ int brcmf_p2p_ifchange(struct brcmf_cfg8
+ err = brcmf_fil_iovar_data_set(vif->ifp, "p2p_ifupd", &if_request,
+ sizeof(if_request));
+ if (err) {
+- brcmf_err("p2p_ifupd FAILED, err=%d\n", err);
++ bphy_err(drvr, "p2p_ifupd FAILED, err=%d\n", err);
+ brcmf_cfg80211_arm_vif_event(cfg, NULL);
+ return err;
+ }
+@@ -2013,7 +2026,7 @@ int brcmf_p2p_ifchange(struct brcmf_cfg8
+ BRCMF_VIF_EVENT_TIMEOUT);
+ brcmf_cfg80211_arm_vif_event(cfg, NULL);
+ if (!err) {
+- brcmf_err("No BRCMF_E_IF_CHANGE event received\n");
++ bphy_err(drvr, "No BRCMF_E_IF_CHANGE event received\n");
+ return -EIO;
+ }
+
+@@ -2076,6 +2089,7 @@ static struct wireless_dev *brcmf_p2p_cr
+ struct wiphy *wiphy,
+ u8 *addr)
+ {
++ struct brcmf_pub *drvr = p2p->cfg->pub;
+ struct brcmf_cfg80211_vif *p2p_vif;
+ struct brcmf_if *p2p_ifp;
+ struct brcmf_if *pri_ifp;
+@@ -2087,7 +2101,7 @@ static struct wireless_dev *brcmf_p2p_cr
+
+ p2p_vif = brcmf_alloc_vif(p2p->cfg, NL80211_IFTYPE_P2P_DEVICE);
+ if (IS_ERR(p2p_vif)) {
+- brcmf_err("could not create discovery vif\n");
++ bphy_err(drvr, "could not create discovery vif\n");
+ return (struct wireless_dev *)p2p_vif;
+ }
+
+@@ -2101,7 +2115,7 @@ static struct wireless_dev *brcmf_p2p_cr
+ /* Initialize P2P Discovery in the firmware */
+ err = brcmf_fil_iovar_int_set(pri_ifp, "p2p_disc", 1);
+ if (err < 0) {
+- brcmf_err("set p2p_disc error\n");
++ bphy_err(drvr, "set p2p_disc error\n");
+ brcmf_fweh_p2pdev_setup(pri_ifp, false);
+ brcmf_cfg80211_arm_vif_event(p2p->cfg, NULL);
+ goto fail;
+@@ -2113,7 +2127,7 @@ static struct wireless_dev *brcmf_p2p_cr
+ brcmf_cfg80211_arm_vif_event(p2p->cfg, NULL);
+ brcmf_fweh_p2pdev_setup(pri_ifp, false);
+ if (!err) {
+- brcmf_err("timeout occurred\n");
++ bphy_err(drvr, "timeout occurred\n");
+ err = -EIO;
+ goto fail;
+ }
+@@ -2127,7 +2141,7 @@ static struct wireless_dev *brcmf_p2p_cr
+ /* verify bsscfg index for P2P discovery */
+ err = brcmf_fil_iovar_int_get(pri_ifp, "p2p_dev", &bsscfgidx);
+ if (err < 0) {
+- brcmf_err("retrieving discover bsscfg index failed\n");
++ bphy_err(drvr, "retrieving discover bsscfg index failed\n");
+ goto fail;
+ }
+
+@@ -2162,6 +2176,7 @@ struct wireless_dev *brcmf_p2p_add_vif(s
+ {
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_if *ifp = netdev_priv(cfg_to_ndev(cfg));
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_cfg80211_vif *vif;
+ enum brcmf_fil_p2p_if_types iftype;
+ int err;
+@@ -2202,7 +2217,7 @@ struct wireless_dev *brcmf_p2p_add_vif(s
+ BRCMF_VIF_EVENT_TIMEOUT);
+ brcmf_cfg80211_arm_vif_event(cfg, NULL);
+ if (!err) {
+- brcmf_err("timeout occurred\n");
++ bphy_err(drvr, "timeout occurred\n");
+ err = -EIO;
+ goto fail;
+ }
+@@ -2210,7 +2225,7 @@ struct wireless_dev *brcmf_p2p_add_vif(s
+ /* interface created in firmware */
+ ifp = vif->ifp;
+ if (!ifp) {
+- brcmf_err("no if pointer provided\n");
++ bphy_err(drvr, "no if pointer provided\n");
+ err = -ENOENT;
+ goto fail;
+ }
+@@ -2221,7 +2236,7 @@ struct wireless_dev *brcmf_p2p_add_vif(s
+ #endif /* >= 3.17.0 */
+ err = brcmf_net_attach(ifp, true);
+ if (err) {
+- brcmf_err("Registering netdevice failed\n");
++ bphy_err(drvr, "Registering netdevice failed\n");
+ goto fail;
+ }
+
+@@ -2375,6 +2390,7 @@ void brcmf_p2p_stop_device(struct wiphy
+ */
+ s32 brcmf_p2p_attach(struct brcmf_cfg80211_info *cfg, bool p2pdev_forced)
+ {
++ struct brcmf_pub *drvr = cfg->pub;
+ struct brcmf_p2p_info *p2p;
+ struct brcmf_if *pri_ifp;
+ s32 err = 0;
+@@ -2389,7 +2405,7 @@ s32 brcmf_p2p_attach(struct brcmf_cfg802
+ if (p2pdev_forced) {
+ err_ptr = brcmf_p2p_create_p2pdev(p2p, NULL, NULL);
+ if (IS_ERR(err_ptr)) {
+- brcmf_err("P2P device creation failed.\n");
++ bphy_err(drvr, "P2P device creation failed.\n");
+ err = PTR_ERR(err_ptr);
+ }
+ } else {
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pno.c
+@@ -47,6 +47,7 @@ static int brcmf_pno_channel_config(stru
+ static int brcmf_pno_config(struct brcmf_if *ifp, u32 scan_freq,
+ u32 mscan, u32 bestn)
+ {
++ struct brcmf_pub *drvr = ifp->drvr;
+ struct brcmf_pno_param_le pfn_param;
+ u16 flags;
+ u32 pfnmem;
+@@ -75,13 +76,13 @@ static int brcmf_pno_config(struct brcmf
+ /* set bestn in firmware */
+ err = brcmf_fil_iovar_int_set(ifp, "pfnmem", pfnmem);
+ if (err < 0) {
+- brcmf_err("failed to set pfnmem\n");
++ bphy_err(drvr, "failed to set pfnmem\n");
+ goto exit;
+ }
+ /* get max mscan which the firmware supports */
+ err = brcmf_fil_iovar_int_get(ifp, "pfnmem", &pfnmem);
+ if (err < 0) {
+- brcmf_err("failed to get pfnmem\n");
++ bphy_err(drvr, "failed to get pfnmem\n");
+ goto exit;
+ }
+ mscan = min_t(u32, mscan, pfnmem);
+@@ -95,7 +96,7 @@ static int brcmf_pno_config(struct brcmf
+ err = brcmf_fil_iovar_data_set(ifp, "pfn_set", &pfn_param,
+ sizeof(pfn_param));
+ if (err)
+- brcmf_err("pfn_set failed, err=%d\n", err);
++ bphy_err(drvr, "pfn_set failed, err=%d\n", err);
+
+ exit:
+ return err;
+@@ -104,6 +105,7 @@ exit:
+ static int brcmf_pno_set_random(struct brcmf_if *ifp, u8 *mac_addr,
+ u8 *mac_mask)
+ {
++ struct brcmf_pub *drvr = ifp->drvr;
+ struct brcmf_pno_macaddr_le pfn_mac;
+ int err, i;
+
+@@ -123,7 +125,7 @@ static int brcmf_pno_set_random(struct b
+ err = brcmf_fil_iovar_data_set(ifp, "pfn_macaddr", &pfn_mac,
+ sizeof(pfn_mac));
+ if (err)
+- brcmf_err("pfn_macaddr failed, err=%d\n", err);
++ bphy_err(drvr, "pfn_macaddr failed, err=%d\n", err);
+
+ return err;
+ }
+@@ -165,6 +167,7 @@ static bool brcmf_is_ssid_active(struct
+
+ int brcmf_pno_clean(struct brcmf_if *ifp)
+ {
++ struct brcmf_pub *drvr = ifp->drvr;
+ int ret;
+
+ /* Disable pfn */
+@@ -174,7 +177,7 @@ int brcmf_pno_clean(struct brcmf_if *ifp
+ ret = brcmf_fil_iovar_data_set(ifp, "pfnclear", NULL, 0);
+ }
+ if (ret < 0)
+- brcmf_err("failed code %d\n", ret);
++ bphy_err(drvr, "failed code %d\n", ret);
+
+ return ret;
+ }
+@@ -182,6 +185,7 @@ int brcmf_pno_clean(struct brcmf_if *ifp
+ int brcmf_pno_start_sched_scan(struct brcmf_if *ifp,
+ struct cfg80211_sched_scan_request *req)
+ {
++ struct brcmf_pub *drvr = ifp->drvr;
+ struct brcmu_d11inf *d11inf;
+ struct brcmf_pno_config_le pno_cfg;
+ struct cfg80211_ssid *ssid;
+@@ -191,7 +195,7 @@ int brcmf_pno_start_sched_scan(struct br
+ /* clean up everything */
+ ret = brcmf_pno_clean(ifp);
+ if (ret < 0) {
+- brcmf_err("failed error=%d\n", ret);
++ bphy_err(drvr, "failed error=%d\n", ret);
+ return ret;
+ }
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/proto.c
+@@ -47,15 +47,15 @@ int brcmf_proto_attach(struct brcmf_pub
+ if (brcmf_proto_msgbuf_attach(drvr))
+ goto fail;
+ } else {
+- brcmf_err("Unsupported proto type %d\n",
+- drvr->bus_if->proto_type);
++ bphy_err(drvr, "Unsupported proto type %d\n",
++ drvr->bus_if->proto_type);
+ goto fail;
+ }
+ if (!proto->tx_queue_data || (proto->hdrpull == NULL) ||
+ (proto->query_dcmd == NULL) || (proto->set_dcmd == NULL) ||
+ (proto->configure_addr_mode == NULL) ||
+ (proto->delete_peer == NULL) || (proto->add_tdls_peer == NULL)) {
+- brcmf_err("Not all proto handlers have been installed\n");
++ bphy_err(drvr, "Not all proto handlers have been installed\n");
+ goto fail;
+ }
+ return 0;
diff --git a/package/kernel/mac80211/patches/339-v5.1-0010-brcmfmac-add-basic-validation-of-shared-RAM-address.patch b/package/kernel/mac80211/patches/339-v5.1-0010-brcmfmac-add-basic-validation-of-shared-RAM-address.patch
new file mode 100644
index 0000000000..8ccf55b5b8
--- /dev/null
+++ b/package/kernel/mac80211/patches/339-v5.1-0010-brcmfmac-add-basic-validation-of-shared-RAM-address.patch
@@ -0,0 +1,38 @@
+From e0a8ef4d7b4315bc4c1641fb3f3a7dfdfa6627b8 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= <rafal@milecki.pl>
+Date: Wed, 20 Feb 2019 11:30:47 +0100
+Subject: [PATCH] brcmfmac: add basic validation of shared RAM address
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+While experimenting with firmware loading I ended up in a state of
+firmware reporting shared RAM address 0x04000001. It was causing:
+[ 94.448015] Unable to handle kernel paging request at virtual address cd680001
+due to reading out of the mapped memory.
+
+This patch adds some basic validation to avoid kernel crashes due to the
+unexpected firmware behavior.
+
+Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
+Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
+Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
+---
+ drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c | 6 ++++++
+ 1 file changed, 6 insertions(+)
+
+--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
++++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c
+@@ -1532,6 +1532,12 @@ static int brcmf_pcie_download_fw_nvram(
+ brcmf_err(bus, "FW failed to initialize\n");
+ return -ENODEV;
+ }
++ if (sharedram_addr < devinfo->ci->rambase ||
++ sharedram_addr >= devinfo->ci->rambase + devinfo->ci->ramsize) {
++ brcmf_err(bus, "Invalid shared RAM address 0x%08x\n",
++ sharedram_addr);
++ return -ENODEV;
++ }
+ brcmf_dbg(PCIE, "Shared RAM addr: 0x%08x\n", sharedram_addr);
+
+ return (brcmf_pcie_init_share_ram_info(devinfo, sharedram_addr));
diff --git a/package/kernel/mac80211/patches/860-brcmfmac-register-wiphy-s-during-module_init.patch b/package/kernel/mac80211/patches/860-brcmfmac-register-wiphy-s-during-module_init.patch
index 85d3544dcd..e8e2afff7b 100644
--- a/package/kernel/mac80211/patches/860-brcmfmac-register-wiphy-s-during-module_init.patch
+++ b/package/kernel/mac80211/patches/860-brcmfmac-register-wiphy-s-during-module_init.patch
@@ -13,7 +13,7 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/core.c
-@@ -1322,6 +1322,7 @@ int __init brcmf_core_init(void)
+@@ -1385,6 +1385,7 @@ int __init brcmf_core_init(void)
{
if (!schedule_work(&brcmf_driver_work))
return -EBUSY;
diff --git a/package/kernel/mac80211/patches/861-brcmfmac-workaround-bug-with-some-inconsistent-BSSes.patch b/package/kernel/mac80211/patches/861-brcmfmac-workaround-bug-with-some-inconsistent-BSSes.patch
index 774b333402..f9e47f89d2 100644
--- a/package/kernel/mac80211/patches/861-brcmfmac-workaround-bug-with-some-inconsistent-BSSes.patch
+++ b/package/kernel/mac80211/patches/861-brcmfmac-workaround-bug-with-some-inconsistent-BSSes.patch
@@ -10,12 +10,11 @@ Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
-@@ -656,9 +656,37 @@ static struct wireless_dev *brcmf_cfg802
- u32 *flags,
- struct vif_params *params)
- {
-+ struct net_device *dev;
+@@ -662,8 +662,36 @@ static struct wireless_dev *brcmf_cfg802
+ struct brcmf_cfg80211_info *cfg = wiphy_to_cfg(wiphy);
+ struct brcmf_pub *drvr = cfg->pub;
struct wireless_dev *wdev;
++ struct net_device *dev;
int err;
+ /*
diff --git a/package/kernel/mac80211/patches/862-brcmfmac-Disable-power-management.patch b/package/kernel/mac80211/patches/862-brcmfmac-Disable-power-management.patch
index b980f9a662..8867e67646 100644
--- a/package/kernel/mac80211/patches/862-brcmfmac-Disable-power-management.patch
+++ b/package/kernel/mac80211/patches/862-brcmfmac-Disable-power-management.patch
@@ -14,7 +14,7 @@ Signed-off-by: Phil Elwell <phil@raspberrypi.org>
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c
-@@ -2773,6 +2773,10 @@ brcmf_cfg80211_set_power_mgmt(struct wip
+@@ -2823,6 +2823,10 @@ brcmf_cfg80211_set_power_mgmt(struct wip
* preference in cfg struct to apply this to
* FW later while initializing the dongle
*/