From: Sascha Hauer <s.hauer@pengutronix.de>
To: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH 02/23] clk clkdev: Add clkdev matching based on physbase
Date: Wed, 26 Sep 2012 23:31:39 +0200 [thread overview]
Message-ID: <20120926213139.GS1322@pengutronix.de> (raw)
In-Reply-To: <20120926190841.GA26553@game.jcrosoft.org>
On Wed, Sep 26, 2012 at 09:08:41PM +0200, Jean-Christophe PLAGNIOL-VILLARD wrote:
> > >
> > > clk_get_sys(NULL, "toto") is a valid call
> >
> > clk_get_sys never calls clk_find_physbase. clk_get(NULL, "toto") will
> > call clk_find_physbase in which case clk_find_physbase returns -ENOSYS
> > and clk_get falls back to clk_get_sys just as it did before.
> I check one stuff
>
> what will return the new clk_get for this
>
> clk_get("dev0", "con0");
>
> where we have
>
> clkdev0 {
> .devid = "dev0"
> .physbase = 0x100
You should either use physbase or devid, not both.
> .clk =clk0
> }
>
> clkdev1 {
> .devid = "dev0"
> .conid = "con0"
> .physbase = 0x100
> .clk = clk1
> }
>
> clkdev2 {
> .devid = "dev1"
> .conid = "con0"
> .clk =clk0
> .physbase = 0x0
> }
>
> register in this order clkdev0 then clkdev1
>
> it will return clkdev0
>
> register in this order clkdev1 then clkdev0
>
> it will return clkdev1
Try the attached fixup patch.
>
> we need to manage the mach best as done in clk_get_sys
>
> then we can nor register a dev with physbase at 0x0
>
Also fixed.
8<------------------------------------------------------
From 4b773f9c7202639d1b110773b5628820091a7e07 Mon Sep 17 00:00:00 2001
From: Sascha Hauer <s.hauer@pengutronix.de>
Date: Wed, 26 Sep 2012 23:12:56 +0200
Subject: [PATCH] fixup! clk clkdev: Add clkdev matching based on physbase
When iterating over clk_lookups, we cannot return the current
clk when the lookup does not have a con_id. Instead we have
to iterate further until we can make sure that we do not have
a lookup for which both con_id and dev_id match
Also, to make sure to initialize a clk_lookup->physbase to
~0 when a dev_id is given. ~0 makes for a better invalid
physbase, NULL may be a valid device address.
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
---
drivers/clk/clkdev.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/clk/clkdev.c b/drivers/clk/clkdev.c
index 40bc006..1ae822f 100644
--- a/drivers/clk/clkdev.c
+++ b/drivers/clk/clkdev.c
@@ -66,6 +66,7 @@ static struct clk *clk_find_physbase(struct device_d *dev, const char *con_id)
{
struct clk_lookup *p;
unsigned long start;
+ struct clk *clk = ERR_PTR(-ENOSYS);
if (!dev || !dev->resource)
return ERR_PTR(-ENOSYS);
@@ -73,7 +74,7 @@ static struct clk *clk_find_physbase(struct device_d *dev, const char *con_id)
start = dev->resource[0].start;
list_for_each_entry(p, &clocks, node) {
- if (!p->physbase)
+ if (p->physbase == ~0)
continue;
if (p->physbase != start)
continue;
@@ -82,9 +83,10 @@ static struct clk *clk_find_physbase(struct device_d *dev, const char *con_id)
continue;
return p->clk;
}
- return p->clk;
+ clk = p->clk;
}
- return ERR_PTR(-ENOSYS);
+
+ return clk;
}
@@ -121,6 +123,9 @@ EXPORT_SYMBOL(clk_put);
void clkdev_add(struct clk_lookup *cl)
{
+ if (cl->dev_id)
+ cl->physbase = ~0;
+
list_add_tail(&cl->node, &clocks);
}
EXPORT_SYMBOL(clkdev_add);
@@ -128,6 +133,8 @@ EXPORT_SYMBOL(clkdev_add);
void __init clkdev_add_table(struct clk_lookup *cl, size_t num)
{
while (num--) {
+ if (cl->dev_id)
+ cl->physbase = ~0;
list_add_tail(&cl->node, &clocks);
cl++;
}
@@ -151,6 +158,7 @@ struct clk_lookup *clkdev_alloc(struct clk *clk, const char *con_id,
if (!cla)
return NULL;
+ cla->cl.physbase = ~0;
cla->cl.clk = clk;
if (con_id) {
strlcpy(cla->con_id, con_id, sizeof(cla->con_id));
--
1.7.10.4
--
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
next prev parent reply other threads:[~2012-09-26 21:31 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-24 11:04 [PATCH] common clk support Sascha Hauer
2012-09-24 11:04 ` [PATCH 01/23] err.h: introduce IS_ERR_OR_NULL Sascha Hauer
2012-09-24 11:04 ` [PATCH 02/23] clk clkdev: Add clkdev matching based on physbase Sascha Hauer
2012-09-26 16:02 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-26 17:25 ` Sascha Hauer
2012-09-26 18:53 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-26 19:09 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-26 19:08 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-26 21:31 ` Sascha Hauer [this message]
2012-09-24 11:04 ` [PATCH 03/23] clk: initial common clk support Sascha Hauer
2012-09-24 11:04 ` [PATCH 04/23] commands: Add clk commands Sascha Hauer
2012-09-24 11:04 ` [PATCH 05/23] ARM i.MX: initial clk support Sascha Hauer
2012-09-24 11:04 ` [PATCH 06/23] ARM i.MX27: implement " Sascha Hauer
2012-09-24 11:04 ` [PATCH 07/23] ARM i.MX25: Switch to common " Sascha Hauer
2012-09-24 11:04 ` [PATCH 08/23] ARM i.MX5: " Sascha Hauer
2012-09-24 11:36 ` Sascha Hauer
2012-09-24 11:04 ` [PATCH 09/23] ARM i.MX1: " Sascha Hauer
2012-09-24 11:04 ` [PATCH 10/23] ARM i.MX31: Switch to common clk Sascha Hauer
2012-09-24 11:04 ` [PATCH 11/23] ARM i.MX6: " Sascha Hauer
2012-09-24 11:04 ` [PATCH 12/23] ARM i.MX21: " Sascha Hauer
2012-09-24 11:04 ` [PATCH 13/23] ARM i.MX35: " Sascha Hauer
2012-09-24 11:04 ` [PATCH 14/23] net fec: Switch to clk support Sascha Hauer
2012-09-26 16:07 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-24 11:04 ` [PATCH 15/23] serial i.MX: " Sascha Hauer
2012-09-26 16:08 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-24 11:04 ` [PATCH 16/23] spi " Sascha Hauer
2012-09-24 11:04 ` [PATCH 17/23] ARM i.MX: Switch clocksource to clk_get Sascha Hauer
2012-09-24 11:04 ` [PATCH 18/23] mci i.MX ESDHC: Switch to clock support Sascha Hauer
2012-09-24 11:04 ` [PATCH 19/23] mci i.MX: " Sascha Hauer
2012-09-24 11:04 ` [PATCH 20/23] i2c " Sascha Hauer
2012-09-26 16:10 ` Jean-Christophe PLAGNIOL-VILLARD
2012-09-24 11:04 ` [PATCH 21/23] video " Sascha Hauer
2012-09-24 11:04 ` [PATCH 22/23] video i.MX IPU: " Sascha Hauer
2012-09-24 11:04 ` [PATCH 23/23] ARM i.MX: Remove old " Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120926213139.GS1322@pengutronix.de \
--to=s.hauer@pengutronix.de \
--cc=barebox@lists.infradead.org \
--cc=plagnioj@jcrosoft.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox