2021-02-02 07:08:09

by Masahiro Yamada

[permalink] [raw]
Subject: [PATCH 2/3] printk: hard-code CONSOLE_LOGLEVEL_MIN in printk.c

CONSOLE_LOGLEVEL_MIN is only used in kernel/printk/printk.c.

You do not need to expose it to all printk() users.

I could move it to kernel/printk/printk.c, but I do not think this
macro would contribute to the code readability or maintainability.

I just hard-coded it.

Signed-off-by: Masahiro Yamada <[email protected]>
---

include/linux/printk.h | 1 -
kernel/printk/printk.c | 2 +-
2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/include/linux/printk.h b/include/linux/printk.h
index fd34b3aa2f90..ceaf0486c01c 100644
--- a/include/linux/printk.h
+++ b/include/linux/printk.h
@@ -48,7 +48,6 @@ static inline const char *printk_skip_headers(const char *buffer)

/* We show everything that is MORE important than this.. */
#define CONSOLE_LOGLEVEL_SILENT 0 /* Mum's the word */
-#define CONSOLE_LOGLEVEL_MIN 1 /* Minimum loglevel we let people use */
#define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */
#define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 92b93340905c..7b50298d52e3 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -63,7 +63,7 @@
int console_printk[4] = {
CONFIG_CONSOLE_LOGLEVEL_DEFAULT, /* console_loglevel */
CONFIG_MESSAGE_LOGLEVEL_DEFAULT, /* default_message_loglevel */
- CONSOLE_LOGLEVEL_MIN, /* minimum_console_loglevel */
+ 1, /* minimum_console_loglevel */
CONFIG_CONSOLE_LOGLEVEL_DEFAULT, /* default_console_loglevel */
};
EXPORT_SYMBOL_GPL(console_printk);
--
2.27.0


2021-02-02 10:08:58

by Sergey Senozhatsky

[permalink] [raw]
Subject: Re: [PATCH 2/3] printk: hard-code CONSOLE_LOGLEVEL_MIN in printk.c

On (21/02/02 16:02), Masahiro Yamada wrote:
> include/linux/printk.h | 1 -
> kernel/printk/printk.c | 2 +-
> 2 files changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/include/linux/printk.h b/include/linux/printk.h
> index fd34b3aa2f90..ceaf0486c01c 100644
> --- a/include/linux/printk.h
> +++ b/include/linux/printk.h
> @@ -48,7 +48,6 @@ static inline const char *printk_skip_headers(const char *buffer)
>
> /* We show everything that is MORE important than this.. */
> #define CONSOLE_LOGLEVEL_SILENT 0 /* Mum's the word */
> -#define CONSOLE_LOGLEVEL_MIN 1 /* Minimum loglevel we let people use */
> #define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */
> #define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */
>
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 92b93340905c..7b50298d52e3 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -63,7 +63,7 @@
> int console_printk[4] = {
> CONFIG_CONSOLE_LOGLEVEL_DEFAULT, /* console_loglevel */
> CONFIG_MESSAGE_LOGLEVEL_DEFAULT, /* default_message_loglevel */
> - CONSOLE_LOGLEVEL_MIN, /* minimum_console_loglevel */
> + 1, /* minimum_console_loglevel */
> CONFIG_CONSOLE_LOGLEVEL_DEFAULT, /* default_console_loglevel */

I personally don't think that this improves code readability.

-ss

2021-02-02 21:30:53

by Joe Perches

[permalink] [raw]
Subject: Re: [PATCH 2/3] printk: hard-code CONSOLE_LOGLEVEL_MIN in printk.c

On Tue, 2021-02-02 at 19:06 +0900, Sergey Senozhatsky wrote:
> On (21/02/02 16:02), Masahiro Yamada wrote:
> > ?include/linux/printk.h | 1 -
> > ?kernel/printk/printk.c | 2 +-
> > ?2 files changed, 1 insertion(+), 2 deletions(-)
> >
> > diff --git a/include/linux/printk.h b/include/linux/printk.h
> > index fd34b3aa2f90..ceaf0486c01c 100644
> > --- a/include/linux/printk.h
> > +++ b/include/linux/printk.h
> > @@ -48,7 +48,6 @@ static inline const char *printk_skip_headers(const char *buffer)
> > ?
> >
> > ?/* We show everything that is MORE important than this.. */
> > ?#define CONSOLE_LOGLEVEL_SILENT 0 /* Mum's the word */
> > -#define CONSOLE_LOGLEVEL_MIN 1 /* Minimum loglevel we let people use */
> > ?#define CONSOLE_LOGLEVEL_DEBUG 10 /* issue debug messages */
> > ?#define CONSOLE_LOGLEVEL_MOTORMOUTH 15 /* You can't shut this one up */
> > ?
> >
> > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
[]
> > @@ -63,7 +63,7 @@
> > ?int console_printk[4] = {
> > ? CONFIG_CONSOLE_LOGLEVEL_DEFAULT, /* console_loglevel */
> > ? CONFIG_MESSAGE_LOGLEVEL_DEFAULT, /* default_message_loglevel */
> > - CONSOLE_LOGLEVEL_MIN, /* minimum_console_loglevel */
> > + 1, /* minimum_console_loglevel */
> > ? CONFIG_CONSOLE_LOGLEVEL_DEFAULT, /* default_console_loglevel */
>
> I personally don't think that this improves code readability.

Nor maintainability.