Re: Unexpected behavior of of_regulator_get()?
From: Mark Brown
Date: Wed Apr 29 2026 - 20:10:50 EST
On Wed, Apr 29, 2026 at 10:18:31AM +0200, Luca Weiss wrote:
> In a simplified version, we have this devicetree structure:
>
> gpio-keys {
> compatible = "gpio-keys";
>
> event-hall-sensor {
> label = "Hall Effect Sensor";
> vdd-supply = <&vreg_l10b>;
> };
I don't understand what this is supposed to describe.
> Looking through the code this seems to be caused by of_get_regulator()
> first doing of_parse_phandle(node, prop_name, 0) which is checking on
> the node itself.
> But then if this does not succeed, it calls
> of_get_child_regulator(dev->of_node, prop_name) which goes through every
> child node of the top-level device (gpio-keys) until it finds a
> regulator. So this will find the vdd-supply of event-hall-sensor even
> for key-volume-up and switch.
Why does this single device have multiple distinct supplies going into
it all called "SUPPLY"? That doesn't seem like the sort of thing that
happens in system designs. I would not expect to see multiple distinct
supplies with the same name going into the same device.
> A workaround from the driver side would be to check for the presence of
> vdd-supply on the child (fwnode_property_present(child, "vdd-supply"))
> before trying to get a regulator but I feel like resolving this in the
> regulator core would be the better solution?
I think we need to take a step back here and look at what the binding is
supposed to describe and what it is trying to accomplish.
Attachment:
signature.asc
Description: PGP signature