diff options
author | Vitaly Bordug <vbordug@ru.mvista.com> | 2006-04-29 15:06:00 -0400 |
---|---|---|
committer | Paul Mackerras <paulus@samba.org> | 2006-05-03 09:06:44 -0400 |
commit | 6e1976961c9bd9a3dc368139fab1883961efc879 (patch) | |
tree | 5fd5795260072c15be659349462abad4fe8ef7e3 /drivers/serial | |
parent | 61f5657c50341198ff05e375e6f1fc0476556562 (diff) |
[PATCH] ppc32 CPM_UART: fixes and improvements
A number of small issues are fixed, and added the header file, missed from the
original series. With this, driver should be pretty stable as tested among
both platform-device-driven and "old way" boards. Also added missing GPL
statement , and updated year field on existing ones to reflect
code update.
Signed-off-by: Vitaly Bordug <vbordug@ru.mvista.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'drivers/serial')
-rw-r--r-- | drivers/serial/cpm_uart/cpm_uart.h | 19 | ||||
-rw-r--r-- | drivers/serial/cpm_uart/cpm_uart_core.c | 31 | ||||
-rw-r--r-- | drivers/serial/cpm_uart/cpm_uart_cpm1.c | 2 | ||||
-rw-r--r-- | drivers/serial/cpm_uart/cpm_uart_cpm2.c | 2 |
4 files changed, 43 insertions, 11 deletions
diff --git a/drivers/serial/cpm_uart/cpm_uart.h b/drivers/serial/cpm_uart/cpm_uart.h index aa5eb7ddeda9..3b35cb779539 100644 --- a/drivers/serial/cpm_uart/cpm_uart.h +++ b/drivers/serial/cpm_uart/cpm_uart.h | |||
@@ -5,6 +5,13 @@ | |||
5 | * | 5 | * |
6 | * Copyright (C) 2004 Freescale Semiconductor, Inc. | 6 | * Copyright (C) 2004 Freescale Semiconductor, Inc. |
7 | * | 7 | * |
8 | * 2006 (c) MontaVista Software, Inc. | ||
9 | * Vitaly Bordug <vbordug@ru.mvista.com> | ||
10 | * | ||
11 | * This file is licensed under the terms of the GNU General Public License | ||
12 | * version 2. This program is licensed "as is" without any warranty of any | ||
13 | * kind, whether express or implied. | ||
14 | * | ||
8 | */ | 15 | */ |
9 | #ifndef CPM_UART_H | 16 | #ifndef CPM_UART_H |
10 | #define CPM_UART_H | 17 | #define CPM_UART_H |
@@ -101,12 +108,13 @@ static inline unsigned long cpu2cpm_addr(void* addr, struct uart_cpm_port *pinfo | |||
101 | int offset; | 108 | int offset; |
102 | u32 val = (u32)addr; | 109 | u32 val = (u32)addr; |
103 | /* sane check */ | 110 | /* sane check */ |
104 | if ((val >= (u32)pinfo->mem_addr) && | 111 | if (likely((val >= (u32)pinfo->mem_addr)) && |
105 | (val<((u32)pinfo->mem_addr + pinfo->mem_size))) { | 112 | (val<((u32)pinfo->mem_addr + pinfo->mem_size))) { |
106 | offset = val - (u32)pinfo->mem_addr; | 113 | offset = val - (u32)pinfo->mem_addr; |
107 | return pinfo->dma_addr+offset; | 114 | return pinfo->dma_addr+offset; |
108 | } | 115 | } |
109 | printk("%s(): address %x to translate out of range!\n", __FUNCTION__, val); | 116 | /* something nasty happened */ |
117 | BUG(); | ||
110 | return 0; | 118 | return 0; |
111 | } | 119 | } |
112 | 120 | ||
@@ -115,12 +123,13 @@ static inline void *cpm2cpu_addr(unsigned long addr, struct uart_cpm_port *pinfo | |||
115 | int offset; | 123 | int offset; |
116 | u32 val = addr; | 124 | u32 val = addr; |
117 | /* sane check */ | 125 | /* sane check */ |
118 | if ((val >= pinfo->dma_addr) && | 126 | if (likely((val >= pinfo->dma_addr) && |
119 | (val<(pinfo->dma_addr + pinfo->mem_size))) { | 127 | (val<(pinfo->dma_addr + pinfo->mem_size)))) { |
120 | offset = val - (u32)pinfo->dma_addr; | 128 | offset = val - (u32)pinfo->dma_addr; |
121 | return (void*)(pinfo->mem_addr+offset); | 129 | return (void*)(pinfo->mem_addr+offset); |
122 | } | 130 | } |
123 | printk("%s(): address %x to translate out of range!\n", __FUNCTION__, val); | 131 | /* something nasty happened */ |
132 | BUG(); | ||
124 | return 0; | 133 | return 0; |
125 | } | 134 | } |
126 | 135 | ||
diff --git a/drivers/serial/cpm_uart/cpm_uart_core.c b/drivers/serial/cpm_uart/cpm_uart_core.c index b9d1185df20c..969f94900431 100644 --- a/drivers/serial/cpm_uart/cpm_uart_core.c +++ b/drivers/serial/cpm_uart/cpm_uart_core.c | |||
@@ -12,7 +12,8 @@ | |||
12 | * | 12 | * |
13 | * Copyright (C) 2004 Freescale Semiconductor, Inc. | 13 | * Copyright (C) 2004 Freescale Semiconductor, Inc. |
14 | * (C) 2004 Intracom, S.A. | 14 | * (C) 2004 Intracom, S.A. |
15 | * (C) 2005 MontaVista Software, Inc. by Vitaly Bordug <vbordug@ru.mvista.com> | 15 | * (C) 2005-2006 MontaVista Software, Inc. |
16 | * Vitaly Bordug <vbordug@ru.mvista.com> | ||
16 | * | 17 | * |
17 | * This program is free software; you can redistribute it and/or modify | 18 | * This program is free software; you can redistribute it and/or modify |
18 | * it under the terms of the GNU General Public License as published by | 19 | * it under the terms of the GNU General Public License as published by |
@@ -81,7 +82,7 @@ early_uart_get_pdev(int index) | |||
81 | } | 82 | } |
82 | 83 | ||
83 | 84 | ||
84 | void cpm_uart_count(void) | 85 | static void cpm_uart_count(void) |
85 | { | 86 | { |
86 | cpm_uart_nr = 0; | 87 | cpm_uart_nr = 0; |
87 | #ifdef CONFIG_SERIAL_CPM_SMC1 | 88 | #ifdef CONFIG_SERIAL_CPM_SMC1 |
@@ -104,6 +105,21 @@ void cpm_uart_count(void) | |||
104 | #endif | 105 | #endif |
105 | } | 106 | } |
106 | 107 | ||
108 | /* Get UART number by its id */ | ||
109 | static int cpm_uart_id2nr(int id) | ||
110 | { | ||
111 | int i; | ||
112 | if (id < UART_NR) { | ||
113 | for (i=0; i<UART_NR; i++) { | ||
114 | if (cpm_uart_port_map[i] == id) | ||
115 | return i; | ||
116 | } | ||
117 | } | ||
118 | |||
119 | /* not found or invalid argument */ | ||
120 | return -1; | ||
121 | } | ||
122 | |||
107 | /* | 123 | /* |
108 | * Check, if transmit buffers are processed | 124 | * Check, if transmit buffers are processed |
109 | */ | 125 | */ |
@@ -1012,7 +1028,11 @@ int cpm_uart_drv_get_platform_data(struct platform_device *pdev, int is_con) | |||
1012 | int line; | 1028 | int line; |
1013 | u32 mem, pram; | 1029 | u32 mem, pram; |
1014 | 1030 | ||
1015 | for (line=0; line<UART_NR && cpm_uart_port_map[line]!=pdata->fs_no; line++); | 1031 | line = cpm_uart_id2nr(idx); |
1032 | if(line < 0) { | ||
1033 | printk(KERN_ERR"%s(): port %d is not registered", __FUNCTION__, idx); | ||
1034 | return -1; | ||
1035 | } | ||
1016 | 1036 | ||
1017 | pinfo = (struct uart_cpm_port *) &cpm_uart_ports[idx]; | 1037 | pinfo = (struct uart_cpm_port *) &cpm_uart_ports[idx]; |
1018 | 1038 | ||
@@ -1245,8 +1265,7 @@ static int cpm_uart_drv_probe(struct device *dev) | |||
1245 | } | 1265 | } |
1246 | 1266 | ||
1247 | pdata = pdev->dev.platform_data; | 1267 | pdata = pdev->dev.platform_data; |
1248 | pr_debug("cpm_uart_drv_probe: Adding CPM UART %d\n", | 1268 | pr_debug("cpm_uart_drv_probe: Adding CPM UART %d\n", cpm_uart_id2nr(pdata->fs_no)); |
1249 | cpm_uart_port_map[pdata->fs_no]); | ||
1250 | 1269 | ||
1251 | if ((ret = cpm_uart_drv_get_platform_data(pdev, 0))) | 1270 | if ((ret = cpm_uart_drv_get_platform_data(pdev, 0))) |
1252 | return ret; | 1271 | return ret; |
@@ -1265,7 +1284,7 @@ static int cpm_uart_drv_remove(struct device *dev) | |||
1265 | struct fs_uart_platform_info *pdata = pdev->dev.platform_data; | 1284 | struct fs_uart_platform_info *pdata = pdev->dev.platform_data; |
1266 | 1285 | ||
1267 | pr_debug("cpm_uart_drv_remove: Removing CPM UART %d\n", | 1286 | pr_debug("cpm_uart_drv_remove: Removing CPM UART %d\n", |
1268 | cpm_uart_port_map[pdata->fs_no]); | 1287 | cpm_uart_id2nr(pdata->fs_no)); |
1269 | 1288 | ||
1270 | uart_remove_one_port(&cpm_reg, &cpm_uart_ports[pdata->fs_no].port); | 1289 | uart_remove_one_port(&cpm_reg, &cpm_uart_ports[pdata->fs_no].port); |
1271 | return 0; | 1290 | return 0; |
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm1.c b/drivers/serial/cpm_uart/cpm_uart_cpm1.c index a5a30622637a..17406a05ce1f 100644 --- a/drivers/serial/cpm_uart/cpm_uart_cpm1.c +++ b/drivers/serial/cpm_uart/cpm_uart_cpm1.c | |||
@@ -8,6 +8,8 @@ | |||
8 | * | 8 | * |
9 | * Copyright (C) 2004 Freescale Semiconductor, Inc. | 9 | * Copyright (C) 2004 Freescale Semiconductor, Inc. |
10 | * (C) 2004 Intracom, S.A. | 10 | * (C) 2004 Intracom, S.A. |
11 | * (C) 2006 MontaVista Software, Inc. | ||
12 | * Vitaly Bordug <vbordug@ru.mvista.com> | ||
11 | * | 13 | * |
12 | * This program is free software; you can redistribute it and/or modify | 14 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License as published by | 15 | * it under the terms of the GNU General Public License as published by |
diff --git a/drivers/serial/cpm_uart/cpm_uart_cpm2.c b/drivers/serial/cpm_uart/cpm_uart_cpm2.c index 7c6b07aeea92..4b2de08f46d0 100644 --- a/drivers/serial/cpm_uart/cpm_uart_cpm2.c +++ b/drivers/serial/cpm_uart/cpm_uart_cpm2.c | |||
@@ -8,6 +8,8 @@ | |||
8 | * | 8 | * |
9 | * Copyright (C) 2004 Freescale Semiconductor, Inc. | 9 | * Copyright (C) 2004 Freescale Semiconductor, Inc. |
10 | * (C) 2004 Intracom, S.A. | 10 | * (C) 2004 Intracom, S.A. |
11 | * (C) 2006 MontaVista Software, Inc. | ||
12 | * Vitaly Bordug <vbordug@ru.mvista.com> | ||
11 | * | 13 | * |
12 | * This program is free software; you can redistribute it and/or modify | 14 | * This program is free software; you can redistribute it and/or modify |
13 | * it under the terms of the GNU General Public License as published by | 15 | * it under the terms of the GNU General Public License as published by |