diff mbox series

[V2,1/2] brcmfmac: modify __brcmf_err() to take bus as a parameter

Message ID 20190115121217.18276-1-zajec5@gmail.com (mailing list archive)
State Changes Requested
Delegated to: Kalle Valo
Headers show
Series [V2,1/2] brcmfmac: modify __brcmf_err() to take bus as a parameter | expand

Commit Message

Rafał Miłecki Jan. 15, 2019, 12:12 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

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>
---
V2: Add missing #include <linux/device.h>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c | 7 +++++--
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h  | 8 +++++---
 .../net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c | 8 ++++++--
 3 files changed, 16 insertions(+), 7 deletions(-)

Comments

Kalle Valo Feb. 1, 2019, 12:14 p.m. UTC | #1
Rafał Miłecki wrote:

> From: Rafał Miłecki <rafal@milecki.pl>
> 
> 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>

Fails to build for me:

drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c: In function 'brcmf_pcie_pm_enter_D3':
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1948:20: error: redeclaration of 'bus' with no linkage
  struct brcmf_bus *bus;
                    ^~~
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1946:20: note: previous definition of 'bus' was here
  struct brcmf_bus *bus = dev_get_drvdata(dev);
                    ^~~
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c: In function 'brcmf_pcie_pm_leave_D3':
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1978:20: error: redeclaration of 'bus' with no linkage
  struct brcmf_bus *bus;
                    ^~~
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1976:20: note: previous definition of 'bus' was here
  struct brcmf_bus *bus = dev_get_drvdata(dev);
                    ^~~
make[6]: *** [drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.o] Error 1
make[6]: *** Waiting for unfinished jobs....
drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c: In function '__brcmf_err':
drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c:35:15: error: dereferencing pointer to incomplete type 'struct brcmf_bus'
   dev_err(bus->dev, "%s: %pV", func, &vaf);
               ^~
make[6]: *** [drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.o] Error 1
make[5]: *** [drivers/net/wireless/broadcom/brcm80211/brcmfmac] Error 2
make[4]: *** [drivers/net/wireless/broadcom/brcm80211] Error 2
make[3]: *** [drivers/net/wireless/broadcom] Error 2
make[2]: *** [drivers/net/wireless] Error 2
make[1]: *** [drivers/net] Error 2
make: *** [drivers] Error 2

2 patches set to Changes Requested.

10764369 [V2,1/2] brcmfmac: modify __brcmf_err() to take bus as a parameter
10764371 [V2,2/2] brcmfmac: pass bus to the __brcmf_err() in pcie.c
Rafał Miłecki Feb. 1, 2019, 3:51 p.m. UTC | #2
On 01.02.2019 13:14, Kalle Valo wrote:
> Rafał Miłecki wrote:
> 
>> From: Rafał Miłecki <rafal@milecki.pl>
>>
>> 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>
> 
> Fails to build for me:
> 
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c: In function 'brcmf_pcie_pm_enter_D3':
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1948:20: error: redeclaration of 'bus' with no linkage
>    struct brcmf_bus *bus;
>                      ^~~
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1946:20: note: previous definition of 'bus' was here
>    struct brcmf_bus *bus = dev_get_drvdata(dev);
>                      ^~~
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c: In function 'brcmf_pcie_pm_leave_D3':
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1978:20: error: redeclaration of 'bus' with no linkage
>    struct brcmf_bus *bus;
>                      ^~~
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1976:20: note: previous definition of 'bus' was here
>    struct brcmf_bus *bus = dev_get_drvdata(dev);
>                      ^~~
> make[6]: *** [drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.o] Error 1
> make[6]: *** Waiting for unfinished jobs....
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c: In function '__brcmf_err':
> drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c:35:15: error: dereferencing pointer to incomplete type 'struct brcmf_bus'
>     dev_err(bus->dev, "%s: %pV", func, &vaf);
>                 ^~

I have no idea why my gcc didn't complain. Sorry. I'll send V3.

$ mips-suse-linux-gcc -v
Using built-in specs.
COLLECT_GCC=mips-suse-linux-gcc
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/mips-suse-linux/8/lto-wrapper
Target: mips-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64 --enable-languages=c,c++ --enable-checking=release --disable-werror --with-gxx-include-dir=/usr/include/c++/8 --enable-ssp --disable-libssp --disable-libvtv --disable-libmpx --disable-cet --disable-libcc1 --disable-plugin --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux' --with-slibdir=/lib64 --with-system-zlib 
--enable-libstdcxx-allocator=new --disable-libstdcxx-pch --enable-version-specific-runtime-libs --with-gcc-major-version-only --enable-linker-build-id --enable-linux-futex --enable-gnu-indirect-function --program-suffix=-8 --program-prefix=mips-suse-linux- --target=mips-suse-linux --disable-nls --with-sysroot=/usr/mips-suse-linux --with-build-sysroot=/usr/mips-suse-linux --with-build-time-tools=/usr/mips-suse-linux/bin --build=x86_64-suse-linux --host=x86_64-suse-linux
Thread model: posix
gcc version 8.2.1 20181108 [gcc-8-branch revision 265914] (SUSE Linux)
Kalle Valo Feb. 1, 2019, 4:46 p.m. UTC | #3
Rafał Miłecki <rafal@milecki.pl> writes:

