netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v1] pse-core: Conditionally set current limit during PI regulator registration
@ 2024-08-13  7:37 Oleksij Rempel
  2024-08-14  9:23 ` Kory Maincent
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Oleksij Rempel @ 2024-08-13  7:37 UTC (permalink / raw)
  To: Kory Maincent, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn
  Cc: Oleksij Rempel, kernel, linux-kernel, netdev

Fix an issue where `devm_regulator_register()` would fail for PSE
controllers that do not support current limit control, such as simple
GPIO-based controllers like the podl-pse-regulator. The
`REGULATOR_CHANGE_CURRENT` flag and `max_uA` constraint are now
conditionally set only if the `pi_set_current_limit` operation is
supported. This change prevents the regulator registration routine from
attempting to call `pse_pi_set_current_limit()`, which would return
`-EOPNOTSUPP` and cause the registration to fail.

Fixes: 4a83abcef5f4f ("net: pse-pd: Add new power limit get and set c33 features")
Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
---
 drivers/net/pse-pd/pse_core.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/drivers/net/pse-pd/pse_core.c b/drivers/net/pse-pd/pse_core.c
index ec20953e0f825..4f032b16a8a0a 100644
--- a/drivers/net/pse-pd/pse_core.c
+++ b/drivers/net/pse-pd/pse_core.c
@@ -401,9 +401,14 @@ devm_pse_pi_regulator_register(struct pse_controller_dev *pcdev,
 	rdesc->ops = &pse_pi_ops;
 	rdesc->owner = pcdev->owner;

-	rinit_data->constraints.valid_ops_mask = REGULATOR_CHANGE_STATUS |
-						 REGULATOR_CHANGE_CURRENT;
-	rinit_data->constraints.max_uA = MAX_PI_CURRENT;
+	rinit_data->constraints.valid_ops_mask = REGULATOR_CHANGE_STATUS;
+
+	if (pcdev->ops->pi_set_current_limit) {
+		rinit_data->constraints.valid_ops_mask |=
+			REGULATOR_CHANGE_CURRENT;
+		rinit_data->constraints.max_uA = MAX_PI_CURRENT;
+	}
+
 	rinit_data->supply_regulator = "vpwr";

 	rconfig.dev = pcdev->dev;
--
2.39.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net v1] pse-core: Conditionally set current limit during PI regulator registration
  2024-08-13  7:37 [PATCH net v1] pse-core: Conditionally set current limit during PI regulator registration Oleksij Rempel
@ 2024-08-14  9:23 ` Kory Maincent
  2024-08-14 22:09 ` Kyle Swenson
  2024-08-16  2:06 ` Jakub Kicinski
  2 siblings, 0 replies; 4+ messages in thread
From: Kory Maincent @ 2024-08-14  9:23 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Andrew Lunn, kernel, linux-kernel, netdev

On Tue, 13 Aug 2024 09:37:19 +0200
Oleksij Rempel <o.rempel@pengutronix.de> wrote:

> Fix an issue where `devm_regulator_register()` would fail for PSE
> controllers that do not support current limit control, such as simple
> GPIO-based controllers like the podl-pse-regulator. The
> `REGULATOR_CHANGE_CURRENT` flag and `max_uA` constraint are now
> conditionally set only if the `pi_set_current_limit` operation is
> supported. This change prevents the regulator registration routine from
> attempting to call `pse_pi_set_current_limit()`, which would return
> `-EOPNOTSUPP` and cause the registration to fail.

Thanks for the fix!

Reviewed-by: Kory Maincent <kory.maincent@bootlin.com>

