In preparation to class_find_device_by_of_node() going away switch to
using class_find_device_by_fwnode().
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
drivers/regulator/of_regulator.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/regulator/of_regulator.c b/drivers/regulator/of_regulator.c
index c0cc6cc0afd8..43ec0845c940 100644
--- a/drivers/regulator/of_regulator.c
+++ b/drivers/regulator/of_regulator.c
@@ -637,7 +637,7 @@ static struct regulator_dev *of_find_regulator_by_node(struct device_node *np)
{
struct device *dev;
- dev = class_find_device_by_of_node(®ulator_class, np);
+ dev = class_find_device_by_fwnode(®ulator_class, of_fwnode_handle(np));
return dev ? dev_to_rdev(dev) : NULL;
}
--
2.53.0.959.g497ff81fa9-goog
On Sun, Mar 22, 2026 at 06:54:22PM -0700, Dmitry Torokhov wrote: > In preparation to class_find_device_by_of_node() going away switch to > using class_find_device_by_fwnode(). > struct device *dev; > > - dev = class_find_device_by_of_node(®ulator_class, np); > + dev = class_find_device_by_fwnode(®ulator_class, of_fwnode_handle(np)); The regulator API is very deliberately specifically using the OF APIs, not the ACPI APIs, since ACPI really doesn't want to model regulators.
On Mon, Mar 23, 2026 at 02:00:43PM +0000, Mark Brown wrote: > On Sun, Mar 22, 2026 at 06:54:22PM -0700, Dmitry Torokhov wrote: > > In preparation to class_find_device_by_of_node() going away switch to > > using class_find_device_by_fwnode(). > > > struct device *dev; > > > > - dev = class_find_device_by_of_node(®ulator_class, np); > > + dev = class_find_device_by_fwnode(®ulator_class, of_fwnode_handle(np)); > > The regulator API is very deliberately specifically using the OF APIs, > not the ACPI APIs, since ACPI really doesn't want to model regulators. For now? We also have software nodes and maybe we come up with something else in the future... I think we should use firmware-agnostic APIs as much as possible, and only use OF- or ACPI-specific ones when there is no generic equivalent. This makes the code most flexible. Anyway, I am not proposing to change all of the regulator code, just clean up driver core APIs. Thanks. -- Dmitry
On Mon, Mar 23, 2026 at 11:28:27AM -0700, Dmitry Torokhov wrote: > On Mon, Mar 23, 2026 at 02:00:43PM +0000, Mark Brown wrote: > > The regulator API is very deliberately specifically using the OF APIs, > > not the ACPI APIs, since ACPI really doesn't want to model regulators. > For now? We also have software nodes and maybe we come up with something > else in the future... > I think we should use firmware-agnostic APIs as much as possible, and > only use OF- or ACPI-specific ones when there is no generic equivalent. > This makes the code most flexible. I think this is a worrying idea for core code like this, we have specific firmware bindings for specific firmware interfaces with the different interfaces having very different ideas of how things should be modelled. The chances that firmware agnostic code is going to do the right thing seem low, and encouraging the use of generic APIs that might happen to run OK raises the risk that we'll get firmware vendors relying on them and leaving us with a conceptual mishmash to sort through. Software nodes are already a bit of a concern here TBH.
On Mon, Mar 23, 2026 at 07:05:13PM +0000, Mark Brown wrote:
> On Mon, Mar 23, 2026 at 11:28:27AM -0700, Dmitry Torokhov wrote:
> > On Mon, Mar 23, 2026 at 02:00:43PM +0000, Mark Brown wrote:
>
> > > The regulator API is very deliberately specifically using the OF APIs,
> > > not the ACPI APIs, since ACPI really doesn't want to model regulators.
>
> > For now? We also have software nodes and maybe we come up with something
> > else in the future...
>
> > I think we should use firmware-agnostic APIs as much as possible, and
> > only use OF- or ACPI-specific ones when there is no generic equivalent.
> > This makes the code most flexible.
>
> I think this is a worrying idea for core code like this, we have
> specific firmware bindings for specific firmware interfaces with the
> different interfaces having very different ideas of how things should be
> modelled. The chances that firmware agnostic code is going to do the
> right thing seem low, and encouraging the use of generic APIs that might
> happen to run OK raises the risk that we'll get firmware vendors relying
> on them and leaving us with a conceptual mishmash to sort through.
How do you handle deprecated OF properties? This is a problem i've run
into before. A developer needs an ACPI binding, so they blindly
convert from of_ to device_ without engaging brain. As a result, they
bring all the deprecated OF properties we want to die into the brand
new ACPI bindings.
A agree with Mark here. OF != ACPI, and anything which makes it appear
they are the same is just going to lead developers down the wrong path
and increase Maintainers work pointing out all the problems.
Andrew
On Mon, Mar 23, 2026 at 09:01:47PM +0100, Andrew Lunn wrote: > On Mon, Mar 23, 2026 at 07:05:13PM +0000, Mark Brown wrote: > > On Mon, Mar 23, 2026 at 11:28:27AM -0700, Dmitry Torokhov wrote: > > > On Mon, Mar 23, 2026 at 02:00:43PM +0000, Mark Brown wrote: > > > > > > The regulator API is very deliberately specifically using the OF APIs, > > > > not the ACPI APIs, since ACPI really doesn't want to model regulators. > > > > > For now? We also have software nodes and maybe we come up with something > > > else in the future... > > > > > I think we should use firmware-agnostic APIs as much as possible, and > > > only use OF- or ACPI-specific ones when there is no generic equivalent. > > > This makes the code most flexible. > > > > I think this is a worrying idea for core code like this, we have > > specific firmware bindings for specific firmware interfaces with the > > different interfaces having very different ideas of how things should be > > modelled. The chances that firmware agnostic code is going to do the > > right thing seem low, and encouraging the use of generic APIs that might > > happen to run OK raises the risk that we'll get firmware vendors relying > > on them and leaving us with a conceptual mishmash to sort through. > > How do you handle deprecated OF properties? This is a problem i've run > into before. A developer needs an ACPI binding, so they blindly > convert from of_ to device_ without engaging brain. As a result, they > bring all the deprecated OF properties we want to die into the brand > new ACPI bindings. > > A agree with Mark here. OF != ACPI, and anything which makes it appear > they are the same is just going to lead developers down the wrong path > and increase Maintainers work pointing out all the problems. That's three who agree. -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
On Mon, Mar 23, 2026 at 09:01:47PM +0100, Andrew Lunn wrote: > How do you handle deprecated OF properties? This is a problem i've run > into before. A developer needs an ACPI binding, so they blindly > convert from of_ to device_ without engaging brain. As a result, they > bring all the deprecated OF properties we want to die into the brand > new ACPI bindings. Honestly that one hasn't really come up much for me - not too many deprecated properties.
On Mon, Mar 23, 2026 at 09:36:07PM +0000, Mark Brown wrote: > On Mon, Mar 23, 2026 at 09:01:47PM +0100, Andrew Lunn wrote: > > > How do you handle deprecated OF properties? This is a problem i've run > > into before. A developer needs an ACPI binding, so they blindly > > convert from of_ to device_ without engaging brain. As a result, they > > bring all the deprecated OF properties we want to die into the brand > > new ACPI bindings. > > Honestly that one hasn't really come up much for me - not too many > deprecated properties. Given that we position properties as an ABI even if they are deprecated we supposed to handle them forever. Newer properties usually offer benefits over old ones and that is how users get moved over. Thanks. -- Dmitry
On Mon, Mar 23, 2026 at 02:41:03PM -0700, Dmitry Torokhov wrote:
> On Mon, Mar 23, 2026 at 09:36:07PM +0000, Mark Brown wrote:
> > On Mon, Mar 23, 2026 at 09:01:47PM +0100, Andrew Lunn wrote:
> >
> > > How do you handle deprecated OF properties? This is a problem i've run
> > > into before. A developer needs an ACPI binding, so they blindly
> > > convert from of_ to device_ without engaging brain. As a result, they
> > > bring all the deprecated OF properties we want to die into the brand
> > > new ACPI bindings.
> >
> > Honestly that one hasn't really come up much for me - not too many
> > deprecated properties.
>
> Given that we position properties as an ABI even if they are deprecated
> we supposed to handle them forever. Newer properties usually offer
> benefits over old ones and that is how users get moved over.
~/linux/Documentation/devicetree/bindings/net$ grep -r deprecated * | wc
75 361 4195
So networking has ~ 75 of them.
Within the OF world, they are ABI and we need to keep them. But we
don't want them in ACPI or any other firmware. Any code looking for
properties needs to know what is underneath so it can decide if it
should look for the deprecated, OF only property, or not.
Andrew
On Mon, Mar 23, 2026 at 11:11:58PM +0100, Andrew Lunn wrote: > On Mon, Mar 23, 2026 at 02:41:03PM -0700, Dmitry Torokhov wrote: > > On Mon, Mar 23, 2026 at 09:36:07PM +0000, Mark Brown wrote: > > > On Mon, Mar 23, 2026 at 09:01:47PM +0100, Andrew Lunn wrote: > > > > > > > How do you handle deprecated OF properties? This is a problem i've run > > > > into before. A developer needs an ACPI binding, so they blindly > > > > convert from of_ to device_ without engaging brain. As a result, they > > > > bring all the deprecated OF properties we want to die into the brand > > > > new ACPI bindings. > > > > > > Honestly that one hasn't really come up much for me - not too many > > > deprecated properties. > > > > Given that we position properties as an ABI even if they are deprecated > > we supposed to handle them forever. Newer properties usually offer > > benefits over old ones and that is how users get moved over. > > ~/linux/Documentation/devicetree/bindings/net$ grep -r deprecated * | wc > 75 361 4195 > > So networking has ~ 75 of them. > > Within the OF world, they are ABI and we need to keep them. But we > don't want them in ACPI or any other firmware. Any code looking for > properties needs to know what is underneath so it can decide if it > should look for the deprecated, OF only property, or not. If there is a deprecated property you can do: error = device_property_read_u32(dev, "prop", &val); if (error == -ENOENT) error = device_property_read_u32(dev, "deprecated-prop", &val); You do not need much more than that... Checking node type only complicates the code, especially when a device can be used on both ACPI and DT systems. Thanks. -- Dmitry
> If there is a deprecated property you can do: > > error = device_property_read_u32(dev, "prop", &val); > if (error == -ENOENT) > error = device_property_read_u32(dev, "deprecated-prop", &val); It is not as simple as that. There are a lot of optional properties. Say "prop" is optional? And not present. So -ENOENT. We then look for this deprecated property. That should not happen. Using of_property_read_u32(np, "deprecated-prop", &val) actually makes it stand out, it is special somehow, which is good, because it is special. Andrew
On Mon, Mar 23, 2026 at 11:39:03PM +0100, Andrew Lunn wrote: > > If there is a deprecated property you can do: > > > > error = device_property_read_u32(dev, "prop", &val); > > if (error == -ENOENT) > > error = device_property_read_u32(dev, "deprecated-prop", &val); > > It is not as simple as that. There are a lot of optional > properties. Say "prop" is optional? And not present. So -ENOENT. We > then look for this deprecated property. That should not happen. Why? That is exactly what you want: you favor new one if it is present and fall back to deprecated one if it is absent. And then you decide whether to continue or abort. Or you are saying that new property is optional but old one was mandatory? Not sure... > > Using of_property_read_u32(np, "deprecated-prop", &val) actually makes > it stand out, it is special somehow, which is good, because it is > special. If you only have of_property_read_u32() then it will not stand out. If you advocate of using device_property_read_u32() normally but of_property_read_u32() for deprecated only - that is a possibility, but I do not know if anyone does this. Thanks. -- Dmitry
On Mon, Mar 23, 2026 at 03:48:42PM -0700, Dmitry Torokhov wrote:
> On Mon, Mar 23, 2026 at 11:39:03PM +0100, Andrew Lunn wrote:
> > > If there is a deprecated property you can do:
> > >
> > > error = device_property_read_u32(dev, "prop", &val);
> > > if (error == -ENOENT)
> > > error = device_property_read_u32(dev, "deprecated-prop", &val);
> >
> > It is not as simple as that. There are a lot of optional
> > properties. Say "prop" is optional? And not present. So -ENOENT. We
> > then look for this deprecated property. That should not happen.
>
> Why? That is exactly what you want: you favor new one if it is present
> and fall back to deprecated one if it is absent. And then you decide
> whether to continue or abort.
The old property is only valid in DT, where it is deprecated, but
still valid. It should never appear in any other newer firmware
bindings.
> If you only have of_property_read_u32() then it will not stand out. If
> you advocate of using device_property_read_u32() normally but
> of_property_read_u32() for deprecated only - that is a possibility, but
> I do not know if anyone does this.
For the subsystems i've dealt with, when somebody proposes a patch
adding an ACPI binding, and they do an of_ to device_ conversion
without engaging brain, i point out the issues, they should not be
adding deprecated properties to a brand new binding, and they go away
and never come back. And so the code remains OF only. Which is fine,
nobody does networking devices using ACPI.
Andrew
On Mon, Mar 23, 2026 at 07:05:13PM +0000, Mark Brown wrote: > On Mon, Mar 23, 2026 at 11:28:27AM -0700, Dmitry Torokhov wrote: > > On Mon, Mar 23, 2026 at 02:00:43PM +0000, Mark Brown wrote: > > > > The regulator API is very deliberately specifically using the OF APIs, > > > not the ACPI APIs, since ACPI really doesn't want to model regulators. > > > For now? We also have software nodes and maybe we come up with something > > else in the future... > > > I think we should use firmware-agnostic APIs as much as possible, and > > only use OF- or ACPI-specific ones when there is no generic equivalent. > > This makes the code most flexible. > > I think this is a worrying idea for core code like this, we have > specific firmware bindings for specific firmware interfaces with the > different interfaces having very different ideas of how things should be > modelled. The chances that firmware agnostic code is going to do the > right thing seem low, and encouraging the use of generic APIs that might > happen to run OK raises the risk that we'll get firmware vendors relying > on them and leaving us with a conceptual mishmash to sort through. > > Software nodes are already a bit of a concern here TBH. Firmware vendors can introduce incompatible DT bindings and have them in their devices too and we have to deal with that... I think if this pushes closer ACPI and OF schemas for at least some subsystems closer to each other it would not be a bad thing. Thanks. -- Dmitry
On Mon, Mar 23, 2026 at 12:41:59PM -0700, Dmitry Torokhov wrote: > On Mon, Mar 23, 2026 at 07:05:13PM +0000, Mark Brown wrote: > > I think this is a worrying idea for core code like this, we have > > specific firmware bindings for specific firmware interfaces with the > > different interfaces having very different ideas of how things should be > > modelled. The chances that firmware agnostic code is going to do the > > right thing seem low, and encouraging the use of generic APIs that might > > happen to run OK raises the risk that we'll get firmware vendors relying > > on them and leaving us with a conceptual mishmash to sort through. > Firmware vendors can introduce incompatible DT bindings and have them in > their devices too and we have to deal with that... The case that's worrying me is mixing the ACPI and DT design models in one system, and especially having that happen to actually work without modification purely by luck rather than by design. > I think if this pushes closer ACPI and OF schemas for at least some > subsystems closer to each other it would not be a bad thing. I think we shouldn't be encouraging people to just throw random stuff at the wall and see if it happens to run OK with whatever OS they tried booting. The differences between ACPI and DT in areas like the regulator bindings are fundamental conceptual ones. There's some areas where things are closer and it winds up being fine actually, especially for leaf devices, but there's others where that's less likely.
On Mon, Mar 23, 2026 at 07:58:14PM +0000, Mark Brown wrote: > On Mon, Mar 23, 2026 at 12:41:59PM -0700, Dmitry Torokhov wrote: > > On Mon, Mar 23, 2026 at 07:05:13PM +0000, Mark Brown wrote: > > > > I think this is a worrying idea for core code like this, we have > > > specific firmware bindings for specific firmware interfaces with the > > > different interfaces having very different ideas of how things should be > > > modelled. The chances that firmware agnostic code is going to do the > > > right thing seem low, and encouraging the use of generic APIs that might > > > happen to run OK raises the risk that we'll get firmware vendors relying > > > on them and leaving us with a conceptual mishmash to sort through. > > > Firmware vendors can introduce incompatible DT bindings and have them in > > their devices too and we have to deal with that... > > The case that's worrying me is mixing the ACPI and DT design models in > one system, and especially having that happen to actually work without > modification purely by luck rather than by design. > > > I think if this pushes closer ACPI and OF schemas for at least some > > subsystems closer to each other it would not be a bad thing. > > I think we shouldn't be encouraging people to just throw random stuff at > the wall and see if it happens to run OK with whatever OS they tried > booting. The differences between ACPI and DT in areas like the > regulator bindings are fundamental conceptual ones. There's some areas > where things are closer and it winds up being fine actually, especially > for leaf devices, but there's others where that's less likely. Maybe we should just have explicit checks with nice comments at the beginning of the schema parsing stating that this schema is intentionally restricted to OF (or ACPI) in cases where we ave distinct schemas? This way it is explicit that it is a thought out decision and not simply a legacy artefact. I think we want to hanel software nodes because they do not form their own schemas, they follow the existing ones (DT usually). -- Dmitry
© 2016 - 2026 Red Hat, Inc.