[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Z0L0SuaRysRxbtNM@pengutronix.de>
Date: Sun, 24 Nov 2024 10:39:22 +0100
From: Oleksij Rempel <o.rempel@...gutronix.de>
To: Kory Maincent <kory.maincent@...tlin.com>
Cc: Andrew Lunn <andrew@...n.ch>, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>, Paolo Abeni <pabeni@...hat.com>,
Jonathan Corbet <corbet@....net>,
Donald Hunter <donald.hunter@...il.com>,
Rob Herring <robh@...nel.org>, Andrew Lunn <andrew+netdev@...n.ch>,
Simon Horman <horms@...nel.org>,
Heiner Kallweit <hkallweit1@...il.com>,
Russell King <linux@...linux.org.uk>,
Liam Girdwood <lgirdwood@...il.com>,
Mark Brown <broonie@...nel.org>,
Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
linux-doc@...r.kernel.org, Kyle Swenson <kyle.swenson@....tech>,
Dent Project <dentproject@...uxfoundation.org>,
kernel@...gutronix.de,
Maxime Chevallier <maxime.chevallier@...tlin.com>
Subject: Re: [PATCH RFC net-next v3 15/27] regulator: core: Resolve supply
using of_node from regulator_config
On Thu, Nov 21, 2024 at 03:42:41PM +0100, Kory Maincent wrote:
> From: Kory Maincent (Dent Project) <kory.maincent@...tlin.com>
>
> Previously, the regulator core resolved its supply only from the parent
> device or its children, ignoring the of_node specified in the
> regulator_config structure.
> This behavior causes issues in scenarios where multiple regulator devices
> are registered for components described as children of a controller, each
> with their own specific regulator supply.
>
> For instance, in a PSE controller with multiple PIs (Power Interfaces),
> each PI may have a distinct regulator supply. However, the regulator core
> would incorrectly use the PSE controller node or its first child to look up
> the regulator supply, rather than the node specified by the
> regulator_config->of_node for the PI.
>
> This update modifies the behavior to prioritize the of_node in
> regulator_config for resolving the supply. This ensures correct resolution
> of the power supply for each device. If no supply is found in the provided
> of_node, the core falls back to searching within the parent device as
> before.
>
> Signed-off-by: Kory Maincent <kory.maincent@...tlin.com>
> ---
> It is weird that it wasn't seen before, maybe there was not any case
> were it can't find the supply_name from the parent device.
>
> Changes in v3:
> - New patch
> ---
> drivers/regulator/core.c | 42 ++++++++++++++++++++++++++++++------------
> 1 file changed, 30 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
> index 2948a7eca734..b49f751893b9 100644
> --- a/drivers/regulator/core.c
> +++ b/drivers/regulator/core.c
> @@ -1936,6 +1936,20 @@ static struct regulator_dev *regulator_lookup_by_name(const char *name)
> return dev ? dev_to_rdev(dev) : NULL;
> }
>
> +static struct regulator_dev *regulator_dt_lookup(struct device *dev,
> + const char *supply)
> +{
> + struct regulator_dev *r = NULL;
> +
> + if (dev && dev->of_node) {
> + r = of_regulator_dev_lookup(dev, supply);
> + if (PTR_ERR(r) == -ENODEV)
> + r = NULL;
> + }
> +
> + return r;
> +}
...
> static int regulator_resolve_supply(struct regulator_dev *rdev)
> {
> - struct regulator_dev *r;
> struct device *dev = rdev->dev.parent;
> + struct regulator_dev *r = NULL;
> struct ww_acquire_ctx ww_ctx;
> int ret = 0;
>
> @@ -2015,7 +2022,18 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)
> if (rdev->supply)
> return 0;
>
> - r = regulator_dev_lookup(dev, rdev->supply_name);
> + /* first do a dt based lookup on the node described in the virtual
> + * device.
> + */
> + if (rdev->dev.of_node)
regulator_dt_lookup() is already doing dev.of_node check, this one can
be removed.
> + r = regulator_dt_lookup(&rdev->dev, rdev->supply_name);
> +
> + /* If regulator not found use usual search path in the parent
> + * device.
> + */
> + if (!r)
> + r = regulator_dev_lookup(dev, rdev->supply_name);
> +
> if (IS_ERR(r)) {
> ret = PTR_ERR(r);
>
With remove dev.of_node check:
Acked-by: Oleksij Rempel <o.rempel@...gutronix.de>
--
Pengutronix e.K. | |
Steuerwalder Str. 21 | http://www.pengutronix.de/ |
31137 Hildesheim, Germany | Phone: +49-5121-206917-0 |
Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Powered by blists - more mailing lists