power: regulator: s2mps11: declaratively get/set regulator mode
authorKaustabh Chakraborty <kauschluss@disroot.org>
Fri, 17 Oct 2025 15:28:19 +0000 (20:58 +0530)
committerPeng Fan <peng.fan@nxp.com>
Thu, 30 Oct 2025 02:11:18 +0000 (10:11 +0800)
commit3d4143ac3aefe54ad77151378f44df94de7e10da
tree74179f560cf7ddf506ff51c96af98ac80be46f5c
parent2d49a7e75ce176b07288397742fb9a72d6caf134
power: regulator: s2mps11: declaratively get/set regulator mode

The functions s2mps11_{buck,ldo}_mode use the s2mps11_{buck,ldo}_modes
arrays directly in order to extract the mode of a certain register.
This approach does not allow similar devices of other variants (which
may support a different set of modes) to work with the same driver.

Instead of using these arrays hardcoded, extract them from the device's
uclass platform data. Now the responsibility of setting these arrays
properly is done by functions s2mps11_{buck,ldo}_probe, by implementing
a switch-case block which can support modes of multiple variants if and
when added.

Signed-off-by: Kaustabh Chakraborty <kauschluss@disroot.org>
Reviewed-by: Peng Fan <peng.fan@nxp.com>
Signed-off-by: Peng Fan <peng.fan@nxp.com>
drivers/power/regulator/s2mps11_regulator.c