[U-Boot,v2,2/7] serial: serial_msm: fail probe if settings clocks fails

Message ID 20180516091342.7509-2-ramon.fried@gmail.com
State New
Delegated to: Tom Rini
Headers show
Series
  • [U-Boot,v2,1/7] db820c: set clk node to be probed before relocation
Related show

Commit Message

Ramon Fried May 16, 2018, 9:13 a.m.
Failure to set the clocks will causes data abort exception when
trying to write to AHB uart registers.
This patch ensures that we don't touch these registers if clock
setting failed.

Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
---
v2: on failure, return actual return code from msm_uart_clk_init

 drivers/serial/serial_msm.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Simon Glass May 16, 2018, 3:40 p.m. | #1
On 16 May 2018 at 03:13, Ramon Fried <ramon.fried@gmail.com> wrote:
> Failure to set the clocks will causes data abort exception when
> trying to write to AHB uart registers.
> This patch ensures that we don't touch these registers if clock
> setting failed.
>
> Signed-off-by: Ramon Fried <ramon.fried@gmail.com>
> ---
> v2: on failure, return actual return code from msm_uart_clk_init
>
>  drivers/serial/serial_msm.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)

Reviewed-by: Simon Glass <sjg@chromium.org>

Patch

diff --git a/drivers/serial/serial_msm.c b/drivers/serial/serial_msm.c
index 119e6b9846..8b585deeeb 100644
--- a/drivers/serial/serial_msm.c
+++ b/drivers/serial/serial_msm.c
@@ -181,10 +181,12 @@  static int msm_uart_clk_init(struct udevice *dev)
 
 static int msm_serial_probe(struct udevice *dev)
 {
+	int ret;
 	struct msm_serial_data *priv = dev_get_priv(dev);
 
-	msm_uart_clk_init(dev); /* Ignore return value and hope clock was
-				  properly initialized by earlier loaders */
+	ret = msm_uart_clk_init(dev);
+	if (ret)
+		return ret;
 
 	if (readl(priv->base + UARTDM_SR) & UARTDM_SR_UART_OVERRUN)
 		writel(UARTDM_CR_CMD_RESET_ERR, priv->base + UARTDM_CR);