diff options
author | Ahmad Fatoum <a.fatoum@pengutronix.de> | 2020-04-13 09:51:45 +0200 |
---|---|---|
committer | Sascha Hauer <s.hauer@pengutronix.de> | 2020-04-15 11:20:56 +0200 |
commit | a2d50d5cf7c301156d1345bcef76a517ec7ba40d (patch) | |
tree | e6ded2279e55e8b34b2381f1efcac91639ce37ac /drivers/mfd | |
parent | f4d3f554bc9214d9d1ac1e3bf16529996896cfd3 (diff) | |
download | barebox-a2d50d5cf7c301156d1345bcef76a517ec7ba40d.tar.gz barebox-a2d50d5cf7c301156d1345bcef76a517ec7ba40d.tar.xz |
mfd: syscon: refactor of_syscon_register compatible check
Linux also provides a device_node_to_regmap function that doesn't do a
compatible = "syscon" check. In preparation for having it in barebox,
factor out the compatible check into the callers.
While at it make the clock checking explicit, so the diff clearly
indicates, we touched all instances and to prepare for follow-up
commits.
No functional change.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'drivers/mfd')
-rw-r--r-- | drivers/mfd/syscon.c | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c index ab458428a6..a8bb297bd2 100644 --- a/drivers/mfd/syscon.c +++ b/drivers/mfd/syscon.c @@ -44,9 +44,6 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk) struct syscon *syscon; struct resource res; - if (!of_device_is_compatible(np, "syscon")) - return ERR_PTR(-EINVAL); - syscon = xzalloc(sizeof(*syscon)); if (of_address_to_resource(np, 0, &res)) { @@ -83,7 +80,7 @@ err_map: return ERR_PTR(ret); } -static struct syscon *node_to_syscon(struct device_node *np) +static struct syscon *node_to_syscon(struct device_node *np, bool check_clk) { struct syscon *entry, *syscon = NULL; @@ -94,7 +91,7 @@ static struct syscon *node_to_syscon(struct device_node *np) } if (!syscon) - syscon = of_syscon_register(np, true); + syscon = of_syscon_register(np, check_clk); if (IS_ERR(syscon)) return ERR_CAST(syscon); @@ -104,9 +101,13 @@ static struct syscon *node_to_syscon(struct device_node *np) static void __iomem *syscon_node_to_base(struct device_node *np) { - struct syscon *syscon = node_to_syscon(np); + struct syscon *syscon; struct clk *clk; + if (!of_device_is_compatible(np, "syscon")) + return ERR_PTR(-EINVAL); + + syscon = node_to_syscon(np, true); if (IS_ERR(syscon)) return ERR_CAST(syscon); @@ -155,8 +156,12 @@ void __iomem *syscon_base_lookup_by_phandle(struct device_node *np, struct regmap *syscon_node_to_regmap(struct device_node *np) { - struct syscon *syscon = node_to_syscon(np); + struct syscon *syscon; + + if (!of_device_is_compatible(np, "syscon")) + return ERR_PTR(-EINVAL); + syscon = node_to_syscon(np, true); if (IS_ERR(syscon)) return ERR_CAST(syscon); |