diff mbox series

[RFC,3/3] power: reset: syscon-reboot: support "reg" property

Message ID 20211102152207.11891-4-zajec5@gmail.com (mailing list archive)
State Not Applicable, archived
Headers show
Series reset: syscon-reboot: add "reg" property support | expand

Commit Message

Rafał Miłecki Nov. 2, 2021, 3:22 p.m. UTC
From: Rafał Miłecki <rafal@milecki.pl>

This follows binding update to use "reg" for reading regmap offset.

Signed-off-by: Rafał Miłecki <rafal@milecki.pl>
---
 drivers/power/reset/syscon-reboot.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/drivers/power/reset/syscon-reboot.c b/drivers/power/reset/syscon-reboot.c
index 510e363381ca..a0999bac503e 100644
--- a/drivers/power/reset/syscon-reboot.c
+++ b/drivers/power/reset/syscon-reboot.c
@@ -44,6 +44,7 @@  static int syscon_reboot_probe(struct platform_device *pdev)
 	struct syscon_reboot_context *ctx;
 	struct device *dev = &pdev->dev;
 	int mask_err, value_err;
+	bool is_child = false;
 	int err;
 
 	ctx = devm_kzalloc(&pdev->dev, sizeof(*ctx), GFP_KERNEL);
@@ -55,10 +56,14 @@  static int syscon_reboot_probe(struct platform_device *pdev)
 		ctx->map = syscon_node_to_regmap(dev->parent->of_node);
 		if (IS_ERR(ctx->map))
 			return PTR_ERR(ctx->map);
+		is_child = true;
 	}
 
-	if (of_property_read_u32(pdev->dev.of_node, "offset", &ctx->offset))
-		return -EINVAL;
+	if (!is_child ||
+	    of_property_read_u32(dev->of_node, "reg", &ctx->offset)) {
+		if (of_property_read_u32(dev->of_node, "offset", &ctx->offset))
+			return -EINVAL;
+	}
 
 	value_err = of_property_read_u32(pdev->dev.of_node, "value", &ctx->value);
 	mask_err = of_property_read_u32(pdev->dev.of_node, "mask", &ctx->mask);