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

From: Chris Down
Date: Thu May 19 2022 - 11:08:55 EST


Greg Kroah-Hartman writes:
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.

Sorry, I'm getting more and more confused about what you're asking me to do, and less and less clear on the rationale.

Can you please clarify what "correctly cleaning up" would mean for a non-pointer `struct device'?

Is your concern that...

register_console(c)
device_initialize(c->d)
device_add(c->d)
unregister_console(c)
device_unregister(c->d) console_classdev_release(c->d)
register_console(c)
device_initialize(c->d) <-- classdev was not previously zeroed out
in console_classdev_release() and bad things may happen

If that's not the point, I could really use some clarification about what "correctly cleaning up" means for a non-pointer `struct device' :-)