Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1331596 > unrolled thread

[PATCH] usb: storage: make US_DEBUGPX print with LOGLEVEL_DEBUG

Started byVictor Dodon <printesoi@chromium.org>
First post2016-02-11 01:20 +0100
Last post2016-02-17 01:50 +0100
Articles 4 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] usb: storage: make US_DEBUGPX print with LOGLEVEL_DEBUG Victor Dodon <printesoi@chromium.org> - 2016-02-11 01:20 +0100
    Re: [PATCH] usb: storage: make US_DEBUGPX print with LOGLEVEL_DEBUG Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-02-15 02:30 +0100
      Re: [PATCH] usb: storage: make US_DEBUGPX print with LOGLEVEL_DEBUG Victor Dodon <printesoi@chromium.org> - 2016-02-17 00:50 +0100
        Re: [PATCH] usb: storage: make US_DEBUGPX print with LOGLEVEL_DEBUG Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2016-02-17 01:50 +0100

#1331596 — [PATCH] usb: storage: make US_DEBUGPX print with LOGLEVEL_DEBUG

FromVictor Dodon <printesoi@chromium.org>
Date2016-02-11 01:20 +0100
Subject[PATCH] usb: storage: make US_DEBUGPX print with LOGLEVEL_DEBUG
Message-ID<r0N9g-13L-3@gated-at.bofh.it>
The US_DEBUGPX macro uses printk without specifying a kernel log level, so
the default kernel log level is used, which may not match LOGLEVEL_DEBUG
used in usb_stor_dbg. Use printk_emit with LOGLEVEL_DEBUG instead.

Signed-off-by: Victor Dodon <printesoi@chromium.org>
---
 drivers/usb/storage/debug.h | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/storage/debug.h b/drivers/usb/storage/debug.h
index f525203..fc1c02f 100644
--- a/drivers/usb/storage/debug.h
+++ b/drivers/usb/storage/debug.h
@@ -43,6 +43,7 @@
 #define _DEBUG_H_
 
 #include <linux/kernel.h>
+#include <linux/printk.h>
 
 #define USB_STORAGE "usb-storage: "
 
@@ -53,7 +54,8 @@ void usb_stor_show_sense(const struct us_data *us, unsigned char key,
 __printf(2, 3) void usb_stor_dbg(const struct us_data *us,
 				 const char *fmt, ...);
 
-#define US_DEBUGPX(fmt, ...)	printk(fmt, ##__VA_ARGS__)
+#define US_DEBUGPX(fmt, ...)					\
+	printk_emit(0, LOGLEVEL_DEBUG, NULL, 0, fmt, ##__VA_ARGS__)
 #define US_DEBUG(x)		x
 #else
 __printf(2, 3)
@@ -64,7 +66,11 @@ static inline void _usb_stor_dbg(const struct us_data *us,
 #define usb_stor_dbg(us, fmt, ...)				\
 	do { if (0) _usb_stor_dbg(us, fmt, ##__VA_ARGS__); } while (0)
 #define US_DEBUGPX(fmt, ...)					\
-	do { if (0) printk(fmt, ##__VA_ARGS__); } while (0)
+	do {							\
+		if (0)						\
+			printk_emit(0, LOGLEVEL_DEBUG, NULL, 0,	\
+				    fmt, ##__VA_ARGS__);	\
+	} while (0)
 #define US_DEBUG(x)
 #endif
 
-- 
2.7.0.rc3.207.g0ac5344

[toc] | [next] | [standalone]


#1334087

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2016-02-15 02:30 +0100
Message-ID<r2g9c-2nN-17@gated-at.bofh.it>
In reply to#1331596
On Wed, Feb 10, 2016 at 04:13:43PM -0800, Victor Dodon wrote:
> The US_DEBUGPX macro uses printk without specifying a kernel log level, so
> the default kernel log level is used, which may not match LOGLEVEL_DEBUG
> used in usb_stor_dbg. Use printk_emit with LOGLEVEL_DEBUG instead.
> 
> Signed-off-by: Victor Dodon <printesoi@chromium.org>
> ---
>  drivers/usb/storage/debug.h | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)

Can you just get rid of US_DEBUGPX() entirely please?  It shouldn't be
needed anymore, just use usb_stor_dbg() instead.

thanks,

greg k-h

[toc] | [prev] | [next] | [standalone]


#1335934

FromVictor Dodon <printesoi@chromium.org>
Date2016-02-17 00:50 +0100
Message-ID<r2Xxw-6pr-19@gated-at.bofh.it>
In reply to#1334087
On Sun, Feb 14, 2016 at 05:20:21PM -0800, Greg Kroah-Hartman wrote:
> On Wed, Feb 10, 2016 at 04:13:43PM -0800, Victor Dodon wrote:
> > The US_DEBUGPX macro uses printk without specifying a kernel log level, so
> > the default kernel log level is used, which may not match LOGLEVEL_DEBUG
> > used in usb_stor_dbg. Use printk_emit with LOGLEVEL_DEBUG instead.
> > 
> > Signed-off-by: Victor Dodon <printesoi@chromium.org>
> > ---
> >  drivers/usb/storage/debug.h | 10 ++++++++--
> >  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> Can you just get rid of US_DEBUGPX() entirely please?  It shouldn't be
> needed anymore, just use usb_stor_dbg() instead.

Using usb_stor_dbg() instead of US_DEBUGPX() in
usb_stor_show_command() prints one byte per line with the full syslog
header, like this:

7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876236] Command
TEST_UNIT_READY (6 bytes)
7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876242] bytes: 
7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876249]  00
7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876255]  00
7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876261]  00
7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876267]  00
7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876273]  00
7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876279]  00
7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876285]

