aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMagnus Damm <damm@igel.co.jp>2009-01-21 10:14:22 -0500
committerPaul Mundt <lethal@linux-sh.org>2009-05-08 10:16:07 -0400
commit08f8cb315fdf9195b472aeb440ae65b189b151da (patch)
treef0bab5565847b51008dc2845abf532b5e752a716 /drivers
parent7ed7e0711b3ff85b3e15591081b42f2af96d584b (diff)
sh-sci: ioremap() in a single place
Handle ioremap() in sci_config_port only. Signed-off-by: Magnus Damm <damm@igel.co.jp> Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/serial/sh-sci.c54
1 files changed, 20 insertions, 34 deletions
diff --git a/drivers/serial/sh-sci.c b/drivers/serial/sh-sci.c
index 039c700ce1e..408624ae7fe 100644
--- a/drivers/serial/sh-sci.c
+++ b/drivers/serial/sh-sci.c
@@ -994,9 +994,21 @@ static void sci_config_port(struct uart_port *port, int flags)
994 994
995 port->type = s->type; 995 port->type = s->type;
996 996
997 if (port->flags & UPF_IOREMAP && !port->membase) { 997 if (port->membase)
998 return;
999
1000 if (port->flags & UPF_IOREMAP) {
998 port->membase = ioremap_nocache(port->mapbase, 0x40); 1001 port->membase = ioremap_nocache(port->mapbase, 0x40);
999 dev_err(port->dev, "can't remap port#%d\n", port->line); 1002
1003 if (IS_ERR(port->membase))
1004 dev_err(port->dev, "can't remap port#%d\n", port->line);
1005 } else {
1006 /*
1007 * For the simple (and majority of) cases where we don't
1008 * need to do any remapping, just cast the cookie
1009 * directly.
1010 */
1011 port->membase = (void __iomem *)port->mapbase;
1000 } 1012 }
1001} 1013}
1002 1014
@@ -1036,9 +1048,9 @@ static struct uart_ops sci_uart_ops = {
1036#endif 1048#endif
1037}; 1049};
1038 1050
1039static int __devinit sci_init_single(struct sci_port *sci_port, 1051static void __devinit sci_init_single(struct sci_port *sci_port,
1040 unsigned int index, 1052 unsigned int index,
1041 struct plat_sci_port *p) 1053 struct plat_sci_port *p)
1042{ 1054{
1043 sci_port->port.ops = &sci_uart_ops; 1055 sci_port->port.ops = &sci_uart_ops;
1044 sci_port->port.iotype = UPIO_MEM; 1056 sci_port->port.iotype = UPIO_MEM;
@@ -1069,22 +1081,6 @@ static int __devinit sci_init_single(struct sci_port *sci_port,
1069 init_timer(&sci_port->break_timer); 1081 init_timer(&sci_port->break_timer);
1070 1082
1071 sci_port->port.mapbase = p->mapbase; 1083 sci_port->port.mapbase = p->mapbase;
1072
1073 if (p->mapbase && !p->membase) {
1074 if (p->flags & UPF_IOREMAP) {
1075 p->membase = ioremap_nocache(p->mapbase, 0x40);
1076 if (IS_ERR(p->membase))
1077 return PTR_ERR(p->membase);
1078 } else {
1079 /*
1080 * For the simple (and majority of) cases
1081 * where we don't need to do any remapping,
1082 * just cast the cookie directly.
1083 */
1084 p->membase = (void __iomem *)p->mapbase;
1085 }
1086 }
1087
1088 sci_port->port.membase = p->membase; 1084 sci_port->port.membase = p->membase;
1089 1085
1090 sci_port->port.irq = p->irqs[SCIx_TXI_IRQ]; 1086 sci_port->port.irq = p->irqs[SCIx_TXI_IRQ];
@@ -1092,8 +1088,6 @@ static int __devinit sci_init_single(struct sci_port *sci_port,
1092 sci_port->type = sci_port->port.type = p->type; 1088 sci_port->type = sci_port->port.type = p->type;
1093 1089
1094 memcpy(&sci_port->irqs, &p->irqs, sizeof(p->irqs)); 1090 memcpy(&sci_port->irqs, &p->irqs, sizeof(p->irqs));
1095
1096 return 0;
1097} 1091}
1098 1092
1099#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE 1093#ifdef CONFIG_SERIAL_SH_SCI_CONSOLE
@@ -1163,8 +1157,7 @@ static int __init serial_console_setup(struct console *co, char *options)
1163 sci_port->clk = clk_get(NULL, "module_clk"); 1157 sci_port->clk = clk_get(NULL, "module_clk");
1164#endif 1158#endif
1165 1159
1166 if (port->flags & UPF_IOREMAP) 1160 sci_config_port(port, 0);
1167 sci_config_port(port, 0);
1168 1161
1169 if (sci_port->enable) 1162 if (sci_port->enable)
1170 sci_port->enable(port); 1163 sci_port->enable(port);
@@ -1258,18 +1251,11 @@ static int __devinit sci_probe_single(struct platform_device *dev,
1258 } 1251 }
1259 1252
1260 sciport->port.dev = &dev->dev; 1253 sciport->port.dev = &dev->dev;
1261 ret = sci_init_single(sciport, index, p); 1254 sci_init_single(sciport, index, p);
1262 if (ret)
1263 return ret;
1264 1255
1265 ret = uart_add_one_port(&sci_uart_driver, &sciport->port); 1256 ret = uart_add_one_port(&sci_uart_driver, &sciport->port);
1266 1257 if (ret)
1267 if (ret) {
1268 if (p->flags & UPF_IOREMAP)
1269 iounmap(p->membase);
1270
1271 return ret; 1258 return ret;
1272 }
1273 1259
1274 INIT_LIST_HEAD(&sciport->node); 1260 INIT_LIST_HEAD(&sciport->node);
1275 1261