linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ttyprintk: make the printk log level configurable
@ 2018-08-21 17:28 Peter Korsgaard
  2018-09-07  7:50 ` Peter Korsgaard
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Korsgaard @ 2018-08-21 17:28 UTC (permalink / raw)
  To: Arnd Bergmann, Greg Kroah-Hartman, linux-kernel; +Cc: Peter Korsgaard

For some use cases it is handy to use a different printk log level than the
default (info) for the messages written to ttyprintk, so add a Kconfig
option similar to what we have for default console loglevel.

Signed-off-by: Peter Korsgaard <peter@korsgaard.com>
---
 drivers/char/Kconfig     | 8 ++++++++
 drivers/char/ttyprintk.c | 4 +++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
index ce277ee0a28a..14a7f023f20b 100644
--- a/drivers/char/Kconfig
+++ b/drivers/char/Kconfig
@@ -66,6 +66,14 @@ config TTY_PRINTK
 
 	  If unsure, say N.
 
+config TTY_PRINTK_LEVEL
+	depends on TTY_PRINTK
+	int "ttyprintk log level (1-7)"
+	range 1 7
+	default "6"
+	help
+	  Printk log level to use for ttyprintk messages.
+
 config PRINTER
 	tristate "Parallel printer support"
 	depends on PARPORT
diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
index 67549ce88cc9..22fbd483b5dc 100644
--- a/drivers/char/ttyprintk.c
+++ b/drivers/char/ttyprintk.c
@@ -37,6 +37,8 @@ static struct ttyprintk_port tpk_port;
  */
 #define TPK_STR_SIZE 508 /* should be bigger then max expected line length */
 #define TPK_MAX_ROOM 4096 /* we could assume 4K for instance */
+#define TPK_PREFIX KERN_SOH __stringify(CONFIG_TTY_PRINTK_LEVEL) " [U]"
+
 static int tpk_curr;
 
 static char tpk_buffer[TPK_STR_SIZE + 4];
@@ -45,7 +47,7 @@ static void tpk_flush(void)
 {
 	if (tpk_curr > 0) {
 		tpk_buffer[tpk_curr] = '\0';
-		pr_info("[U] %s\n", tpk_buffer);
+		printk(TPK_PREFIX " %s\n", tpk_buffer);
 		tpk_curr = 0;
 	}
 }
-- 
2.11.0


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

* Re: [PATCH] ttyprintk: make the printk log level configurable
  2018-08-21 17:28 [PATCH] ttyprintk: make the printk log level configurable Peter Korsgaard
@ 2018-09-07  7:50 ` Peter Korsgaard
  2018-09-07  8:03   ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Peter Korsgaard @ 2018-09-07  7:50 UTC (permalink / raw)
  To: Arnd Bergmann, Greg Kroah-Hartman, linux-kernel

On Tue, Aug 21, 2018 at 7:28 PM Peter Korsgaard <peter@korsgaard.com> wrote:
>
> For some use cases it is handy to use a different printk log level than the
> default (info) for the messages written to ttyprintk, so add a Kconfig
> option similar to what we have for default console loglevel.

Ping? Feedback, comments?

> diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
> index ce277ee0a28a..14a7f023f20b 100644
> --- a/drivers/char/Kconfig
> +++ b/drivers/char/Kconfig
> @@ -66,6 +66,14 @@ config TTY_PRINTK
>
>           If unsure, say N.
>
> +config TTY_PRINTK_LEVEL
> +       depends on TTY_PRINTK
> +       int "ttyprintk log level (1-7)"
> +       range 1 7
> +       default "6"
> +       help
> +         Printk log level to use for ttyprintk messages.
> +
>  config PRINTER
>         tristate "Parallel printer support"
>         depends on PARPORT
> diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
> index 67549ce88cc9..22fbd483b5dc 100644
> --- a/drivers/char/ttyprintk.c
> +++ b/drivers/char/ttyprintk.c
> @@ -37,6 +37,8 @@ static struct ttyprintk_port tpk_port;
>   */
>  #define TPK_STR_SIZE 508 /* should be bigger then max expected line length */
>  #define TPK_MAX_ROOM 4096 /* we could assume 4K for instance */
> +#define TPK_PREFIX KERN_SOH __stringify(CONFIG_TTY_PRINTK_LEVEL) " [U]"
> +
>  static int tpk_curr;
>
>  static char tpk_buffer[TPK_STR_SIZE + 4];
> @@ -45,7 +47,7 @@ static void tpk_flush(void)
>  {
>         if (tpk_curr > 0) {
>                 tpk_buffer[tpk_curr] = '\0';
> -               pr_info("[U] %s\n", tpk_buffer);
> +               printk(TPK_PREFIX " %s\n", tpk_buffer);
>                 tpk_curr = 0;
>         }
>  }
> --
> 2.11.0
>

