netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] smc91x: fix compile error when SMC_DEBUG >= 2
@ 2014-04-19  3:47 Zi Shen Lim
  2014-04-19  4:06 ` Joe Perches
  2014-04-23  1:20 ` David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Zi Shen Lim @ 2014-04-19  3:47 UTC (permalink / raw)
  To: Nicolas Pitre; +Cc: Zi Shen Lim, netdev, linux-kernel

When SMC_DEBUG >= 2, we hit the following compilation error:

drivers/net/ethernet/smsc/smc91x.c:85:0:
drivers/net/ethernet/smsc/smc91x.c: In function ‘smc_findirq’:
drivers/net/ethernet/smsc/smc91x.c:1784:9: error: ‘dev’ undeclared (first use in this function)
  DBG(2, dev, "%s: %s\n", CARDNAME, __func__);
         ^
Fix it by passing in the appropriate netdev pointer.

Signed-off-by: Zi Shen Lim <zlim.lnx@gmail.com>
---
 drivers/net/ethernet/smsc/smc91x.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index d1b4dca..597909f 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -1781,7 +1781,7 @@ static int smc_findirq(struct smc_local *lp)
 	int timeout = 20;
 	unsigned long cookie;
 
-	DBG(2, dev, "%s: %s\n", CARDNAME, __func__);
+	DBG(2, lp->dev, "%s: %s\n", CARDNAME, __func__);
 
 	cookie = probe_irq_on();
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] smc91x: fix compile error when SMC_DEBUG >= 2
  2014-04-19  3:47 [PATCH] smc91x: fix compile error when SMC_DEBUG >= 2 Zi Shen Lim
@ 2014-04-19  4:06 ` Joe Perches
  2014-04-20  1:24   ` Zi Shen Lim
  2014-04-23  1:20 ` David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Joe Perches @ 2014-04-19  4:06 UTC (permalink / raw)
  To: Zi Shen Lim; +Cc: Nicolas Pitre, netdev, linux-kernel

On Fri, 2014-04-18 at 20:47 -0700, Zi Shen Lim wrote:
> When SMC_DEBUG >= 2, we hit the following compilation error:
> 
> drivers/net/ethernet/smsc/smc91x.c:85:0:
> drivers/net/ethernet/smsc/smc91x.c: In function ‘smc_findirq’:
> drivers/net/ethernet/smsc/smc91x.c:1784:9: error: ‘dev’ undeclared (first use in this function)
>   DBG(2, dev, "%s: %s\n", CARDNAME, __func__);
>          ^
> Fix it by passing in the appropriate netdev pointer.

Perhaps verifying the format and args in all cases
would help avoid more of these in the future.
---
 drivers/net/ethernet/smsc/smc91x.c | 25 +++++++++++++++----------
 1 file changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index d1b4dca..a8302f5 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -148,16 +148,19 @@ MODULE_ALIAS("platform:smc91x");
 #define MII_DELAY		1
 
 #if SMC_DEBUG > 0
-#define DBG(n, dev, args...)				\
-	do {						\
-		if (SMC_DEBUG >= (n))			\
-			netdev_dbg(dev, args);		\
-	} while (0)
-
-#define PRINTK(dev, args...)   netdev_info(dev, args)
+#define DBG(n, dev, fmt, ...)					\
+do {								\
+	if (SMC_DEBUG >= (n))					\
+		netdev_dbg(dev, fmt, ##__VA_ARGS__);		\
+} while (0)
+#define PRINTK(dev, fmt, ...)   netdev_info(dev, fmt, ##__VA_ARGS__)
 #else
-#define DBG(n, dev, args...)   do { } while (0)
-#define PRINTK(dev, args...)   netdev_dbg(dev, args)
+#define DBG(n, dev, fmt, ...)					\
+do {								\
+	if (0)					\
+		netdev_dbg(dev, fmt, ##__VA_ARGS__);		\
+} while (0)
+#define PRINTK(dev, fmt, ...)   netdev_dbg(dev, fmt, ##__VA_ARGS__)
 #endif
 
 #if SMC_DEBUG > 3
@@ -191,7 +194,9 @@ static void PRINT_PKT(u_char *buf, int length)
 	pr_cont("\n");
 }
 #else
-#define PRINT_PKT(x...)  do { } while (0)
+static inline void PRINT_PKT(u_char *buf, int length)
+{
+}
 #endif
 
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] smc91x: fix compile error when SMC_DEBUG >= 2
  2014-04-19  4:06 ` Joe Perches
