Skip to contentSkip to conversation

drivers/tty/serial/8250: check the return value of clk_set_rate()

PATCH In review Li Zhong 2 participants 2 messages Sep 19, 2022

Subsystems (2)
lore
Share & tools
lore

Li Zhong

author
#0 lore raw

PATCH 1/1 drivers/tty/serial/8250: check the return value of clk_set_rate()

Check the return of clk_set_rate() which could fail if there is error setting the rate.

---
 drivers/tty/serial/8250/8250_bcm7271.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/tty/serial/8250/8250_bcm7271.c +3 -1
index 8efdc271eb75..9014853d6e35 100644
@@ -671,7 +671,9 @@ static void init_real_clk_rates(struct device *dev, struct brcmuart_priv *priv)
 			priv->real_rates[x] = clk_get_rate(priv->baud_mux_clk);
 		}
 	}
-	clk_set_rate(priv->baud_mux_clk, priv->default_mux_rate);
+	rc = clk_set_rate(priv->baud_mux_clk, priv->default_mux_rate);
+	if (rc)
+		dev_err(dev, "Error restoring default BAUD MUX clock\n");
 }
 
 static void set_clock_mux(struct uart_port *up, struct brcmuart_priv *priv,
Signature · 1 line
2.25.1
#1 lore raw
Quoted 13 lines · Li Zhong

Check the return of clk_set_rate() which could fail if there is error setting the rate.

---
 drivers/tty/serial/8250/8250_bcm7271.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/tty/serial/8250/8250_bcm7271.c +0 -0
index 8efdc271eb75..9014853d6e35 100644

drivers/tty/serial/8250/8250_bcm7271.c static void init_real_clk_rates(struct device *dev, struct brcmuart_priv *priv) · line 676

Quoted 7 lines
drivers/tty/serial/8250/8250_bcm7271.c +3 -1
@@ -671,7 +671,9 @@ static void init_real_clk_rates(struct device *dev, struct brcmuart_priv *priv)
 			priv->real_rates[x] = clk_get_rate(priv->baud_mux_clk);
 		}
 	}
-	clk_set_rate(priv->baud_mux_clk, priv->default_mux_rate);
+	rc = clk_set_rate(priv->baud_mux_clk, priv->default_mux_rate);
+	if (rc)
+		dev_err(dev, "Error restoring default BAUD MUX clock\n");

What does this actually help with? Shouldn't you recover properly from an error instead of telling the user something bad went wrong and nothing can be done?

This is not a correct fix at all, sorry.

thanks,

greg k-h