[PATCH 03/21] mfd: syscon: implement device_node_to_regmap

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxx>
| Acked-by: Arnd Bergmann <arnd@xxxxxxxx>
| Signed-off-by: Paul Burton <paul.burton@xxxxxxxx>
|__________________________________________________________________________

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 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@xxxxxxxxxxxxxxxxxxx
http://lists.infradead.org/mailman/listinfo/barebox



[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux