Re: [PATCH] regulator: sgm3804: register rails with their DT nodes
From: neil . armstrong
Date: Mon Jul 20 2026 - 12:08:34 EST
On 7/20/26 12:59, kr494167@xxxxxxxxx wrote:
From: surendra <kr494167@xxxxxxxxx>
The driver locates the pos and neg child nodes to obtain their enable
GPIOs, but registers both regulators with the parent node. As a result,
the regulator core does not parse per-rail DT constraints or supplies.
Hmmm, no it does get the constraints properly because the regulator core will
fetch the associated subnodes with the of_match desc property in regulator_of_get_init_node().
This patch solves nothing and duplicates the regulator core behaviour.
Neil
Pass each matching child node in regulator_config.of_node.
Fixes: 0c47e1a8cf5d ("regulator: add SGM3804 Dual Output driver")
Signed-off-by: surendra <kr494167@xxxxxxxxx>
---
drivers/regulator/sgm3804-regulator.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/drivers/regulator/sgm3804-regulator.c b/drivers/regulator/sgm3804-regulator.c
index c3406cfb73d0..531b98460ee3 100644
--- a/drivers/regulator/sgm3804-regulator.c
+++ b/drivers/regulator/sgm3804-regulator.c
@@ -9,6 +9,7 @@
#include <linux/err.h>
#include <linux/i2c.h>
#include <linux/module.h>
+#include <linux/of.h>
#include <linux/regmap.h>
#include <linux/regulator/driver.h>
#include <linux/regulator/of_regulator.h>
@@ -268,14 +269,21 @@ static int sgm3804_probe(struct i2c_client *i2c)
for (i = 0; i < ARRAY_SIZE(sgm3804_regulator_desc); i++) {
struct regulator_config config = { };
+ const struct regulator_desc *reg = &sgm3804_regulator_desc[i];
struct regulator_dev *rdev;
+ struct device_node *child;
+
+ child = of_get_child_by_name(dev_of_node(dev), reg->of_match);
+ if (!child)
+ return dev_err_probe(dev, -EINVAL, "missing child '%s'\n",
+ reg->of_match);
config.dev = dev;
config.regmap = ctx->regmap;
- config.of_node = dev_of_node(dev);
+ config.of_node = child;
config.driver_data = ctx;
- rdev = devm_regulator_register(dev, &sgm3804_regulator_desc[i],
- &config);
+ rdev = devm_regulator_register(dev, reg, &config);
+ of_node_put(child);
if (IS_ERR(rdev))
return dev_err_probe(dev, PTR_ERR(rdev),
"failed to register regulator %d\n", i);