|
From: Kenn H. <ke...@us...> - 2004-07-30 00:19:08
|
Update of /cvsroot/linux-vax/kernel-2.5/drivers/vax/serial In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29335/drivers/vax/serial Modified Files: ipr.c Log Message: Make the internal-processor-register serial driver a citizen of the driver-model world (as a platform driver) Index: ipr.c =================================================================== RCS file: /cvsroot/linux-vax/kernel-2.5/drivers/vax/serial/ipr.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- ipr.c 17 Apr 2004 23:54:58 -0000 1.6 +++ ipr.c 30 Jul 2004 00:18:58 -0000 1.7 @@ -17,6 +17,7 @@ */ #include <linux/config.h> +#include <linux/device.h> #include <linux/init.h> #include <linux/module.h> #include <linux/tty.h> @@ -405,15 +406,19 @@ __mtpr(old_inten_tx, PR_TXCS); } +/* + * This is really just a forward declaration for the static struct + * uart_driver defined below + */ -extern struct uart_driver iprcons_reg; +extern struct uart_driver iprcons_uart_driver; static struct console iprcons_console = { .name = "ttyS", .write = iprcons_console_write, .device = uart_console_device, .index = -1, - .data = &iprcons_reg, + .data = &iprcons_uart_driver, }; static int __init iprcons_console_init(void) @@ -431,7 +436,7 @@ #endif /* CONFIG_SERIAL_CONSOLE */ -static struct uart_driver iprcons_reg = { +static struct uart_driver iprcons_uart_driver = { .owner = THIS_MODULE, .driver_name = "ttyS", .dev_name = "ttyS", @@ -441,23 +446,47 @@ .cons = VAX_IPR_CONSOLE, }; -static int __init iprcons_init(void) +static void __exit iprcons_exit(void) +{ + /* + * FIXME: this is probably very broken. How should + * we handled module removal with the driver model + * and the serial core involved? + */ + uart_remove_one_port(&iprcons_uart_driver, &iprcons_port); + uart_unregister_driver(&iprcons_uart_driver); +} + +static int __init iprcons_probe(struct device *busdev) { int ret; printk(KERN_INFO "Serial: VAX IPR CPU console driver $Revision$\n"); - ret = uart_register_driver(&iprcons_reg); + /* + * We are a platform device. We'll only get probed if + * the per-cpu init code registers a platform device called + * 'iprcons'. So it's safe to go ahead and register the + * UART driver here without checking the presence of any + * hardware. + */ + + ret = uart_register_driver(&iprcons_uart_driver); if (ret == 0) { - uart_add_one_port(&iprcons_reg, &iprcons_port); + uart_add_one_port(&iprcons_uart_driver, &iprcons_port); } return ret; } -static void __exit iprcons_exit(void) +static struct device_driver iprcons_driver = { + .name = "iprcons", + .bus = &platform_bus_type, + .probe = iprcons_probe, +}; + +static int __init iprcons_init(void) { - uart_remove_one_port(&iprcons_reg, &iprcons_port); - uart_unregister_driver(&iprcons_reg); + return driver_register(&iprcons_driver); } module_init(iprcons_init); |