-- 
Bye, Peter Korsgaard

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

* Re: [PATCH] ttyprintk: make the printk log level configurable
  2018-09-07  7:50 ` Peter Korsgaard
@ 2018-09-07  8:03   ` Joe Perches
  2018-09-07  8:11     ` Peter Korsgaard
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2018-09-07  8:03 UTC (permalink / raw)
  To: Peter Korsgaard, Arnd Bergmann, Greg Kroah-Hartman, linux-kernel

On Fri, 2018-09-07 at 09:50 +0200, Peter Korsgaard wrote:
> On Tue, Aug 21, 2018 at 7:28 PM Peter Korsgaard <peter@korsgaard.com> wrote:
> > 
> > For some use cases it is handy to use a different printk log level than the
> > default (info) for the messages written to ttyprintk, so add a Kconfig
> > option similar to what we have for default console loglevel.
> 
> Ping? Feedback, comments?

I think it is moving "[U]" into TPK_LEVEL is an
unnecessary and a tad obfuscating change.

This also adds a leading space for unknown reasons
after the KERN_SOH <level>.

> > diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
> > index ce277ee0a28a..14a7f023f20b 100644
> > --- a/drivers/char/Kconfig
> > +++ b/drivers/char/Kconfig
> > @@ -66,6 +66,14 @@ config TTY_PRINTK
> > 
> >           If unsure, say N.
> > 
> > +config TTY_PRINTK_LEVEL
> > +       depends on TTY_PRINTK
> > +       int "ttyprintk log level (1-7)"
> > +       range 1 7
> > +       default "6"
> > +       help
> > +         Printk log level to use for ttyprintk messages.
> > +
> >  config PRINTER
> >         tristate "Parallel printer support"
> >         depends on PARPORT
> > diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
> > index 67549ce88cc9..22fbd483b5dc 100644
> > --- a/drivers/char/ttyprintk.c
> > +++ b/drivers/char/ttyprintk.c
> > @@ -37,6 +37,8 @@ static struct ttyprintk_port tpk_port;
> >   */
> >  #define TPK_STR_SIZE 508 /* should be bigger then max expected line length */
> >  #define TPK_MAX_ROOM 4096 /* we could assume 4K for instance */
> > +#define TPK_PREFIX KERN_SOH __stringify(CONFIG_TTY_PRINTK_LEVEL) " [U]"

I think this should be

#define TPK_PREFIX KERN_SOH __stringify(CONFIG_TTY_PRINTK_LEVEL)

> > +
> >  static int tpk_curr;
> > 
> >  static char tpk_buffer[TPK_STR_SIZE + 4];
> > @@ -45,7 +47,7 @@ static void tpk_flush(void)
> >  {
> >         if (tpk_curr > 0) {
> >                 tpk_buffer[tpk_curr] = '\0';
> > -               pr_info("[U] %s\n", tpk_buffer);
> > +               printk(TPK_PREFIX " %s\n", tpk_buffer);

and this

		printk(TPK_PREFIX "[U] %s\n", tpk_buffer);

> >                 tpk_curr = 0;
> >         }
> >  }
> > --
> > 2.11.0
> > 
> 
> 

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

* Re: [PATCH] ttyprintk: make the printk log level configurable
  2018-09-07  8:03   ` Joe Perches
