Skip to content

Commit cdc90f7

Browse files
oleremPaolo Abeni
authored andcommitted
pse-core: Conditionally set current limit during PI regulator registration
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: 4a83abc ("net: pse-pd: Add new power limit get and set c33 features") Signed-off-by: Oleksij Rempel <o.rempel@pengutronix.de> Reviewed-by: Kory Maincent <kory.maincent@bootlin.com> Tested-by: Kyle Swenson <kyle.swenson@est.tech> Link: https://patch.msgid.link/20240813073719.2304633-1-o.rempel@pengutronix.de Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 1f1b194 commit cdc90f7

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

drivers/net/pse-pd/pse_core.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -401,9 +401,14 @@ devm_pse_pi_regulator_register(struct pse_controller_dev *pcdev,
401401
rdesc->ops = &pse_pi_ops;
402402
rdesc->owner = pcdev->owner;
403403

404-
rinit_data->constraints.valid_ops_mask = REGULATOR_CHANGE_STATUS |
405-
REGULATOR_CHANGE_CURRENT;
406-
rinit_data->constraints.max_uA = MAX_PI_CURRENT;
404+
rinit_data->constraints.valid_ops_mask = REGULATOR_CHANGE_STATUS;
405+
406+
if (pcdev->ops->pi_set_current_limit) {
407+
rinit_data->constraints.valid_ops_mask |=
408+
REGULATOR_CHANGE_CURRENT;
409+
rinit_data->constraints.max_uA = MAX_PI_CURRENT;
410+
}
411+
407412
rinit_data->supply_regulator = "vpwr";
408413

409414
rconfig.dev = pcdev->dev;

0 commit comments

Comments
 (0)