[PATCH 2/2] test: self: add basic regulator selftest

Ahmad Fatoum a.fatoum at pengutronix.de
Tue May 2 03:04:04 PDT 2023


Hello Sascha,

On 02.05.23 11:22, Sascha Hauer wrote:
> On Mon, Apr 24, 2023 at 01:59:08PM +0200, Ahmad Fatoum wrote:
>> 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.
>>
>> +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(&regulator_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?

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

> 
> Sascha
> 

-- 
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 |




More information about the barebox mailing list