@ 2014-04-20  1:24   ` Zi Shen Lim
  0 siblings, 0 replies; 4+ messages in thread
From: Zi Shen Lim @ 2014-04-20  1:24 UTC (permalink / raw)
  To: Joe Perches; +Cc: Nicolas Pitre, netdev, linux-kernel

Hi Joe,

On Fri, Apr 18, 2014 at 09:06:53PM -0700, Joe Perches wrote:
> On Fri, 2014-04-18 at 20:47 -0700, Zi Shen Lim wrote:
> > When SMC_DEBUG >= 2, we hit the following compilation error:
> > 
> > drivers/net/ethernet/smsc/smc91x.c:85:0:
> > drivers/net/ethernet/smsc/smc91x.c: In function ‘smc_findirq’:
> > drivers/net/ethernet/smsc/smc91x.c:1784:9: error: ‘dev’ undeclared (first use in this function)
> >   DBG(2, dev, "%s: %s\n", CARDNAME, __func__);
> >          ^
> > Fix it by passing in the appropriate netdev pointer.
> 
> Perhaps verifying the format and args in all cases
> would help avoid more of these in the future.

Sounds good. I can add it as the second patch in the series.

> ---
>  drivers/net/ethernet/smsc/smc91x.c | 25 +++++++++++++++----------
>  1 file changed, 15 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
> index d1b4dca..a8302f5 100644
> --- a/drivers/net/ethernet/smsc/smc91x.c
> +++ b/drivers/net/ethernet/smsc/smc91x.c
> @@ -148,16 +148,19 @@ MODULE_ALIAS("platform:smc91x");
>  #define MII_DELAY		1
>  
>  #if SMC_DEBUG > 0
> -#define DBG(n, dev, args...)				\
> -	do {						\
> -		if (SMC_DEBUG >= (n))			\
> -			netdev_dbg(dev, args);		\
> -	} while (0)
> -
> -#define PRINTK(dev, args...)   netdev_info(dev, args)
> +#define DBG(n, dev, fmt, ...)				\
> +do {								\
> +	if (SMC_DEBUG >= (n))					\
> +		netdev_dbg(dev, fmt, ##__VA_ARGS__);		\
> +} while (0)
> +#define PRINTK(dev, fmt, ...)   netdev_info(dev, fmt, ##__VA_ARGS__)
>  #else
> -#define DBG(n, dev, args...)   do { } while (0)
> -#define PRINTK(dev, args...)   netdev_dbg(dev, args)
> +#define DBG(n, dev, fmt, ...)				\
> +do {								\
> +	if (0)					\
> +		netdev_dbg(dev, fmt, ##__VA_ARGS__);		\
> +} while (0)
> +#define PRINTK(dev, fmt, ...)   netdev_dbg(dev, fmt, ##__VA_ARGS__)
>  #endif
>  
>  #if SMC_DEBUG > 3
> @@ -191,7 +194,9 @@ static void PRINT_PKT(u_char *buf, int length)
>  	pr_cont("\n");
>  }
>  #else
> -#define PRINT_PKT(x...)  do { } while (0)
> +static inline void PRINT_PKT(u_char *buf, int length)
> +{
> +}
>  #endif
>  

How about the following?
Ok to add your Signed-off-by as well?

Thanks.

---
 drivers/net/ethernet/smsc/smc91x.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/smsc/smc91x.c b/drivers/net/ethernet/smsc/smc91x.c
index d1b4dca..796355a 100644
--- a/drivers/net/ethernet/smsc/smc91x.c
+++ b/drivers/net/ethernet/smsc/smc91x.c
@@ -147,18 +147,19 @@ MODULE_ALIAS("platform:smc91x");
  */
 #define MII_DELAY		1
 
-#if SMC_DEBUG > 0
-#define DBG(n, dev, args...)				\
-	do {						\
-		if (SMC_DEBUG >= (n))			\
-			netdev_dbg(dev, args);		\
+#define DBG(n, dev, fmt, ...)					\
+	do {							\
+		if (SMC_DEBUG >= (n))				\
+			netdev_dbg(dev, fmt, ##__VA_ARGS__);	\
 	} while (0)
 
-#define PRINTK(dev, args...)   netdev_info(dev, args)
-#else
-#define DBG(n, dev, args...)   do { } while (0)
-#define PRINTK(dev, args...)   netdev_dbg(dev, args)
-#endif
+#define PRINTK(dev, fmt, ...)					\
+	do {							\
+		if (SMC_DEBUG > 0)				\
+			netdev_info(dev, fmt, ##__VA_ARGS__);	\
+		else						\
+			netdev_dbg(dev, fmt, ##__VA_ARGS__);	\
+	} while (0)
 
 #if SMC_DEBUG > 3
 static void PRINT_PKT(u_char *buf, int length)
@@ -191,7 +192,7 @@ static void PRINT_PKT(u_char *buf, int length)
 	pr_cont("\n");
 }
 #else
-#define PRINT_PKT(x...)  do { } while (0)
+static inline void PRINT_PKT(u_char *buf, int length) { }
 #endif
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] smc91x: fix compile error when SMC_DEBUG >= 2
  2014-04-19  3:47 [PATCH] smc91x: fix compile error when SMC_DEBUG >= 2 Zi Shen Lim
  2014-04-19  4:06 ` Joe Perches
@ 2014-04-23  1:20 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2014-04-23  1:20 UTC (permalink / raw)
  To: zlim.lnx; +Cc: nico, netdev, linux-kernel

From: Zi Shen Lim <zlim.lnx@gmail.com>
Date: Fri, 18 Apr 2014 20:47:30 -0700

> When SMC_DEBUG >= 2, we hit the following compilation error:
> 
> drivers/net/ethernet/smsc/smc91x.c:85:0:
> drivers/net/ethernet/smsc/smc91x.c: In function ‘smc_findirq’:
> drivers/net/ethernet/smsc/smc91x.c:1784:9: error: ‘dev’ undeclared (first use in this function)
>   DBG(2, dev, "%s: %s\n", CARDNAME, __func__);
>          ^
> Fix it by passing in the appropriate netdev pointer.
> 
> Signed-off-by: Zi Shen Lim <zlim.lnx@gmail.com>

Applied, thanks.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-04-23  1:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-04-19  3:47 [PATCH] smc91x: fix compile error when SMC_DEBUG >= 2 Zi Shen Lim
2014-04-19  4:06 ` Joe Perches
2014-04-20  1:24   ` Zi Shen Lim
2014-04-23  1:20 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).