> On 01.02.2019 13:14, Kalle Valo wrote:
>> Rafał Miłecki wrote:
>>
>>> From: Rafał Miłecki <rafal@milecki.pl>
>>>
>>> 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>
>>
>> Fails to build for me:
>>
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c: In function 'brcmf_pcie_pm_enter_D3':
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1948:20: error: redeclaration of 'bus' with no linkage
>>    struct brcmf_bus *bus;
>>                      ^~~
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1946:20: note: previous definition of 'bus' was here
>>    struct brcmf_bus *bus = dev_get_drvdata(dev);
>>                      ^~~
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c: In function 'brcmf_pcie_pm_leave_D3':
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1978:20: error: redeclaration of 'bus' with no linkage
>>    struct brcmf_bus *bus;
>>                      ^~~
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c:1976:20: note: previous definition of 'bus' was here
>>    struct brcmf_bus *bus = dev_get_drvdata(dev);
>>                      ^~~
>> make[6]: *** [drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.o] Error 1
>> make[6]: *** Waiting for unfinished jobs....
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c: In function '__brcmf_err':
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c:35:15: error: dereferencing pointer to incomplete type 'struct brcmf_bus'
>>     dev_err(bus->dev, "%s: %pV", func, &vaf);
>>                 ^~
>
> I have no idea why my gcc didn't complain. Sorry.

No worries. Oddly kbuild bot didn't notice it either so the problem
might be on my end as well.

> I'll send V3.
>
> $ mips-suse-linux-gcc -v
> Using built-in specs.
> COLLECT_GCC=mips-suse-linux-gcc
> COLLECT_LTO_WRAPPER=/usr/lib64/gcc/mips-suse-linux/8/lto-wrapper
> Target: mips-suse-linux
> Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
> --mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
> --enable-languages=c,c++ --enable-checking=release --disable-werror
> --with-gxx-include-dir=/usr/include/c++/8 --enable-ssp
> --disable-libssp --disable-libvtv --disable-libmpx --disable-cet
> --disable-libcc1 --disable-plugin
> --with-bugurl=http://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
> --with-slibdir=/lib64 --with-system-zlib
> --enable-libstdcxx-allocator=new --disable-libstdcxx-pch
> --enable-version-specific-runtime-libs --with-gcc-major-version-only
> --enable-linker-build-id --enable-linux-futex
> --enable-gnu-indirect-function --program-suffix=-8
> --program-prefix=mips-suse-linux- --target=mips-suse-linux
> --disable-nls --with-sysroot=/usr/mips-suse-linux
> --with-build-sysroot=/usr/mips-suse-linux
> --with-build-time-tools=/usr/mips-suse-linux/bin
> --build=x86_64-suse-linux --host=x86_64-suse-linux
> Thread model: posix
> gcc version 8.2.1 20181108 [gcc-8-branch revision 265914] (SUSE Linux)

Mine is:

Using built-in specs.
COLLECT_GCC=/opt/cross/gcc-7.3.0-nolibc/x86_64-linux/bin/x86_64-linux-x86_64-linux-gcc
COLLECT_LTO_WRAPPER=/opt/cross/gcc-7.3.0-nolibc/x86_64-linux/bin/../libexec/gcc/x86_64-linux/7.3.0/lto-wrapper
Target: x86_64-linux
Configured with: /home/arnd/git/gcc/configure --target=x86_64-linux --enable-targets=all --prefix=/opt/crosstool/gcc-7.3.0-nolibc/x86_64-linux --enable-languages=c --without-headers --disable-bootstrap --disable-nls --disable-threads --disable-shared --disable-libmudflap --disable-libssp --disable-libgomp --disable-decimal-float --disable-libquadmath --disable-libatomic --disable-libcc1 --disable-libmpx --enable-checking=release
Thread model: single
diff mbox series

Patch

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
index 0ce1d8174e6d..c62009a06617 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/common.c
@@ -350,7 +350,7 @@  int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
 }
 
 #ifndef CONFIG_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;
@@ -359,7 +359,10 @@  void __brcmf_err(const char *func, const char *fmt, ...)
 
 	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);
 }
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/debug.h
index cfed0626bf5a..b499f90d94f6 100644
--- 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 char *fmt, ...);
 		if (IS_ENABLED(CONFIG_BRCMDBG) ||			\
 		    IS_ENABLED(CONFIG_BRCM_TRACING) ||			\
 		    net_ratelimit())					\
-			__brcmf_err(__func__, fmt, ##__VA_ARGS__);	\
+			__brcmf_err(NULL, __func__, fmt, ##__VA_ARGS__);\
 	} while (0)
 
 #if defined(DEBUG) || defined(CONFIG_BRCM_TRACING)
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c
index fe6755944b7b..9c440a5e1c5f 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/tracepoint.c
@@ -14,6 +14,7 @@ 
  * 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__
@@ -21,7 +22,7 @@ 
 #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 +31,10 @@  void __brcmf_err(const char *func, const char *fmt, ...)
 
 	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);
 }