Commit 5cc898fb authored by Rafał Miłecki's avatar Rafał Miłecki Committed by Kalle Valo

brcmfmac: modify __brcmf_err() to take bus as a parameter

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: default avatarRafał Miłecki <rafal@milecki.pl>
Acked-by: default avatarArend van Spriel <arend.vanspriel@broadcom.com>
Signed-off-by: default avatarKalle Valo <kvalo@codeaurora.org>
parent 6ecde493
...@@ -350,7 +350,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp) ...@@ -350,7 +350,7 @@ int brcmf_c_preinit_dcmds(struct brcmf_if *ifp)
} }
#ifndef CONFIG_BRCM_TRACING #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; struct va_format vaf;
va_list args; va_list args;
...@@ -359,7 +359,10 @@ void __brcmf_err(const char *func, const char *fmt, ...) ...@@ -359,7 +359,10 @@ void __brcmf_err(const char *func, const char *fmt, ...)
vaf.fmt = fmt; vaf.fmt = fmt;
vaf.va = &args; 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); va_end(args);
} }
......
...@@ -45,8 +45,10 @@ ...@@ -45,8 +45,10 @@
#undef pr_fmt #undef pr_fmt
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
__printf(2, 3) struct brcmf_bus;
void __brcmf_err(const char *func, const char *fmt, ...);
__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 /* Macro for error messages. When debugging / tracing the driver all error
* messages are important to us. * messages are important to us.
*/ */
...@@ -55,7 +57,7 @@ void __brcmf_err(const char *func, const char *fmt, ...); ...@@ -55,7 +57,7 @@ void __brcmf_err(const char *func, const char *fmt, ...);
if (IS_ENABLED(CONFIG_BRCMDBG) || \ if (IS_ENABLED(CONFIG_BRCMDBG) || \
IS_ENABLED(CONFIG_BRCM_TRACING) || \ IS_ENABLED(CONFIG_BRCM_TRACING) || \
net_ratelimit()) \ net_ratelimit()) \
__brcmf_err(__func__, fmt, ##__VA_ARGS__); \ __brcmf_err(NULL, __func__, fmt, ##__VA_ARGS__);\
} while (0) } while (0)
#if defined(DEBUG) || defined(CONFIG_BRCM_TRACING) #if defined(DEBUG) || defined(CONFIG_BRCM_TRACING)
......
...@@ -14,14 +14,16 @@ ...@@ -14,14 +14,16 @@
* CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * 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 */ #include <linux/module.h> /* bug in tracepoint.h, it should include this */
#ifndef __CHECKER__ #ifndef __CHECKER__
#define CREATE_TRACE_POINTS #define CREATE_TRACE_POINTS
#include "bus.h"
#include "tracepoint.h" #include "tracepoint.h"
#include "debug.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 = { struct va_format vaf = {
.fmt = fmt, .fmt = fmt,
...@@ -30,7 +32,10 @@ void __brcmf_err(const char *func, const char *fmt, ...) ...@@ -30,7 +32,10 @@ void __brcmf_err(const char *func, const char *fmt, ...)
va_start(args, fmt); va_start(args, fmt);
vaf.va = &args; 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); trace_brcmf_err(func, &vaf);
va_end(args); va_end(args);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment