batman-adv: use original printk in bat_printk

Message ID 20100210023641.GA2112@Linus-Debian (mailing list archive)
State Superseded, archived
Headers

Commit Message

Linus Lüssing Feb. 10, 2010, 2:36 a.m. UTC
  bat_printk is calling a printk which got previously
substituted because of the define in compat.h.
This patch removes the define for the scope of
bat_printk.c.

Signed-off-by: Linus Lüssing <linus.luessing@web.de>
---
  

Comments

Marek Lindner Feb. 10, 2010, 10:47 a.m. UTC | #1
On Wednesday 10 February 2010 10:36:41 Linus Lüssing wrote:
> bat_printk is calling a printk which got previously
> substituted because of the define in compat.h.
> This patch removes the define for the scope of
> bat_printk.c.

After seeing your patch I understand the issue. We redefine printk() to 
bat_printk() which works fine for all functions except for bat_printk() itself.
I think your approach seems to be a solution although we don't need to define 
printk at the end again, do we ?

Regards,
Marek
  
Andrew Lunn Feb. 10, 2010, 1:11 p.m. UTC | #2
On Wed, Feb 10, 2010 at 06:47:49PM +0800, Marek Lindner wrote:
> On Wednesday 10 February 2010 10:36:41 Linus L??ssing wrote:
> > bat_printk is calling a printk which got previously
> > substituted because of the define in compat.h.
> > This patch removes the define for the scope of
> > bat_printk.c.
> 
> After seeing your patch I understand the issue. We redefine printk()
> to bat_printk() which works fine for all functions except for
> bat_printk() itself.  I think your approach seems to be a solution
> although we don't need to define printk at the end again, do we ?

I think Simon added compat.h when he reworked the patch. My original
version did not use it to avoid this recursion problem. Linus's
solution looks O.K, but as you said it is not necessary to redefine it
at the end. I also don't see why the ___printk is needed.

While we are at it, please also remove the "foo:". That i do claim
responsibility for. I developed the patch on a kernel which is %pM
capable and i wanted to be sure it was using bat_printk and not the
native printk when testing. So i put in the foo. It never got removed
:-(

   Andrew
  

Patch

diff --git a/batman-adv-kernelland/bat_printk.c b/batman-adv-kernelland/bat_printk.c
index a55eff3..556620a 100644
--- a/batman-adv-kernelland/bat_printk.c
+++ b/batman-adv-kernelland/bat_printk.c
@@ -35,6 +35,13 @@ 
 /* Works only for digits and letters, but small and fast */
 #define TOLOWER(x) ((x) | 0x20)
 
+/* We don't want to recursively call bat_printk here
+   because of the previous define in compat.h */
+#ifdef printk
+#define ___printk printk
+#undef printk
+#endif
+
 static int skip_atoi(const char **s)
 {
 	int i = 0;
@@ -853,3 +860,8 @@  asmlinkage int bat_printk(const char *fmt, ...)
 
 	return printk("foo:%s", buf);
 }
+
+#ifdef ___printk
+#define printk ___printk
+#undef ___printk
+#endif