From 1a2d9b30e31e2b7ed0acb64bfb2290911e3c9efb Mon Sep 17 00:00:00 2001 From: Stefan Roese Date: Tue, 12 Oct 2010 09:39:45 +0200 Subject: [PATCH] ns16550: Add WATCHDOG_RESET to putc for short watchdog timeout boards Call watchdog_reset() upon newline. This is done here in putc since the environment code uses a single puts() to print the complete envrironment upon "printenv". So we can't put this watchdog call in puts(). This is needed for boards with a very short watchdog timeout, like the lwmon5 with a 100ms timeout. Without this patch this board resets in the commands with long outputs, like "printenv" or "fdt print". Note that the image size is not increased with this patch when CONFIG_HW_WATCHDOG or CONFIG_WATCHDOG are not defined since the compiler optimizes this additional code away. Signed-off-by: Stefan Roese Fix typo in comment. Signed-off-by: Wolfgang Denk --- drivers/serial/ns16550.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/serial/ns16550.c b/drivers/serial/ns16550.c index 7e833fde5f..32f24dee50 100644 --- a/drivers/serial/ns16550.c +++ b/drivers/serial/ns16550.c @@ -70,6 +70,15 @@ void NS16550_putc (NS16550_t com_port, char c) { while ((serial_in(&com_port->lsr) & UART_LSR_THRE) == 0); serial_out(c, &com_port->thr); + + /* + * Call watchdog_reset() upon newline. This is done here in putc + * since the environment code uses a single puts() to print the complete + * environment upon "printenv". So we can't put this watchdog call + * in puts(). + */ + if (c == '\n') + WATCHDOG_RESET(); } #ifndef CONFIG_NS16550_MIN_FUNCTIONS -- 2.25.1