[PATCH 3/5] regulator: allow use of dummy regulator

Andrej Picej andrej.picej at norik.com
Mon Nov 15 05:02:06 PST 2021


It is quite common for users to delete power supply nodes of regulators
which aren't yet supported.
The idea of a function call or devicetree property which allows use of
dummy regulator is not new. This implementation uses barebox specific
devicetree property "barebox,allow-dummy-supply" to allow switching to
dummy power regulator.
Basically just catch the regulators ensure_probed error, if this
property is set.

Signed-off-by: Andrej Picej <andrej.picej at norik.com>
---
 drivers/regulator/core.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 097f7d779..1c58932e1 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -231,8 +231,15 @@ static struct regulator_internal *of_regulator_get(struct device_d *dev, const c
 	}
 
 	ret = of_device_ensure_probed(node);
-	if (ret)
+	if (ret) {
+		if (of_get_property(dev->device_node, "barebox,allow-dummy-supply", NULL)) {
+			dev_dbg(dev, "Allow use of dummy regulator for " \
+				"%s-supply\n", supply);
+			ri = NULL;
+			goto out;
+		}
 		return ERR_PTR(ret);
+	}
 
 	list_for_each_entry(ri, &regulator_list, list) {
 		if (ri->node == node) {
-- 
2.25.1




More information about the barebox mailing list