* [PATCH] regulator: sgm3804: register rails with their DT nodes
@ 2026-07-20 10:59 kr494167
2026-07-20 16:05 ` neil.armstrong
0 siblings, 1 reply; 2+ messages in thread
From: kr494167 @ 2026-07-20 10:59 UTC (permalink / raw)
To: broonie, lgirdwood; +Cc: neil.armstrong, kancy2333, linux-kernel, surendra
From: surendra <kr494167@gmail.com>
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.
Pass each matching child node in regulator_config.of_node.
Fixes: 0c47e1a8cf5d ("regulator: add SGM3804 Dual Output driver")
Signed-off-by: surendra <kr494167@gmail.com>
---
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);
--
2.55.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] regulator: sgm3804: register rails with their DT nodes
2026-07-20 10:59 [PATCH] regulator: sgm3804: register rails with their DT nodes kr494167
@ 2026-07-20 16:05 ` neil.armstrong
0 siblings, 0 replies; 2+ messages in thread
From: neil.armstrong @ 2026-07-20 16:05 UTC (permalink / raw)
To: kr494167, broonie, lgirdwood; +Cc: kancy2333, linux-kernel
On 7/20/26 12:59, kr494167@gmail.com wrote:
> From: surendra <kr494167@gmail.com>
>
> 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@gmail.com>
> ---
> 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);
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-07-20 16:05 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-20 10:59 [PATCH] regulator: sgm3804: register rails with their DT nodes kr494167
2026-07-20 16:05 ` neil.armstrong
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.