serial: lpuart: Avoid division by zero when requested baudrate is
With serdev device support added there's now a corner case where:

 1. There is a DT node for a serdev device on one of the UARTs
 2. There is no driver that binds against serdev device's compatibility
    string

with 1 and 2 being true it is possible to end up in a situation where
a particualr UART has not been initalized to any baudrate when
clock_notifier_call_chain() gets called. This effectively translates
to

	set_baudrate(uart, 0);

which for LPUART driver result in a division by zero.

To avoid this problem, convert lpuart_serial_setbaudrate() to treat
zero baudrate as a request to disable the UART. While we are at it add
a BUG_ON() to lpuart_setbrg() to simplify finding any future bugs.

Signed-off-by: Andrey Smirnov <andrew.smirnov@gmail.com>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
1 parent 1df07fb commit 958f0311136b3e47a1ce3093663f74c4ee139558
@Andrey Smirnov Andrey Smirnov authored on 8 May 2018
Sascha Hauer committed on 13 Aug 2018
Showing 2 changed files
View
drivers/serial/serial_lpuart.c
View
include/serial/lpuart.h