instead of the desired:

7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876236] Command
TEST_UNIT_READY (6 bytes)
7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876242] bytes: 
7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876249]  00 00 00 00 00 00

this is why I think the US_DEBUGPX() macro is still needed.

Regards,
Victor Dodon.

> 
> thanks,
> 
> greg k-h

[toc] | [prev] | [next] | [standalone]


#1335964

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2016-02-17 01:50 +0100
Message-ID<r2YtA-70p-5@gated-at.bofh.it>
In reply to#1335934
On Tue, Feb 16, 2016 at 03:45:39PM -0800, Victor Dodon wrote:
> On Sun, Feb 14, 2016 at 05:20:21PM -0800, Greg Kroah-Hartman wrote:
> > On Wed, Feb 10, 2016 at 04:13:43PM -0800, Victor Dodon wrote:
> > > The US_DEBUGPX macro uses printk without specifying a kernel log level, so
> > > the default kernel log level is used, which may not match LOGLEVEL_DEBUG
> > > used in usb_stor_dbg. Use printk_emit with LOGLEVEL_DEBUG instead.
> > > 
> > > Signed-off-by: Victor Dodon <printesoi@chromium.org>
> > > ---
> > >  drivers/usb/storage/debug.h | 10 ++++++++--
> > >  1 file changed, 8 insertions(+), 2 deletions(-)
> > 
> > Can you just get rid of US_DEBUGPX() entirely please?  It shouldn't be
> > needed anymore, just use usb_stor_dbg() instead.
> 
> Using usb_stor_dbg() instead of US_DEBUGPX() in
> usb_stor_show_command() prints one byte per line with the full syslog
> header, like this:
> 
> 7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876236] Command
> TEST_UNIT_READY (6 bytes)
> 7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876242] bytes: 
> 7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876249]  00
> 7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876255]  00
> 7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876261]  00
> 7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876267]  00
> 7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876273]  00
> 7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876279]  00
> 7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876285]
> 
> instead of the desired:
> 
> 7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876236] Command
> TEST_UNIT_READY (6 bytes)
> 7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876242] bytes: 
> 7,0,Feb 16 14:30:41,ubuntu,kernel:,[  422.876249]  00 00 00 00 00 00
> 
> this is why I think the US_DEBUGPX() macro is still needed.

Nope, fix the call to use the proper printk % modifier instead and you
will be fine.  No need to keep reinventing the wheel, we have had
support for byte streams in messages for probably over a decade now...

Nice try though :)

thanks,

greg k-h

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web