Commit fcc32e8d authored by Russell King's avatar Russell King

[SERIAL] 8250: Add platform device for ISA 8250-compatible devices.

Add a platform device for ISA 8250-compatible serial devices listed
in the table in include/asm-*/serial.h.  Arrange for unregistered
serial devices to be owned by this device.

This enables power management for ISA 8250 devices, and starts to
opens the way for architectures to dynamically provide their own
lists of 8250 devices via platform device(s).
parent e5e0d098
......@@ -2216,6 +2216,12 @@ static struct device_driver serial8250_isa_driver = {
.resume = serial8250_resume,
};
/*
* This "device" covers _all_ ISA 8250-compatible serial devices listed
* in the table in include/asm-*/serial.h
*/
static struct platform_device *serial8250_isa_devs;
/*
* serial8250_register_port and serial8250_unregister_port allows for
* 16x50 serial ports to be configured at run-time, to support PCMCIA
......@@ -2336,7 +2342,7 @@ void serial8250_unregister_port(int line)
uart_remove_one_port(&serial8250_reg, &uart->port);
uart->port.flags &= ~UPF_BOOT_AUTOCONF;
uart->port.type = PORT_UNKNOWN;
uart->port.dev = NULL;
uart->port.dev = &serial8250_isa_devs->dev;
uart_add_one_port(&serial8250_reg, &uart->port);
up(&serial_sem);
}
......@@ -2357,14 +2363,20 @@ static int __init serial8250_init(void)
if (ret)
goto out;
serial8250_register_ports(&serial8250_reg, NULL);
ret = driver_register(&serial8250_isa_driver);
if (ret)
serial8250_isa_devs = platform_device_register_simple("serial8250",
-1, NULL, 0);
if (IS_ERR(serial8250_isa_devs)) {
ret = PTR_ERR(serial8250_isa_devs);
goto unreg;
}
goto out;
serial8250_register_ports(&serial8250_reg, &serial8250_isa_devs->dev);
ret = driver_register(&serial8250_isa_driver);
if (ret == 0)
goto out;
platform_device_unregister(serial8250_isa_devs);
unreg:
uart_unregister_driver(&serial8250_reg);
out:
......@@ -2377,8 +2389,13 @@ static void __exit serial8250_exit(void)
driver_unregister(&serial8250_isa_driver);
for (i = 0; i < UART_NR; i++)
uart_remove_one_port(&serial8250_reg, &serial8250_ports[i].port);
for (i = 0; i < UART_NR; i++) {
struct uart_8250_port *up = &serial8250_ports[i];
if (up->port.dev == &serial8250_isa_devs->dev)
uart_remove_one_port(&serial8250_reg, &up->port);
}
platform_device_unregister(serial8250_isa_devs);
uart_unregister_driver(&serial8250_reg);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment