mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Subject: [PATCH 03/21] mfd: syscon: implement device_node_to_regmap
Date: Mon, 13 Apr 2020 09:51:46 +0200	[thread overview]
Message-ID: <20200413075204.17544-4-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20200413075204.17544-1-a.fatoum@pengutronix.de>

Extend our syscon API with a device_node_to_regmap function that has the
same semantics as upstream:

 __________________________________________________________________________
| Linux commit 39233b7c611248c0d05209b4854bc63e26485655
| CommitDate: Thu Aug 8 15:30:07 2019 -0700
|
| mfd/syscon: Add device_node_to_regmap()
|
| device_node_to_regmap() is exactly like syscon_node_to_regmap(), but it
| does not check that the node is compatible with "syscon", and won't
| attach the first clock it finds to the regmap.
|
| The rationale behind this, is that one device node with a standard
| compatible string "foo,bar" can be covered by multiple drivers sharing a
| regmap, or by a single driver doing all the job without a regmap, but
| these are implementation details which shouldn't reflect on the
| devicetree.
|
| Signed-off-by: Paul Cercueil <paul@crapouillou.net>
| Acked-by: Arnd Bergmann <arnd@arndb.de>
| Signed-off-by: Paul Burton <paul.burton@mips.com>
|__________________________________________________________________________

Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/mfd/syscon.c | 21 ++++++++++++++++-----
 include/mfd/syscon.h |  5 +++++
 2 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 5f391dc08b10..2d7a31095b31 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -171,20 +171,31 @@ void __iomem *syscon_base_lookup_by_phandle(struct device_node *np,
 	return syscon_node_to_base(syscon_np);
 }
 
-struct regmap *syscon_node_to_regmap(struct device_node *np)
+static struct regmap *__device_node_to_regmap(struct device_node *np,
+					      bool check_clk)
 {
 	struct syscon *syscon;
 
-	if (!of_device_is_compatible(np, "syscon"))
-		return ERR_PTR(-EINVAL);
-
-	syscon = node_to_syscon(np, true);
+	syscon = node_to_syscon(np, check_clk);
 	if (IS_ERR(syscon))
 		return ERR_CAST(syscon);
 
 	return syscon->regmap;
 }
 
+struct regmap *device_node_to_regmap(struct device_node *np)
+{
+	return __device_node_to_regmap(np, false);
+}
+
+struct regmap *syscon_node_to_regmap(struct device_node *np)
+{
+	if (!of_device_is_compatible(np, "syscon"))
+		return ERR_PTR(-EINVAL);
+
+	return __device_node_to_regmap(np, true);
+}
+
 struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
 {
 	struct device_node *syscon_np;
diff --git a/include/mfd/syscon.h b/include/mfd/syscon.h
index ac33f2d34747..b47aa1e160e6 100644
--- a/include/mfd/syscon.h
+++ b/include/mfd/syscon.h
@@ -21,6 +21,7 @@ void __iomem *syscon_base_lookup_by_pdevname(const char *s);
 void __iomem *syscon_base_lookup_by_phandle
 	(struct device_node *np, const char *property);
 struct regmap *syscon_node_to_regmap(struct device_node *np);
+struct regmap *device_node_to_regmap(struct device_node *np);
 struct regmap *syscon_regmap_lookup_by_compatible(const char *s);
 extern struct regmap *syscon_regmap_lookup_by_phandle(
 					struct device_node *np,
@@ -41,6 +42,10 @@ static inline struct regmap *syscon_node_to_regmap(struct device_node *np)
 {
 	return ERR_PTR(-ENOSYS);
 }
+static inline struct regmap *device_node_to_regmap(struct device_node *np)
+{
+	return ERR_PTR(-ENOSYS);
+}
 static inline struct regmap *syscon_regmap_lookup_by_compatible(const char *s)
 {
 	return ERR_PTR(-ENOSYS);
-- 
2.26.0.rc2


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

  parent reply	other threads:[~2020-04-13  7:52 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-13  7:51 [PATCH 00/21] clk: at91: sync with Linux v5.6 Ahmad Fatoum
2020-04-13  7:51 ` [PATCH 01/21] mfd: syscon: enable specified clocks on syscon_base_lookup_by_phandle Ahmad Fatoum
2020-04-15  9:15   ` Ahmad Fatoum
2020-04-13  7:51 ` [PATCH 02/21] mfd: syscon: refactor of_syscon_register compatible check Ahmad Fatoum
2020-04-13  7:51 ` Ahmad Fatoum [this message]
2020-04-13  7:51 ` [PATCH 04/21] regmap: retire of_node_to_regmap in favor of device_node_to_regmap Ahmad Fatoum
2020-04-13  7:51 ` [PATCH 05/21] ARM: include: remove unused <asm/processor.h> Ahmad Fatoum
2020-04-13  7:51 ` [PATCH 06/21] treewide: use cpu_relax() where appropriate Ahmad Fatoum
2020-04-13  7:51 ` [PATCH 07/21] of: port Linux of_get_compatible_child helper Ahmad Fatoum
2020-04-14  6:46   ` Sascha Hauer
2020-04-14  7:29     ` Ahmad Fatoum
2020-04-14  9:44       ` Michael Tretter
2020-04-14 15:41     ` [PATCH] fixup! " Ahmad Fatoum
2020-04-13  7:51 ` [PATCH 08/21] clk: implement clk_register_fixed_rate Ahmad Fatoum
2020-04-13  7:51 ` [PATCH 09/21] clk: add clk_unregister stub Ahmad Fatoum
2020-04-13  7:51 ` [PATCH 10/21] include: linux/kernel.h: port DIV_ROUND_CLOSEST_ULL definition Ahmad Fatoum
2020-04-13  7:51 ` [PATCH 11/21] clk: migrate to SPDX-License-Identifier use Ahmad Fatoum
2020-04-13  7:51 ` [PATCH 12/21] clk: at91: fix masterck name Ahmad Fatoum
2020-04-13  7:51 ` [PATCH 13/21] clk: at91: fix possible deadlock Ahmad Fatoum
2020-04-13  7:51 ` [PATCH 14/21] clk: at91: delete no-longer required DT compat code Ahmad Fatoum
2020-04-13  7:51 ` [PATCH 15/21] clk: at91: compile dt-compat for all platforms that require it Ahmad Fatoum
2020-04-13  7:51 ` [PATCH 16/21] clk: at91: add __init marker where appropriate Ahmad Fatoum
2020-04-13  7:52 ` [PATCH 17/21] clk: at91: Mark struct clk_range as const Ahmad Fatoum
2020-04-13  7:52 ` [PATCH 18/21] clk: at91: allow 24 Mhz clock as input for PLL Ahmad Fatoum
2020-04-13  7:52 ` [PATCH 19/21] clk: at91: add sama5d2 audio PLL support Ahmad Fatoum
2020-04-13  7:52 ` [PATCH 20/21] clk: at91: port Linux v5.6 SAM9X60 (new ARM926EJ-S) clock support Ahmad Fatoum
2020-04-13  7:52 ` [PATCH 21/21] clk: at91: sckc: fix off-by-1000 in udelay() Ahmad Fatoum
2020-04-15  9:23 ` [PATCH 00/21] clk: at91: sync with Linux v5.6 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=20200413075204.17544-4-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /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