diff mbox

[5/6] ath6kl: convert ath6kl_dbg() and ath6kl_dbg_dump() into functions

Message ID 20120104230950.32306.21264.stgit@x201
State Not Applicable, archived
Delegated to: David Miller
Headers show

Commit Message

Kalle Valo Jan. 4, 2012, 11:09 p.m. UTC
That way it's possible to not export debug_mask outside the upcoming
ath6kl_core.ko and that makes it easier to ath6kl_core.ko in the
following patch.

Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
---
 drivers/net/wireless/ath/ath6kl/debug.c |   24 ++++++++++++++++++++++++
 drivers/net/wireless/ath/ath6kl/debug.h |   25 ++++---------------------
 2 files changed, 28 insertions(+), 21 deletions(-)


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Joe Perches Jan. 4, 2012, 11:41 p.m. UTC | #1
On Thu, 2012-01-05 at 01:09 +0200, Kalle Valo wrote:
> That way it's possible to not export debug_mask outside the upcoming
> ath6kl_core.ko and that makes it easier to ath6kl_core.ko in the
> following patch.
[]
> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
[]
> diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c
[]
> +void ath6kl_dbg(enum ATH6K_DEBUG_MASK mask, const char *fmt, ...)
> +{
> +	va_list args;
> +
> +	if (!(debug_mask & mask))
> +		return;
> +
> +	va_start(args, fmt);
> +	ath6kl_printk(KERN_DEBUG, fmt, &args);

Passing a va_list as an argument?
I believe this doesn't work.
I think you'll need to add and use:

	struct va_format vaf;

	vaf.fmt = fmt;
	vaf.va = &args;

	ath6kl_printk(KERN_DEBUG, "%pV", &vaf);



--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Kalle Valo Jan. 5, 2012, 8:22 a.m. UTC | #2
On 01/05/2012 01:41 AM, Joe Perches wrote:
> On Thu, 2012-01-05 at 01:09 +0200, Kalle Valo wrote:
>> That way it's possible to not export debug_mask outside the upcoming
>> ath6kl_core.ko and that makes it easier to ath6kl_core.ko in the
>> following patch.
> []
>> Signed-off-by: Kalle Valo <kvalo@qca.qualcomm.com>
> []
>> diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c
> []
>> +void ath6kl_dbg(enum ATH6K_DEBUG_MASK mask, const char *fmt, ...)
>> +{
>> +	va_list args;
>> +
>> +	if (!(debug_mask & mask))
>> +		return;
>> +
>> +	va_start(args, fmt);
>> +	ath6kl_printk(KERN_DEBUG, fmt, &args);
> 
> Passing a va_list as an argument?
> I believe this doesn't work.

Doh, I was supposed to test this but then I forgot in the hurry. Thanks
for pointing this out. I will send v2 which will fix this.

Kalle
--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
David Laight Jan. 5, 2012, 10:41 a.m. UTC | #3
> > +	va_start(args, fmt);
> > +	ath6kl_printk(KERN_DEBUG, fmt, &args);
> 
> Passing a va_list as an argument?
> I believe this doesn't work.
> I think you'll need to add and use:

Passing a va_list certainly does work - vprintf() etc.
What is problematical is taking the address of a va_list.

The likely problem is a 'levels of indirection' one
because, when va_list needs to be a struct (very
likely when arguments are passed in registers),
it is often declared as as array type.

	David


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Joe Perches Jan. 5, 2012, 4:30 p.m. UTC | #4
On Thu, 2012-01-05 at 10:41 +0000, David Laight wrote:
> > > +	va_start(args, fmt);
> > > +	ath6kl_printk(KERN_DEBUG, fmt, &args);
> > Passing a va_list as an argument?
> > I believe this doesn't work.
> > I think you'll need to add and use:
> Passing a va_list certainly does work - vprintf() etc.
> What is problematical is taking the address of a va_list.

Nope.  This referred to this specific instance.
Taking the address of a va_list works fine.
Look at the provide example.


--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/net/wireless/ath/ath6kl/debug.c b/drivers/net/wireless/ath/ath6kl/debug.c
index 0d77129..1d216e9 100644
--- a/drivers/net/wireless/ath/ath6kl/debug.c
+++ b/drivers/net/wireless/ath/ath6kl/debug.c
@@ -57,6 +57,30 @@  int ath6kl_printk(const char *level, const char *fmt, ...)
 
 #ifdef CONFIG_ATH6KL_DEBUG
 
+void ath6kl_dbg(enum ATH6K_DEBUG_MASK mask, const char *fmt, ...)
+{
+	va_list args;
+
+	if (!(debug_mask & mask))
+		return;
+
+	va_start(args, fmt);
+	ath6kl_printk(KERN_DEBUG, fmt, &args);
+	va_end(args);
+}
+
+void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask,
+		     const char *msg, const char *prefix,
+		     const void *buf, size_t len)
+{
+	if (debug_mask & mask) {
+		if (msg)
+			ath6kl_dbg(mask, "%s\n", msg);
+
+		print_hex_dump_bytes(prefix, DUMP_PREFIX_OFFSET, buf, len);
+	}
+}
+
 #define REG_OUTPUT_LEN_PER_LINE	25
 #define REGTYPE_STR_LEN		100
 
diff --git a/drivers/net/wireless/ath/ath6kl/debug.h b/drivers/net/wireless/ath/ath6kl/debug.h
index cb21d91..c4be6e5 100644
--- a/drivers/net/wireless/ath/ath6kl/debug.h
+++ b/drivers/net/wireless/ath/ath6kl/debug.h
@@ -61,28 +61,11 @@  enum ath6kl_war {
 };
 
 #ifdef CONFIG_ATH6KL_DEBUG
-#define ath6kl_dbg(mask, fmt, ...)					\
-	({								\
-	 int rtn;							\
-	 if (debug_mask & mask)						\
-		rtn = ath6kl_printk(KERN_DEBUG, fmt, ##__VA_ARGS__);	\
-	 else								\
-		rtn = 0;						\
-									\
-	 rtn;								\
-	 })
 
-static inline void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask,
-				   const char *msg, const char *prefix,
-				   const void *buf, size_t len)
-{
-	if (debug_mask & mask) {
-		if (msg)
-			ath6kl_dbg(mask, "%s\n", msg);
-
-		print_hex_dump_bytes(prefix, DUMP_PREFIX_OFFSET, buf, len);
-	}
-}
+void ath6kl_dbg(enum ATH6K_DEBUG_MASK mask, const char *fmt, ...);
+void ath6kl_dbg_dump(enum ATH6K_DEBUG_MASK mask,
+		     const char *msg, const char *prefix,
+		     const void *buf, size_t len);
 
 void ath6kl_dump_registers(struct ath6kl_device *dev,
 			   struct ath6kl_irq_proc_registers *irq_proc_reg,