mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] serial: ns16550: Fix reading clock-frequency property
@ 2015-06-22  8:48 Sascha Hauer
  2015-06-22  9:33 ` Antony Pavlov
  0 siblings, 1 reply; 3+ messages in thread
From: Sascha Hauer @ 2015-06-22  8:48 UTC (permalink / raw)
  To: Barebox List

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@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


_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] serial: ns16550: Fix reading clock-frequency property
  2015-06-22  8:48 [PATCH] serial: ns16550: Fix reading clock-frequency property Sascha Hauer
@ 2015-06-22  9:33 ` Antony Pavlov
  2015-06-22  9:53   ` Sascha Hauer
  0 siblings, 1 reply; 3+ messages in thread
From: Antony Pavlov @ 2015-06-22  9:33 UTC (permalink / raw)
  To: barebox

On Mon, 22 Jun 2015 10:48:40 +0200
Sascha Hauer <s.hauer@pengutronix.de> wrote:

> The clock-frequency property is never read because the driver

hmmm, but how qemu-malta works?

> 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@pengutronix.de>

-- 
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] serial: ns16550: Fix reading clock-frequency property
  2015-06-22  9:33 ` Antony Pavlov
@ 2015-06-22  9:53   ` Sascha Hauer
  0 siblings, 0 replies; 3+ messages in thread
From: Sascha Hauer @ 2015-06-22  9:53 UTC (permalink / raw)
  To: Antony Pavlov; +Cc: barebox

On Mon, Jun 22, 2015 at 12:33:07PM +0300, Antony Pavlov wrote:
> On Mon, 22 Jun 2015 10:48:40 +0200
> Sascha Hauer <s.hauer@pengutronix.de> wrote:
> 
> > The clock-frequency property is never read because the driver
> 
> hmmm, but how qemu-malta works?

Probably qemu-malta has clk support disabled, so:

static inline struct clk *clk_get(struct device_d *dev, const char *id)
{
	return NULL;
}

Which is a valid clk and the driver is happy. clk_get_rate(priv->clk)
returns 0 and the drivers continues with:

        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);
        }

Which will read the correct clock-frequency from the device tree.

Sascha

-- 
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-06-22  9:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-22  8:48 [PATCH] serial: ns16550: Fix reading clock-frequency property Sascha Hauer
2015-06-22  9:33 ` Antony Pavlov
2015-06-22  9:53   ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox