From 4ad8b730a0f09fae020e2cf13fdbf301c1e2aec9 Mon Sep 17 00:00:00 2001 From: Alex Badea Date: Wed, 17 Nov 2010 23:35:16 +0200 Subject: target uart: fix preservation of LCR Store old_lcr only when switching to LCR == 0xBF. We don't want to clobber old_lcr when switching back, otherwise we can't restore the previous LCR value. Signed-off-by: Alex Badea --- src/target/firmware/calypso/uart.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/target/firmware/calypso/uart.c') diff --git a/src/target/firmware/calypso/uart.c b/src/target/firmware/calypso/uart.c index a46fff91..4d7df092 100644 --- a/src/target/firmware/calypso/uart.c +++ b/src/target/firmware/calypso/uart.c @@ -127,12 +127,12 @@ static void uart_set_lcr7bit(int uart, int on) static uint8_t old_lcr; static void uart_set_lcr_bf(int uart, int on) { - old_lcr = readb(UART_REG(uart, LCR)); - - if (on) + if (on) { + old_lcr = readb(UART_REG(uart, LCR)); writeb(0xBF, UART_REG(uart, LCR)); - else + } else { writeb(old_lcr, UART_REG(uart, LCR)); + } } /* Enable or disable the TCR_TLR latch bit in MCR[6] */ -- cgit v1.2.3