diff mbox series

[net,v1] pse-core: Conditionally set current limit during PI regulator registration

Message ID 20240813073719.2304633-1-o.rempel@pengutronix.de (mailing list archive)
State Accepted
Delegated to: Netdev Maintainers
Headers show
Series [net,v1] pse-core: Conditionally set current limit during PI regulator registration | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 29 this patch: 29
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers fail 1 blamed authors not CCed: saikrishnag@marvell.com; 1 maintainers not CCed: saikrishnag@marvell.com
netdev/build_clang success Errors and warnings before: 29 this patch: 29
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 29 this patch: 29
netdev/checkpatch warning WARNING: Please use correct Fixes: style 'Fixes: <12 chars of sha1> ("<title line>")' - ie: 'Fixes: 4a83abcef5f4 ("net: pse-pd: Add new power limit get and set c33 features")'
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-08-13--12-00 (tests: 706)

Commit Message

Oleksij Rempel Aug. 13, 2024, 7:37 a.m. UTC
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(-)

--
2.39.2

Comments

Kory Maincent Aug. 14, 2024, 9:23 a.m. UTC | #1
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>
Kyle Swenson Aug. 14, 2024, 10:09 p.m. UTC | #2
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>
Jakub Kicinski Aug. 16, 2024, 2:06 a.m. UTC | #3
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!
diff mbox series

Patch

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;