From: Sean Anderson <sean.anderson@linux.dev>
To: Rob Herring <robh@kernel.org>
Cc: Saravana Kannan <saravanak@google.com>,
devicetree@vger.kernel.org,
Sakari Ailus <sakari.ailus@linux.intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J . Wysocki" <rafael@kernel.org>,
Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Len Brown <lenb@kernel.org>,
Heikki Krogerus <heikki.krogerus@linux.intel.com>,
Daniel Scally <djrscally@gmail.com>,
linux-kernel@vger.kernel.org, Danilo Krummrich <dakr@kernel.org>,
linux-acpi@vger.kernel.org
Subject: Re: [PATCH 2/2] device property: Add fwnode_property_get_reference_optional_args
Date: Tue, 8 Apr 2025 11:28:40 -0400 [thread overview]
Message-ID: <2d674a0e-9a54-4315-bd81-0cb3a2fb1602@linux.dev> (raw)
In-Reply-To: <CAL_JsqJ_EqsxrY67OPm+t6tU5ikFA-TZ-fFqHPYQMuy16c_kLg@mail.gmail.com>
On 4/8/25 11:19, Rob Herring wrote:
> On Tue, Apr 8, 2025 at 10:12 AM Sean Anderson <sean.anderson@linux.dev> wrote:
>>
>> On 4/8/25 09:00, Rob Herring wrote:
>> > On Mon, Apr 7, 2025 at 5:37 PM Sean Anderson <sean.anderson@linux.dev> wrote:
>> >>
>> >> Add a fwnode variant of of_parse_phandle_with_optional_args to allow
>> >> nargs_prop to be absent from the referenced node. This improves
>> >> compatibility for references where the devicetree might not always have
>> >> nargs_prop.
>> >
>> > Can't we just make fwnode_property_get_reference_args() handle this
>> > case? Or why is it not just a 1 line wrapper function?
>>
>> fwnode_property_get_reference_args ignores nargs when nargs_prop is
>> non-NULL. So all the existing callers just pass 0 to nargs. Rather than
>> convert them, I chose to add another function with different defaults.
>> There are only four callers that pass nargs_prop, so I could just as
>> easily change the callers instead.
>
> Why do you have to change the callers? nargs value won't matter
> because they obviously have nargs_prop present or they would not have
> worked in the first place. If behavior changes because there's an
> error in their DT, who cares. That's their problem for not validating
> the DT.
Because the change would be to make nargs matter even when nargs_prop is
present. For the sake of example, consider something like
foo: foo {
#my-cells = <1>;
};
bar: bar {
};
baz {
my-prop = <&bar>, <&foo 5>, ;
my-prop-names = "bar", "foo";
};
Before we would have
fwnode_property_get_reference_args(baz, "my-prop", NULL, 0, "bar", args) <bar>
fwnode_property_get_reference_args(baz, "my-prop", NULL, 0, "foo", args) <foo>
fwnode_property_get_reference_args(baz, "my-prop", "#my-cells", -1, "bar", args) ERROR
fwnode_property_get_reference_args(baz, "my-prop", "#my-cells", -1, "foo", args) ERROR
fwnode_property_get_reference_args(baz, "my-prop", "#my-cells", 0, "bar", args) ERROR
fwnode_property_get_reference_args(baz, "my-prop", "#my-cells", 0, "foo", args) ERROR
and after we would have
fwnode_property_get_reference_args(baz, "my-prop", NULL, 0, "bar", args) <bar>
fwnode_property_get_reference_args(baz, "my-prop", NULL, 0, "foo", args) <foo>
fwnode_property_get_reference_args(baz, "my-prop", "#my-cells", -1, "bar", args) ERROR
fwnode_property_get_reference_args(baz, "my-prop", "#my-cells", -1, "foo", args) ERROR
fwnode_property_get_reference_args(baz, "my-prop", "#my-cells", 0, "bar", args) <bar>
fwnode_property_get_reference_args(baz, "my-prop", "#my-cells", 0, "foo", args) <foo 5>
The problem is that all existing callers pass nargs=0 when
nargs_prop="#my-cells" so they will get the new behavior even when they
shouldn't. So if we change the behavior we have to change the callers
too. If we make a new function with new behavior the callers stay the
same.
--Sean
next prev parent reply other threads:[~2025-04-08 15:28 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-07 22:37 [PATCH 0/2] device property: Add fwnode_property_get_reference_optional_args Sean Anderson
2025-04-07 22:37 ` [PATCH 1/2] device property: Add optional nargs_prop for get_reference_args Sean Anderson
2025-04-08 8:37 ` Andy Shevchenko
2025-04-08 12:52 ` Rob Herring
2025-04-08 9:14 ` Sakari Ailus
2025-04-08 12:55 ` Rob Herring
2025-04-07 22:37 ` [PATCH 2/2] device property: Add fwnode_property_get_reference_optional_args Sean Anderson
2025-04-08 8:39 ` Andy Shevchenko
2025-04-08 15:10 ` Sean Anderson
2025-04-08 13:00 ` Rob Herring
2025-04-08 15:12 ` Sean Anderson
2025-04-08 15:19 ` Rob Herring
2025-04-08 15:28 ` Sean Anderson [this message]
2025-04-08 17:19 ` Rob Herring
2025-04-08 8:40 ` [PATCH 0/2] " Andy Shevchenko
2025-04-08 15:13 ` Sean Anderson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2d674a0e-9a54-4315-bd81-0cb3a2fb1602@linux.dev \
--to=sean.anderson@linux.dev \
--cc=andriy.shevchenko@linux.intel.com \
--cc=dakr@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=djrscally@gmail.com \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rafael@kernel.org \
--cc=robh@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=saravanak@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.