Re: [RFC PATCH] printk: console: Allow each console to have its own loglevel

From: Greg Kroah-Hartman
Date: Thu May 19 2022 - 10:35:52 EST


On Thu, May 19, 2022 at 03:12:19PM +0100, Chris Down wrote:
> Greg Kroah-Hartman writes:
> > The two stanzas in my reply do NOT refer to the same thing.
> >
> > The first one is for the device that is assigned to the class. That
> > must be freed and properly reference counted and handled as that is a
> > dynamic object that can come and go as people add and remove consoles.
>
> Ah, I see. So to be clear, this change would fix what you're concerned
> about, right? :-)
>
> If so I'll do this in v2. Thanks!
>
> ---
>
> diff --git include/linux/console.h include/linux/console.h
> index ce5ba405285a..408dd86be8eb 100644
> --- include/linux/console.h
> +++ include/linux/console.h
> @@ -156,12 +156,6 @@ static inline int con_debug_leave(void)
> */
> #define CON_LOGLEVEL (128) /* Level set locally for this console */
> -/*
> - * Console has active class device, so may have active readers/writers from
> - * /sys/class hierarchy.
> - */
> -#define CON_CLASSDEV_ACTIVE (256)
> -
> struct console {
> char name[16];
> void (*write)(struct console *, const char *, unsigned);
> @@ -179,9 +173,11 @@ struct console {
> void *data;
> struct console *next;
> int level;
> - struct device classdev;
> + struct device *classdev;

Ick, no, keep the real structure here. It can properly handle the
reference counting for the object. Just correctly clean up in the
release function, not anywhere else.

thanks,

greg k-h