regulator: core: add debug print for regulator_resolve_supply
PATCH 1/2 regulator: core: add debug print for regulator_resolve_supply
Starting with commit 324bd9bbe7e8 ("regulator: recursively enable/disable regulator dependency tree"), regulator operations may affect more than just the one regulator being enabled. Place a debug print, so it's easier to follow the dependency chain.
--- drivers/regulator/core.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/regulator/core.c +2 -0
@@ -141,6 +141,8 @@ static int regulator_resolve_supply(struct regulator_dev *rdev)if (!supply_name)return 0 ; +dev_dbg (rdev->dev,"resolving %s\n" , supply_name); + supply =regulator_get (rdev->dev, supply_name);if (IS_ERR (supply)) {if (deep_probe_is_supported ())
Signature · 1 line
2.38.4
PATCH 2/2 test: self: add basic regulator selftest
This simple test verifies registration and always-on enabling and disabling work as they should. It may be extended in future to support more complex cases.
--- test/self/Kconfig | 5 + test/self/Makefile | 1 + test/self/regulator.c | 188 ++++++++++++++++++++++++++++++++++ test/self/test_regulator.dtso | 43 ++++++++ 4 files changed, 237 insertions(+) create mode 100644 test/self/regulator.c create mode 100644 test/self/test_regulator.dtso
test/self/Kconfig +5 -0
@@ -36,6 +36,7 @@ config SELFTEST_ENABLE_ALL imply SELFTEST_FS_RAMFS imply SELFTEST_TFTP imply SELFTEST_JSON + imply SELFTEST_REGULATOR help Selects all self-tests compatible with current configuration
@@ -69,4 +70,8 @@ config SELFTEST_JSON bool "JSON selftest" depends on JSMN +config SELFTEST_REGULATOR + bool "Regulator selftest" + depends on REGULATOR && OFDEVICE + endif
test/self/Makefile +1 -0
@@ -9,6 +9,7 @@ obj-$(CONFIG_SELFTEST_OF_MANIPULATION) += of_manipulation.o of_manipulation.dtb. obj-$(CONFIG_SELFTEST_ENVIRONMENT_VARIABLES) += envvar.o obj-$(CONFIG_SELFTEST_FS_RAMFS) += ramfs.o obj-$(CONFIG_SELFTEST_JSON) += json.o +obj-$(CONFIG_SELFTEST_REGULATOR) += regulator.o test_regulator.dtbo.o clean-files := *.dtb *.dtb.S .*.dtc .*.pre .*.dts *.dtb.z clean-files += *.dtbo *.dtbo.S .*.dtso
test/self/regulator.c new file +188 -0
188 lines not on this page · raw message
test/self/test_regulator.dtso new file +43 -0
43 lines not on this page · raw message
Signature · 1 line
2.38.4
Re: [PATCH 2/2] test: self: add basic regulator selftest
Quoted 21 lines · Ahmad Fatoum
This simple test verifies registration and always-on enabling and disabling work as they should. It may be extended in future to support more complex cases.
test/self/regulator.c new file +17
-0+static const struct of_device_id test_regulator_of_match[] = { + { .compatible ="barebox,regulator-self-test" }, + {/* sentintel */ }, +}; + +static struct driver regulator_test_driver = { + .name ="regulator-test" , + .probe = regulator_probe, + .of_match_table = test_regulator_of_match, +}; + +static struct device_d *dev; + +static void test_regulator (void ) +{ +extern char __dtbo_test_regulator_start[]; +struct device_node *overlay;
test/self/regulator.c line 179
Quoted 10 lines
test/self/regulator.c new file +10
-0+int ret; + +if (!dev) { + ret =platform_driver_register (®ulator_test_driver); +if (ret) +return ; + + overlay =of_unflatten_dtb (__dtbo_test_regulator_start,INT_MAX ); +of_overlay_apply_tree (of_get_root_node (), overlay); +of_probe ();
This needs CONFIG_OF_OVERLAY_LIVE enabled to work. Should we make sure this option is enabled before running this test?
Sascha
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Re: [PATCH 2/2] test: self: add basic regulator selftest
Hello Sascha,
Quoted 27 lines · Sascha Hauer
Quoted 26 lines · Ahmad Fatoum
This simple test verifies registration and always-on enabling and disabling work as they should. It may be extended in future to support more complex cases.
test/self/regulator.c new file +22
-0+static const struct of_device_id test_regulator_of_match[] = { + { .compatible ="barebox,regulator-self-test" }, + {/* sentintel */ }, +}; + +static struct driver regulator_test_driver = { + .name ="regulator-test" , + .probe = regulator_probe, + .of_match_table = test_regulator_of_match, +}; + +static struct device_d *dev; + +static void test_regulator (void ) +{ +extern char __dtbo_test_regulator_start[]; +struct device_node *overlay; +int ret; + +if (!dev) { + ret =platform_driver_register (®ulator_test_driver); +if (ret)
Quoted 8 lines
test/self/regulator.c line 179
Quoted 5 lines
test/self/regulator.c new file +5
-0+return ; + + overlay =of_unflatten_dtb (__dtbo_test_regulator_start,INT_MAX ); +of_overlay_apply_tree (of_get_root_node (), overlay); +of_probe ();This needs
CONFIG_OF_OVERLAY_LIVEenabled to work. Should we make sure this option is enabled before running this test?
No, it doesn't. The overlay has no phandle references into the barebox live tree, so it can be applied without symbols. This is similar to the QEMU overlay, where the QEMU-provided DT also lacks symbols.
Cheers,
Ahmad
Quoted 3 lines
Sascha
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
Re: [PATCH 2/2] test: self: add basic regulator selftest
Quoted 39 lines · Ahmad Fatoum
Hello Sascha,
Quoted 27 lines · Sascha Hauer
Quoted 26 lines · Ahmad Fatoum
This simple test verifies registration and always-on enabling and disabling work as they should. It may be extended in future to support more complex cases.
test/self/regulator.c new file +22
-0+static const struct of_device_id test_regulator_of_match[] = { + { .compatible ="barebox,regulator-self-test" }, + {/* sentintel */ }, +}; + +static struct driver regulator_test_driver = { + .name ="regulator-test" , + .probe = regulator_probe, + .of_match_table = test_regulator_of_match, +}; + +static struct device_d *dev; + +static void test_regulator (void ) +{ +extern char __dtbo_test_regulator_start[]; +struct device_node *overlay; +int ret; + +if (!dev) { + ret =platform_driver_register (®ulator_test_driver); +if (ret)Quoted 8 lines
test/self/regulator.c line 179
Quoted 5 lines
test/self/regulator.c new file +5
-0+return ; + + overlay =of_unflatten_dtb (__dtbo_test_regulator_start,INT_MAX ); +of_overlay_apply_tree (of_get_root_node (), overlay); +of_probe ();This needs
CONFIG_OF_OVERLAY_LIVEenabled to work. Should we make sure this option is enabled before running this test?
Quoted 3 lines
No, it doesn't. The overlay has no phandle references into the barebox live tree, so it can be applied without symbols. This is similar to the QEMU overlay, where the QEMU-provided DT also lacks symbols.
Ok, I see. It still needs CONFIG_OF_OVERLAY though. Without it of_overlay_apply_tree will be a stub.
Sascha
Signature · 4 lines
Pengutronix e.K. | | Steuerwalder Str. 21 | http://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |
PATCH 1/1 fixup! test: self: add basic regulator selftest
In reply to Ahmad Fatoum - fix order, so test doesn't fail.
- print debug message before registration, so early failure is easier to follow
- don't define DEBUG by default
--- test/self/regulator.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-)
test/self/regulator.c +4 -9
@@ -1,7 +1,7 @@// SPDX-License-Identifier: GPL-2.0-only #define pr_fmt (fmt) KBUILD_MODNAME ": " fmt -#define DEBUG 1 +#include <common.h> #include <bselftest.h> #include <driver.h>
@@ -60,12 +60,8 @@ static const struct regulator_ops test_regulator_ops_range = { };enum { -/* -* This is intentionally ordered that way to test registering -* an always-on regulator before its sibling that it depends on -*/ -TEST_LDO1 ,TEST_BUCK , +TEST_LDO1 ,TEST_LDO2 ,TEST_REGULATORS_NUM };
@@ -106,13 +102,12 @@ static int test_regulator_register(struct test_regulator *priv, int id, cfg->rdev.desc = &cfg->desc; cfg->rdev.dev = dev; +dev_dbg (dev,"registering %s\n" , match->name); + ret =of_regulator_register (&cfg->rdev, match->of_node);if (ret)return dev_err_probe (dev, ret,"failed to register %s regulator\n" , match->name); - -dev_dbg (dev,"registered %s\n" , match->name); -return 0 ; }
Signature · 1 line
2.38.4