[PATCH 02/21] mfd: syscon: refactor of_syscon_register compatible check

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

 



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@xxxxxxxxxxxxxx>
---
 drivers/mfd/syscon.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index ba0489bf95a8..5f391dc08b10 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -46,9 +46,6 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_clk)
 	int ret;
 	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)) {
@@ -106,7 +103,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;
 
@@ -117,7 +114,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);
@@ -127,9 +124,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);
 
@@ -172,8 +173,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);
 
-- 
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