From: Andy Shevchenko <andriy.shevchenko@intel.com>
To: David Lechner <dlechner@baylibre.com>, Rob Herring <robh@kernel.org>
Cc: "Bartosz Golaszewski" <brgl@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-gpio@vger.kernel.org, "Chris Hall" <c-hall@ti.com>,
"Patrick Edwards" <pedwards@ti.com>,
"Kurt Borja" <kuurtb@gmail.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Linus Walleij" <linusw@kernel.org>
Subject: Re: [PATCH v2 2/2] iio: adc: ti-ads112c14: add gpio support
Date: Thu, 15 Oct 2026 21:16:44 +0300 [thread overview]
Message-ID: <atEYjMpwn0yKFBk3@ashevche-desk.local> (raw)
In-Reply-To: <11c08f9a-091d-43fb-8c1e-f3f2fe6ec3c2@baylibre.com>
+Cc: Rob. Here is a discussion how properly to check if the specific node has
gpio-controller flag set. I tend to say that in the case of a simple branch
(in opposite to if-else) we should use _property_present() and not
_property_read_bool(). Can you be an arbiter here and tell the correct way
of doing this?
On Thu, Oct 15, 2026 at 09:04:58AM -0500, David Lechner wrote:
> On 10/15/26 8:37 AM, Andy Shevchenko wrote:
> > On Thu, Oct 15, 2026 at 08:01:14AM -0500, David Lechner wrote:
> >> On 10/13/26 9:05 AM, Andy Shevchenko wrote:
> >>> On Sat, Oct 10, 2026 at 08:46:30AM -0500, David Lechner wrote:
> >>>> On 10/10/26 4:00 AM, Bartosz Golaszewski wrote:
> >>>>> On Sat, 10 Oct 2026 01:25:52 +0200, "David Lechner (TI)"
> >>>>> <dlechner@baylibre.com> said:
...
> >>>>>> + if (device_property_read_bool(dev, "gpio-controller")) {
> >>>>>
> >>>>> I think the right one to use is device_property_present().
> >>>>
> >>>> I thought this was the one case where device_property_read_bool() is
> >>>> actually correct because gpio-controller property is a
> >>>> /schemas/types.yaml#/definitions/flag.
> >>>>
> >>>> Otherwise, we should just remove device_property_read_bool() from the tree
> >>>> because there would never be a reason to use it.
> >>>>
> >>>> My understanding is we should use device_property_present() for non-boolean
> >>>> properties when we want to know if it is present or not before reading the
> >>>> value of it.
> >>>
> >>> That's not true. The _property_present() checks any type of property, while
> >>> _property_read_bool() returns an actual value of the flag, while they might
> >>> overlap in the behaviour, they are semantically completely different.
> >>
> >> That is exactly what I said.
> >
> > But you made a code different. As I read it it checks for "is the
> > gpio-controller property present?" For the question that you may
> > think off "is the gpio-controller flag is true?" I consider rather
> > if-else branch as we *either* option.
> >
> > So, when we do
> >
> > if (...check_flag...)
> > do_smth();
> >
> > I assume we check the presence of the property (flag). If we do
> >
> > x = ...read_flag...;
> >
> > OR
> >
> > if (...read_flag... == true)
> > do_smth();
> > else
> > do_smth_else();
> >
> > I consider the appropriate is reading the property.
> >
>
> Are you saying flag != boolean DT property type?
No, I'm saying that semantics is defined also in the context of use. In your
case you check for the property presence and do not use it as a value.
> type: boolean
>
> vs.
>
> $ref: /schemas/types.yaml#/definitions/flag
>
> I know we have both names in dt-bindings but I don't know the history on it
> and if we consider them semantically different.
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2026-10-15 18:16 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 23:25 [PATCH v2 0/2] " David Lechner (TI)
2026-10-09 23:25 ` [PATCH v2 1/2] iio: adc: ti-ads112c14: parameterize GPIO register field macros David Lechner (TI)
2026-10-10 9:00 ` Bartosz Golaszewski
2026-10-09 23:25 ` [PATCH v2 2/2] iio: adc: ti-ads112c14: add gpio support David Lechner (TI)
2026-10-10 9:00 ` Bartosz Golaszewski
2026-10-10 13:46 ` David Lechner
2026-10-13 14:05 ` Andy Shevchenko
2026-10-15 13:01 ` David Lechner
2026-10-15 13:37 ` Andy Shevchenko
2026-10-15 14:04 ` David Lechner
2026-10-15 18:16 ` Andy Shevchenko [this message]
2026-10-13 14:07 ` Andy Shevchenko
2026-10-15 13:02 ` David Lechner
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=atEYjMpwn0yKFBk3@ashevche-desk.local \
--to=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=brgl@kernel.org \
--cc=c-hall@ti.com \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=kuurtb@gmail.com \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nuno.sa@analog.com \
--cc=pedwards@ti.com \
--cc=robh@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®