Re: [PATCH v2 2/2] iio: adc: ti-ads112c14: add gpio support
From: Andy Shevchenko
Date: Thu Oct 15 2026 - 09:59:26 EST
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@xxxxxxxxxxxx> 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.
--
With Best Regards,
Andy Shevchenko