aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/tty
diff options
context:
space:
mode:
authorDengChao <chao.deng@linaro.org>2015-11-12 08:45:47 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-12-13 22:59:48 -0500
commit3ac4ae4736d404c436edf3b2ecfd941368f9e247 (patch)
treed2e19b6ea8ddd077d3fb7ad6c2b749061df41faa /drivers/tty
parent29647c483658f1e3d2e0ec9ad64ebd23edeecdf5 (diff)
serial:bfin-uart:Remove 'struct timeval'
The bfin-uart code uses real time with struct timeval. This will cause problems on 32-bit architectures in 2038 when time_t overflows. Since the code just needs delta value of time, it is not necessary to record them in real time. This patch changes the code to use the monotonic time instead, replaces struct timeval and do_gettimeofday() with u64 and ktime_get_ns(). Signed-off-by: DengChao <chao.deng@linaro.org> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/tty')
-rw-r--r--drivers/tty/serial/bfin_uart.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/drivers/tty/serial/bfin_uart.c b/drivers/tty/serial/bfin_uart.c
index ae3cf94b146b..293ecbb00684 100644
--- a/drivers/tty/serial/bfin_uart.c
+++ b/drivers/tty/serial/bfin_uart.c
@@ -213,7 +213,7 @@ static void bfin_serial_stop_rx(struct uart_port *port)
213static void bfin_serial_rx_chars(struct bfin_serial_port *uart) 213static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
214{ 214{
215 unsigned int status, ch, flg; 215 unsigned int status, ch, flg;
216 static struct timeval anomaly_start = { .tv_sec = 0 }; 216 static u64 anomaly_start;
217 217
218 status = UART_GET_LSR(uart); 218 status = UART_GET_LSR(uart);
219 UART_CLEAR_LSR(uart); 219 UART_CLEAR_LSR(uart);
@@ -246,27 +246,24 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
246 * character time +/- some percent. So 1.5 sounds good. All other 246 * character time +/- some percent. So 1.5 sounds good. All other
247 * Blackfin families operate properly. Woo. 247 * Blackfin families operate properly. Woo.
248 */ 248 */
249 if (anomaly_start.tv_sec) { 249 if (anomaly_start > 0) {
250 struct timeval curr; 250 u64 curr, nsecs, threshold_ns;
251 suseconds_t usecs;
252 251
253 if ((~ch & (~ch + 1)) & 0xff) 252 if ((~ch & (~ch + 1)) & 0xff)
254 goto known_good_char; 253 goto known_good_char;
255 254
256 do_gettimeofday(&curr); 255 curr = ktime_get_ns();
257 if (curr.tv_sec - anomaly_start.tv_sec > 1) 256 nsecs = curr - anomaly_start;
257 if (nsecs >> 32)
258 goto known_good_char; 258 goto known_good_char;
259 259
260 usecs = 0; 260 threshold_ns = UART_GET_ANOMALY_THRESHOLD(uart)
261 if (curr.tv_sec != anomaly_start.tv_sec) 261 * NSEC_PER_USEC;
262 usecs += USEC_PER_SEC; 262 if (nsecs > threshold_ns)
263 usecs += curr.tv_usec - anomaly_start.tv_usec;
264
265 if (usecs > UART_GET_ANOMALY_THRESHOLD(uart))
266 goto known_good_char; 263 goto known_good_char;
267 264
268 if (ch) 265 if (ch)
269 anomaly_start.tv_sec = 0; 266 anomaly_start = 0;
270 else 267 else
271 anomaly_start = curr; 268 anomaly_start = curr;
272 269
@@ -274,14 +271,14 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
274 271
275 known_good_char: 272 known_good_char:
276 status &= ~BI; 273 status &= ~BI;
277 anomaly_start.tv_sec = 0; 274 anomaly_start = 0;
278 } 275 }
279 } 276 }
280 277
281 if (status & BI) { 278 if (status & BI) {
282 if (ANOMALY_05000363) 279 if (ANOMALY_05000363)
283 if (bfin_revid() < 5) 280 if (bfin_revid() < 5)
284 do_gettimeofday(&anomaly_start); 281 anomaly_start = ktime_get_ns();
285 uart->port.icount.brk++; 282 uart->port.icount.brk++;
286 if (uart_handle_break(&uart->port)) 283 if (uart_handle_break(&uart->port))
287 goto ignore_char; 284 goto ignore_char;