summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-01-06 19:36:58 +0400
committerAlejandro Mery <amery@geeks.cl>2013-01-14 14:35:50 +0400
commitda7e20bdb2c513564d8dfcdd905d8aec93cb8113 (patch)
tree80053254f8c132d6bc1d06236d4cd015c0781a89
parent7225a3b88a68d6f34d4232a24a4cc68f3baf1b28 (diff)
downloadlinux-sunxi-da7e20bdb2c513564d8dfcdd905d8aec93cb8113.tar.xz
sunxi-serial: Get rid of sw_serial global array
There is no need for global state here, instead store the line-number we got from registering together with our other info in the sw_serial_port struct. While at it, also add proper error checking for the serial8250_register_port call. Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rwxr-xr-xdrivers/tty/serial/8250_sunxi.c15
1 files changed, 7 insertions, 8 deletions
diff --git a/drivers/tty/serial/8250_sunxi.c b/drivers/tty/serial/8250_sunxi.c
index f5bd2706dc4a..ee620ce3fdb5 100755
--- a/drivers/tty/serial/8250_sunxi.c
+++ b/drivers/tty/serial/8250_sunxi.c
@@ -35,8 +35,6 @@
#error "Unknown chip ID for Serial"
#endif
-static int sw_serial[MAX_PORTS];
-
#define UART_MSG(fmt...) printk("[uart]: "fmt)
/* Register base define */
#define UART_BASE (0x01C28000)
@@ -46,6 +44,7 @@ static int sw_serial[MAX_PORTS];
struct sw_serial_port {
int port_no;
+ int line;
int pin_num;
u32 pio_hdle;
struct clk *clk;
@@ -183,7 +182,6 @@ sw_serial_probe(struct platform_device *dev)
printk(KERN_ERR "Failed to get resource\n");
goto free_dev;
}
- platform_set_drvdata(dev, sport);
port.private_data = sport;
port.irq = sport->irq;
@@ -198,9 +196,12 @@ sw_serial_probe(struct platform_device *dev)
pr_info("serial probe %d irq %d mapbase 0x%08x\n", dev->id,
sport->irq, sport->mmres->start);
+ ret = serial8250_register_port(&port);
+ if (ret < 0)
+ goto free_dev;
- sw_serial[sport->port_no] = serial8250_register_port(&port);
-
+ sport->line = ret;
+ platform_set_drvdata(dev, sport);
return 0;
free_dev:
kfree(sport);
@@ -213,8 +214,7 @@ static int __devexit sw_serial_remove(struct platform_device *dev)
struct sw_serial_port *sport = platform_get_drvdata(dev);
UART_MSG("serial remove\n");
- serial8250_unregister_port(sw_serial[sport->port_no]);
- sw_serial[sport->port_no] = 0;
+ serial8250_unregister_port(sport->line);
sw_serial_put_resource(sport);
platform_set_drvdata(dev, NULL);
@@ -332,7 +332,6 @@ static int __init sw_serial_init(void)
int used = 0;
char uart_para[16];
- memset(sw_serial, 0, sizeof(sw_serial));
uart_used = 0;
for (i=0; i<MAX_PORTS; i++, used=0) {
sprintf(uart_para, "uart_para%d", i);