From d070a4344d28190dbdfeaebc416681a569e2cded Mon Sep 17 00:00:00 2001 From: Russell King Date: Tue, 29 Jun 2004 05:16:30 -0700 Subject: [PATCH] Provide console_device() [This patch series has also been separately sent to the architecture maintainers] Add console_device() to return the console tty driver structure and the index. Acquire the console lock while scanning the list of console drivers to protect us against console driver list manipulations. Signed-off-by: Russell King Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- kernel/printk.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'kernel') diff --git a/kernel/printk.c b/kernel/printk.c index 9e34ce41beb6..224c37c0e28d 100644 --- a/kernel/printk.c +++ b/kernel/printk.c @@ -683,6 +683,26 @@ void console_unblank(void) } EXPORT_SYMBOL(console_unblank); +/* + * Return the console tty driver structure and its associated index + */ +struct tty_driver *console_device(int *index) +{ + struct console *c; + struct tty_driver *driver = NULL; + + acquire_console_sem(); + for (c = console_drivers; c != NULL; c = c->next) { + if (!c->device) + continue; + driver = c->device(c, index); + if (driver) + break; + } + release_console_sem(); + return driver; +} + /* * The console driver calls this routine during kernel initialization * to register the console printing procedure with printk() and to -- cgit v1.2.3