@ 2018-09-07  8:11     ` Peter Korsgaard
  0 siblings, 0 replies; 4+ messages in thread
From: Peter Korsgaard @ 2018-09-07  8:11 UTC (permalink / raw)
  To: Joe Perches; +Cc: Arnd Bergmann, Greg Kroah-Hartman, linux-kernel

>>>>> "Joe" == Joe Perches <joe@perches.com> writes:

 > On Fri, 2018-09-07 at 09:50 +0200, Peter Korsgaard wrote:
 >> On Tue, Aug 21, 2018 at 7:28 PM Peter Korsgaard <peter@korsgaard.com> wrote:
 >> > 
 >> > For some use cases it is handy to use a different printk log level than the
 >> > default (info) for the messages written to ttyprintk, so add a Kconfig
 >> > option similar to what we have for default console loglevel.
 >> 
 >> Ping? Feedback, comments?

 > I think it is moving "[U]" into TPK_LEVEL is an
 > unnecessary and a tad obfuscating change.

It is arguably part of the prefix, but OK - I have no problem leaving it
in the printk line.

 > This also adds a leading space for unknown reasons
 > after the KERN_SOH <level>.

True. I'll fix that and send a v2 - Thanks.

 >> > diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig
 >> > index ce277ee0a28a..14a7f023f20b 100644
 >> > --- a/drivers/char/Kconfig
 >> > +++ b/drivers/char/Kconfig
 >> > @@ -66,6 +66,14 @@ config TTY_PRINTK
 >> > 
 >> >           If unsure, say N.
 >> > 
 >> > +config TTY_PRINTK_LEVEL
 >> > +       depends on TTY_PRINTK
 >> > +       int "ttyprintk log level (1-7)"
 >> > +       range 1 7
 >> > +       default "6"
 >> > +       help
 >> > +         Printk log level to use for ttyprintk messages.
 >> > +
 >> >  config PRINTER
 >> >         tristate "Parallel printer support"
 >> >         depends on PARPORT
 >> > diff --git a/drivers/char/ttyprintk.c b/drivers/char/ttyprintk.c
 >> > index 67549ce88cc9..22fbd483b5dc 100644
 >> > --- a/drivers/char/ttyprintk.c
 >> > +++ b/drivers/char/ttyprintk.c
 >> > @@ -37,6 +37,8 @@ static struct ttyprintk_port tpk_port;
 >> >   */
 >> >  #define TPK_STR_SIZE 508 /* should be bigger then max expected line length */
 >> >  #define TPK_MAX_ROOM 4096 /* we could assume 4K for instance */
 >> > +#define TPK_PREFIX KERN_SOH __stringify(CONFIG_TTY_PRINTK_LEVEL) " [U]"

 > I think this should be

 > #define TPK_PREFIX KERN_SOH __stringify(CONFIG_TTY_PRINTK_LEVEL)

 >> > +
 >> >  static int tpk_curr;
 >> > 
 >> >  static char tpk_buffer[TPK_STR_SIZE + 4];
 >> > @@ -45,7 +47,7 @@ static void tpk_flush(void)
 >> >  {
 >> >         if (tpk_curr > 0) {
 >> >                 tpk_buffer[tpk_curr] = '\0';
 >> > -               pr_info("[U] %s\n", tpk_buffer);
 >> > +               printk(TPK_PREFIX " %s\n", tpk_buffer);

 > and this

 > 		printk(TPK_PREFIX "[U] %s\n", tpk_buffer);

 >> >                 tpk_curr = 0;
 >> >         }
 >> >  }
 >> > --
 >> > 2.11.0
 >> > 
 >> 
 >> 

-- 
Bye, Peter Korsgaard

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

end of thread, other threads:[~2018-09-07  8:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-21 17:28 [PATCH] ttyprintk: make the printk log level configurable Peter Korsgaard
2018-09-07  7:50 ` Peter Korsgaard
2018-09-07  8:03   ` Joe Perches
2018-09-07  8:11     ` Peter Korsgaard

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).