Commit 7389d0dc authored by Russell King's avatar Russell King

[SERIAL] Make SA11x0 serial driver build.

Update the SA11x0 serial driver for the removal of system devices
from the driver model.  The driver becomes a platform device driver.
The driver is now known to the driver model and resource subsytems
as "sa11x0-uart".
parent 003e16bb
...@@ -398,7 +398,7 @@ static int sa1100_startup(struct uart_port *port) ...@@ -398,7 +398,7 @@ static int sa1100_startup(struct uart_port *port)
* Allocate the IRQ * Allocate the IRQ
*/ */
retval = request_irq(sport->port.irq, sa1100_int, 0, retval = request_irq(sport->port.irq, sa1100_int, 0,
"serial_sa1100", sport); "sa11x0-uart", sport);
if (retval) if (retval)
return retval; return retval;
...@@ -568,7 +568,7 @@ static int sa1100_request_port(struct uart_port *port) ...@@ -568,7 +568,7 @@ static int sa1100_request_port(struct uart_port *port)
struct sa1100_port *sport = (struct sa1100_port *)port; struct sa1100_port *sport = (struct sa1100_port *)port;
return request_mem_region(sport->port.mapbase, UART_PORT_SIZE, return request_mem_region(sport->port.mapbase, UART_PORT_SIZE,
"serial_sa1100") != NULL ? 0 : -EBUSY; "sa11x0-uart") != NULL ? 0 : -EBUSY;
} }
/* /*
...@@ -858,71 +858,91 @@ static struct uart_driver sa1100_reg = { ...@@ -858,71 +858,91 @@ static struct uart_driver sa1100_reg = {
.cons = SA1100_CONSOLE, .cons = SA1100_CONSOLE,
}; };
static int sa1100_serial_suspend(struct device *dev, u32 state, u32 level) static int sa1100_serial_suspend(struct device *_dev, u32 state, u32 level)
{ {
int i; struct sa1100_port *sport = dev_get_drvdata(_dev);
for (i = 0; i < NR_PORTS; i++) if (sport)
uart_suspend_port(&sa1100_reg, &sa1100_ports[i].port, level); uart_suspend_port(&sa1100_reg, &sport->port, level);
return 0; return 0;
} }
static int sa1100_serial_resume(struct device *dev, u32 level) static int sa1100_serial_resume(struct device *_dev, u32 level)
{ {
struct sa1100_port *sport = dev_get_drvdata(_dev);
if (sport)
uart_resume_port(&sa1100_reg, &sport->port, level);
return 0;
}
static int sa1100_serial_probe(struct device *_dev)
{
struct platform_device *dev = to_platform_device(_dev);
struct resource *res = dev->resource;
int i; int i;
for (i = 0; i < NR_PORTS; i++) for (i = 0; i < dev->num_resources; i++, res++)
uart_resume_port(&sa1100_reg, &sa1100_ports[i].port, level); if (res->flags & IORESOURCE_MEM)
break;
if (i < dev->num_resources) {
for (i = 0; i < NR_PORTS; i++) {
if (sa1100_ports[i].port.mapbase != res->start)
continue;
uart_add_one_port(&sa1100_reg, &sa1100_ports[i].port);
dev_set_drvdata(_dev, &sa1100_ports[i]);
break;
}
}
return 0;
}
static int sa1100_serial_remove(struct device *_dev)
{
struct sa1100_port *sport = dev_get_drvdata(_dev);
dev_set_drvdata(_dev, NULL);
if (sport)
uart_remove_one_port(&sa1100_reg, &sport->port);
return 0; return 0;
} }
static struct device_driver sa11x0_serial_driver = { static struct device_driver sa11x0_serial_driver = {
.name = "sa11x0_serial", .name = "sa11x0-uart",
.bus = &system_bus_type, .bus = &platform_bus_type,
.probe = sa1100_serial_probe,
.remove = sa1100_serial_remove,
.suspend = sa1100_serial_suspend, .suspend = sa1100_serial_suspend,
.resume = sa1100_serial_resume, .resume = sa1100_serial_resume,
}; };
/*
* This "device" covers _all_ ISA 8250-compatible serial devices.
*/
static struct sys_device sa11x0_serial_devs = {
.name = "sa11x0_serial",
.id = 0,
.dev = {
.driver = &sa11x0_serial_driver,
},
};
static int __init sa1100_serial_init(void) static int __init sa1100_serial_init(void)
{ {
int ret; int ret;
printk(KERN_INFO "Serial: SA11x0 driver $Revision: 1.50 $\n"); printk(KERN_INFO "Serial: SA11x0 driver $Revision: 1.50 $\n");
driver_register(&sa11x0_serial_driver);
sys_device_register(&sa11x0_serial_devs);
sa1100_init_ports(); sa1100_init_ports();
ret = uart_register_driver(&sa1100_reg); ret = uart_register_driver(&sa1100_reg);
if (ret == 0) { if (ret == 0) {
int i; ret = driver_register(&sa11x0_serial_driver);
if (ret)
for (i = 0; i < NR_PORTS; i++) uart_unregister_driver(&sa1100_reg);
uart_add_one_port(&sa1100_reg, &sa1100_ports[i].port);
} }
return ret; return ret;
} }
static void __exit sa1100_serial_exit(void) static void __exit sa1100_serial_exit(void)
{ {
int i; driver_unregister(&sa11x0_serial_driver);
for (i = 0; i < NR_PORTS; i++)
uart_remove_one_port(&sa1100_reg, &sa1100_ports[i].port);
uart_unregister_driver(&sa1100_reg); uart_unregister_driver(&sa1100_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