lkml.org 
[lkml]   [2014]   [Jul]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2] tty: serial: msm_serial.c: Cleaning up uninitialized variables
Date
Set reasonable initial value of some variables, in case
they do not get set to something otherwise.
And I've also added a plausibility control of the values.

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
drivers/tty/serial/msm_serial.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/tty/serial/msm_serial.c b/drivers/tty/serial/msm_serial.c
index 72000a6..4491108 100644
--- a/drivers/tty/serial/msm_serial.c
+++ b/drivers/tty/serial/msm_serial.c
@@ -917,7 +917,7 @@ static int __init msm_console_setup(struct console *co, char *options)
{
struct uart_port *port;
struct msm_port *msm_port;
- int baud, flow, bits, parity;
+ int baud = 115200, flow = 'n', bits = 8, parity = 'n';

if (unlikely(co->index >= UART_NR || co->index < 0))
return -ENXIO;
@@ -930,17 +930,21 @@ static int __init msm_console_setup(struct console *co, char *options)

msm_init_clock(port);

- if (options)
+ if (options) {
uart_parse_options(options, &baud, &parity, &bits, &flow);
+ if (baud < 300 || baud > 115200)
+ baud = 115200;
+ if (NULL == strchr("noeNOE", parity))
+ parity = 'n';
+ if (bits != 7)
+ bits = 8;
+ if (flow != 'r')
+ flow = 'n';
+ }

- bits = 8;
- parity = 'n';
- flow = 'n';
msm_write(port, UART_MR2_BITS_PER_CHAR_8 | UART_MR2_STOP_BIT_LEN_ONE,
UART_MR2); /* 8N1 */

- if (baud < 300 || baud > 115200)
- baud = 115200;
msm_set_baud_rate(port, baud);

msm_reset(port);
--
1.7.10.4


\
 
 \ /
  Last update: 2014-07-06 19:01    [W:0.038 / U:0.488 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site