-- 
Köry Maincent, Bootlin
Embedded Linux and kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net v1] pse-core: Conditionally set current limit during PI regulator registration
  2024-08-13  7:37 [PATCH net v1] pse-core: Conditionally set current limit during PI regulator registration Oleksij Rempel
  2024-08-14  9:23 ` Kory Maincent
@ 2024-08-14 22:09 ` Kyle Swenson
  2024-08-16  2:06 ` Jakub Kicinski
  2 siblings, 0 replies; 4+ messages in thread
From: Kyle Swenson @ 2024-08-14 22:09 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: Kory Maincent, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Andrew Lunn, kernel@pengutronix.de,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org

On Tue, Aug 13, 2024 at 09:37:19AM +0200, Oleksij Rempel wrote:
> Fix an issue where `devm_regulator_register()` would fail for PSE
> controllers that do not support current limit control, such as simple
> GPIO-based controllers like the podl-pse-regulator. The
> `REGULATOR_CHANGE_CURRENT` flag and `max_uA` constraint are now
> conditionally set only if the `pi_set_current_limit` operation is
> supported. This change prevents the regulator registration routine from
> attempting to call `pse_pi_set_current_limit()`, which would return
> `-EOPNOTSUPP` and cause the registration to fail.
> 
> Fixes: 4a83abcef5f4f ("net: pse-pd: Add new power limit get and set c33 features")
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>
> ---
>  drivers/net/pse-pd/pse_core.c | 11 ++++++++---
>  1 file changed, 8 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/net/pse-pd/pse_core.c b/drivers/net/pse-pd/pse_core.c
> index ec20953e0f825..4f032b16a8a0a 100644
> --- a/drivers/net/pse-pd/pse_core.c
> +++ b/drivers/net/pse-pd/pse_core.c
> @@ -401,9 +401,14 @@ devm_pse_pi_regulator_register(struct pse_controller_dev *pcdev,
>  	rdesc->ops = &pse_pi_ops;
>  	rdesc->owner = pcdev->owner;
> 
> -	rinit_data->constraints.valid_ops_mask = REGULATOR_CHANGE_STATUS |
> -						 REGULATOR_CHANGE_CURRENT;
> -	rinit_data->constraints.max_uA = MAX_PI_CURRENT;
> +	rinit_data->constraints.valid_ops_mask = REGULATOR_CHANGE_STATUS;
> +
> +	if (pcdev->ops->pi_set_current_limit) {
> +		rinit_data->constraints.valid_ops_mask |=
> +			REGULATOR_CHANGE_CURRENT;
> +		rinit_data->constraints.max_uA = MAX_PI_CURRENT;
> +	}
> +
>  	rinit_data->supply_regulator = "vpwr";
> 
>  	rconfig.dev = pcdev->dev;
> --
> 2.39.2

This patch solves the problem I was having with the regulator setup for
the tps23881 on my hardware.  Great timing, and thanks for the fix!

Tested-by: Kyle Swenson <kyle.swenson@est.tech>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net v1] pse-core: Conditionally set current limit during PI regulator registration
  2024-08-13  7:37 [PATCH net v1] pse-core: Conditionally set current limit during PI regulator registration Oleksij Rempel
  2024-08-14  9:23 ` Kory Maincent
  2024-08-14 22:09 ` Kyle Swenson
@ 2024-08-16  2:06 ` Jakub Kicinski
  2 siblings, 0 replies; 4+ messages in thread
From: Jakub Kicinski @ 2024-08-16  2:06 UTC (permalink / raw)
  To: Oleksij Rempel
  Cc: Kory Maincent, David S. Miller, Eric Dumazet, Paolo Abeni,
	Andrew Lunn, kernel, linux-kernel, netdev

On Tue, 13 Aug 2024 09:37:19 +0200 Oleksij Rempel wrote:
> Fix an issue where `devm_regulator_register()` would fail for PSE
> controllers that do not support current limit control, such as simple
> GPIO-based controllers like the podl-pse-regulator. The
> `REGULATOR_CHANGE_CURRENT` flag and `max_uA` constraint are now
> conditionally set only if the `pi_set_current_limit` operation is
> supported. This change prevents the regulator registration routine from
> attempting to call `pse_pi_set_current_limit()`, which would return
> `-EOPNOTSUPP` and cause the registration to fail.
> 
> Fixes: 4a83abcef5f4f ("net: pse-pd: Add new power limit get and set c33 features")
> Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de>

FTR looks like Paolo applied this, thanks!
-- 
pw-bot: accept

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-16  2:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-13  7:37 [PATCH net v1] pse-core: Conditionally set current limit during PI regulator registration Oleksij Rempel
2024-08-14  9:23 ` Kory Maincent
2024-08-14 22:09 ` Kyle Swenson
2024-08-16  2:06 ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).