Re: [PATCH 5/8] regulator: bd71828: Support ROHM BD73800

From: Matti Vaittinen

Date: Thu Jul 02 2026 - 00:57:22 EST


On 01/07/2026 16:01, Mark Brown wrote:
On Wed, Jul 01, 2026 at 03:42:35PM +0300, Matti Vaittinen wrote:
From: Matti Vaittinen <mazziesaccount@xxxxxxxxx>

+ nproot = of_get_child_by_name(nproot, "regulators");
+ if (!nproot) {
+ dev_err(dev, "failed to find regulators node\n");
+ return -ENODEV;
+ }
+ for_each_child_of_node(nproot, np) {
+ if (of_node_name_eq(np, LDO1_NODE_NAME))
+ ldo1_use_high_range = of_property_read_bool(np,
+ "rohm,ldo-range-high");
+ if (of_node_name_eq(np, LDO3_NODE_NAME))
+ ldo3_use_high_range = of_property_read_bool(np,
+ "rohm,ldo-range-high");
+ }

Why do we iterate over all nodes rather than doing additional
of_get_child_by_name()s?

This series has been sitting in my "TODO" -folder for quite a while - so I am not anymore 100% sure as to why. I believe I've thought that the of_get_child_by_name() does (internally) iterate all the child nodes, so using it twice would cause code to loop through the nodes twice. So, looping through all child nodes in a single loop probably felt like the right thing to do. Furthermore, I've probably written the first version before I found out the cleanup.h...

But yes. I think you're right. This can be made much leaner.

+ if (ldo1_use_high_range) {
+ d[BD73800_LDO1].desc.linear_ranges = bd73800_ldo13_high_volts;
+ d[BD73800_LDO1].desc.n_linear_ranges =
+ ARRAY_SIZE(bd73800_ldo13_high_volts);
+ }
+ if (ldo3_use_high_range) {
+ d[BD73800_LDO3].desc.linear_ranges = bd73800_ldo13_high_volts;
+ d[BD73800_LDO3].desc.n_linear_ranges =
+ ARRAY_SIZE(bd73800_ldo13_high_volts);
+ }

You could just do these updates without the intermediate variables.

Yes.

Thanks for the suggestions! I will fix these for the v2, but it will probably be out only during August.

Yours,
-- Matti

--
Matti Vaittinen
Linux kernel developer at ROHM Semiconductors
Oulu Finland

~~ When things go utterly wrong vim users can always type :help! ~~