mirror of https://gitee.com/openkylin/linux.git
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>
This commit is contained in:
parent
29647c4836
commit
3ac4ae4736
|
@ -213,7 +213,7 @@ static void bfin_serial_stop_rx(struct uart_port *port)
|
||||||
static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
|
static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
|
||||||
{
|
{
|
||||||
unsigned int status, ch, flg;
|
unsigned int status, ch, flg;
|
||||||
static struct timeval anomaly_start = { .tv_sec = 0 };
|
static u64 anomaly_start;
|
||||||
|
|
||||||
status = UART_GET_LSR(uart);
|
status = UART_GET_LSR(uart);
|
||||||
UART_CLEAR_LSR(uart);
|
UART_CLEAR_LSR(uart);
|
||||||
|
@ -246,27 +246,24 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
|
||||||
* character time +/- some percent. So 1.5 sounds good. All other
|
* character time +/- some percent. So 1.5 sounds good. All other
|
||||||
* Blackfin families operate properly. Woo.
|
* Blackfin families operate properly. Woo.
|
||||||
*/
|
*/
|
||||||
if (anomaly_start.tv_sec) {
|
if (anomaly_start > 0) {
|
||||||
struct timeval curr;
|
u64 curr, nsecs, threshold_ns;
|
||||||
suseconds_t usecs;
|
|
||||||
|
|
||||||
if ((~ch & (~ch + 1)) & 0xff)
|
if ((~ch & (~ch + 1)) & 0xff)
|
||||||
goto known_good_char;
|
goto known_good_char;
|
||||||
|
|
||||||
do_gettimeofday(&curr);
|
curr = ktime_get_ns();
|
||||||
if (curr.tv_sec - anomaly_start.tv_sec > 1)
|
nsecs = curr - anomaly_start;
|
||||||
|
if (nsecs >> 32)
|
||||||
goto known_good_char;
|
goto known_good_char;
|
||||||
|
|
||||||
usecs = 0;
|
threshold_ns = UART_GET_ANOMALY_THRESHOLD(uart)
|
||||||
if (curr.tv_sec != anomaly_start.tv_sec)
|
* NSEC_PER_USEC;
|
||||||
usecs += USEC_PER_SEC;
|
if (nsecs > threshold_ns)
|
||||||
usecs += curr.tv_usec - anomaly_start.tv_usec;
|
|
||||||
|
|
||||||
if (usecs > UART_GET_ANOMALY_THRESHOLD(uart))
|
|
||||||
goto known_good_char;
|
goto known_good_char;
|
||||||
|
|
||||||
if (ch)
|
if (ch)
|
||||||
anomaly_start.tv_sec = 0;
|
anomaly_start = 0;
|
||||||
else
|
else
|
||||||
anomaly_start = curr;
|
anomaly_start = curr;
|
||||||
|
|
||||||
|
@ -274,14 +271,14 @@ static void bfin_serial_rx_chars(struct bfin_serial_port *uart)
|
||||||
|
|
||||||
known_good_char:
|
known_good_char:
|
||||||
status &= ~BI;
|
status &= ~BI;
|
||||||
anomaly_start.tv_sec = 0;
|
anomaly_start = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (status & BI) {
|
if (status & BI) {
|
||||||
if (ANOMALY_05000363)
|
if (ANOMALY_05000363)
|
||||||
if (bfin_revid() < 5)
|
if (bfin_revid() < 5)
|
||||||
do_gettimeofday(&anomaly_start);
|
anomaly_start = ktime_get_ns();
|
||||||
uart->port.icount.brk++;
|
uart->port.icount.brk++;
|
||||||
if (uart_handle_break(&uart->port))
|
if (uart_handle_break(&uart->port))
|
||||||
goto ignore_char;
|
goto ignore_char;
|
||||||
|
|
Loading…
Reference in New Issue