[PATCH] serial: ns16550: Fix reading clock-frequency property

Sascha Hauer s.hauer at pengutronix.de
Mon Jun 22 01:48:40 PDT 2015


The clock-frequency property is never read because the driver
bails out earlier when it is unable to clk_get the clk. Move
the clock-frequency read out to the dt setup code which is
executed before the driver bails out due to the missing clk.

Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
 drivers/serial/serial_ns16550.c | 9 ++-------
 1 file changed, 2 insertions(+), 7 deletions(-)

diff --git a/drivers/serial/serial_ns16550.c b/drivers/serial/serial_ns16550.c
index 4d636c1..c186ad4 100644
--- a/drivers/serial/serial_ns16550.c
+++ b/drivers/serial/serial_ns16550.c
@@ -291,6 +291,7 @@ static void ns16550_probe_dt(struct device_d *dev, struct ns16550_priv *priv)
 	if (!IS_ENABLED(CONFIG_OFDEVICE))
 		return;
 
+	of_property_read_u32(np, "clock-frequency", &priv->plat.clock);
 	of_property_read_u32(np, "reg-shift", &priv->plat.shift);
 }
 
@@ -417,7 +418,7 @@ static int ns16550_probe(struct device_d *dev)
 	else
 		ns16550_probe_dt(dev, priv);
 
-	if (!plat || !plat->clock) {
+	if (!priv->plat.clock) {
 		priv->clk = clk_get(dev, NULL);
 		if (IS_ERR(priv->clk)) {
 			ret = PTR_ERR(priv->clk);
@@ -427,12 +428,6 @@ static int ns16550_probe(struct device_d *dev)
 		priv->plat.clock = clk_get_rate(priv->clk);
 	}
 
-	if (priv->plat.clock == 0 && IS_ENABLED(CONFIG_OFDEVICE)) {
-		struct device_node *np = dev->device_node;
-
-		of_property_read_u32(np, "clock-frequency", &priv->plat.clock);
-	}
-
 	if (priv->plat.clock == 0) {
 		dev_err(dev, "no valid clockrate\n");
 		ret = -EINVAL;
-- 
2.1.4




More information about the barebox mailing list