]> git.baikalelectronics.ru Git - kernel.git/commit
regulator: core: Don't err if allow-set-load but no allowed-modes
authorDouglas Anderson <dianders@chromium.org>
Wed, 24 Aug 2022 21:22:57 +0000 (14:22 -0700)
committerMark Brown <broonie@kernel.org>
Thu, 25 Aug 2022 16:58:33 +0000 (17:58 +0100)
commit10bb8f6c14231dacbe7ef891cfc3e87837e110b5
treeec5ae94ae38bc606b95713fbb51301382d19ced8
parent5ef38e801d373e920c54616a8a42491974530491
regulator: core: Don't err if allow-set-load but no allowed-modes

Apparently the device trees of some boards have the property
"regulator-allow-set-load" for some of their regulators but then they
don't specify anything for "regulator-allowed-modes". That's not
really legit, but...

...before commit 8f76d20e5e81 ("regulator: qcom-rpmh: Implement
get_optimum_mode(), not set_load()") they used to get away with it, at
least on boards using RPMH regulators. That's because when a regulator
driver implements set_load() then the core doesn't look at
"regulator-allowed-modes" when trying to automatically adjust things
in response to the regulator's load. The core doesn't know what mode
we'll end up in, so how could it validate it?

Said another way: before commit 8f76d20e5e81 ("regulator: qcom-rpmh:
Implement get_optimum_mode(), not set_load()") some boards _were_
having the regulator mode adjusted despite listing no allowed
modes. After commit 8f76d20e5e81 ("regulator: qcom-rpmh: Implement
get_optimum_mode(), not set_load()") these same boards were now
getting an error returned when trying to use their regulators, since
simply enabling a regulator tries to update its load and that was
failing.

We don't really want to go back to the behavior from before commit
8f76d20e5e81 ("regulator: qcom-rpmh: Implement get_optimum_mode(), not
set_load()"). Boards shouldn't have been changing modes if no allowed
modes were listed. However, the behavior after commit 8f76d20e5e81
("regulator: qcom-rpmh: Implement get_optimum_mode(), not set_load()")
isn't the best because now boards can't even turn their regulators on.

Let's choose to detect this case and return "no error" from
drms_uA_update(). The net-result will be _different_ behavior than we
had before commit 8f76d20e5e81 ("regulator: qcom-rpmh: Implement
get_optimum_mode(), not set_load()"), but this new behavior seems more
correct. If a board truly needed the mode switched then its device
tree should be updated to list the allowed modes.

Reported-by: Andrew Halaney <ahalaney@redhat.com>
Fixes: 8f76d20e5e81 ("regulator: qcom-rpmh: Implement get_optimum_mode(), not set_load()")
Signed-off-by: Douglas Anderson <dianders@chromium.org>
Tested-by: Andrew Halaney <ahalaney@redhat.com>
Link: https://lore.kernel.org/r/20220824142229.RFT.v2.2.I6f77860e5cd98bf5c67208fa9edda4a08847c304@changeid
Signed-off-by: Mark Brown <broonie@kernel.org>
drivers/regulator/core.c