lkml.org 
[lkml]   [2020]   [Jan]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectRe: [PATCH v4 5/6] console: Introduce ->exit() callback
On (20/01/30 17:25), Andy Shevchenko wrote:
[..]
> diff --git a/include/linux/console.h b/include/linux/console.h
> index f33016b3a401..54759ad0c36b 100644
> --- a/include/linux/console.h
> +++ b/include/linux/console.h
> @@ -148,6 +148,7 @@ struct console {
> struct tty_driver *(*device)(struct console *, int *);
> void (*unblank)(void);
> int (*setup)(struct console *, char *);
> + void (*exit)(struct console *);

Should console ->exit() be able to return an error code?

> int (*match)(struct console *, char *name, int idx, char *options);
> short flags;
> short index;
> diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> index 932345e6cd71..0117d4d92a8e 100644
> --- a/kernel/printk/printk.c
> +++ b/kernel/printk/printk.c
> @@ -2850,6 +2850,10 @@ int unregister_console(struct console *console)
> console->flags &= ~CON_ENABLED;
> console_unlock();
> console_sysfs_notify();
> +
> + if (!res && console->exit)
> + console->exit(console);
> +
> return res;
> }

I would probably push it a bit further (I posted this snippet in another
thread). If console is not on the list then there is nothing for us to do
and sysfs notify is pointless.

---

diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
index 0117d4d92a8e..7116e421210b 100644
--- a/kernel/printk/printk.c
+++ b/kernel/printk/printk.c
@@ -2837,7 +2837,13 @@ int unregister_console(struct console *console)
}
}

- if (!res && (console->flags & CON_EXTENDED))
+ if (res) {
+ console->flags &= ~CON_ENABLED;
+ console_unlock();
+ return res;
+ }
+
+ if (console->flags & CON_EXTENDED)
nr_ext_console_drivers--;

/*
@@ -2851,7 +2857,7 @@ int unregister_console(struct console *console)
console_unlock();
console_sysfs_notify();

- if (!res && console->exit)
+ if (console->exit)
console->exit(console);

return res;
\
 
 \ /
  Last update: 2020-01-31 02:32    [W:0.067 / U:0.392 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site