From: Jonathan Cameron <jic23@kernel.org>
To: Andy Shevchenko <andy@kernel.org>
Cc: "Ceclan Dumitru" <mitrutzceclan@gmail.com>,
"Jonathan Cameron" <Jonathan.Cameron@huawei.com>,
linus.walleij@linaro.org, brgl@bgdev.pl,
linux-gpio@vger.kernel.org,
"Lars-Peter Clausen" <lars@metafoo.de>,
"Rob Herring" <robh+dt@kernel.org>,
"Krzysztof Kozlowski" <krzysztof.kozlowski+dt@linaro.org>,
"Conor Dooley" <conor+dt@kernel.org>,
"Michael Walle" <michael@walle.cc>,
"Arnd Bergmann" <arnd@arndb.de>,
"ChiaEn Wu" <chiaen_wu@richtek.com>,
"Niklas Schnelle" <schnelle@linux.ibm.com>,
"Leonard Göhrs" <l.goehrs@pengutronix.de>,
"Mike Looijmans" <mike.looijmans@topic.nl>,
"Haibo Chen" <haibo.chen@nxp.com>,
"Hugo Villeneuve" <hvilleneuve@dimonoff.com>,
"Ceclan Dumitru" <dumitru.ceclan@analog.com>,
linux-iio@vger.kernel.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v8 2/2] iio: adc: ad7173: add AD7173 driver
Date: Sun, 17 Dec 2023 13:31:12 +0000 [thread overview]
Message-ID: <20231217133112.0054ef56@jic23-huawei> (raw)
In-Reply-To: <ZXsVgVzcK6Om4td_@smile.fi.intel.com>
On Thu, 14 Dec 2023 16:47:29 +0200
Andy Shevchenko <andy@kernel.org> wrote:
> On Thu, Dec 14, 2023 at 02:57:35PM +0200, Ceclan Dumitru wrote:
> > On 12/14/23 14:30, Jonathan Cameron wrote:
> > > On Tue, 12 Dec 2023 12:44:36 +0200
> > > Dumitru Ceclan <mitrutzceclan@gmail.com> wrote:
>
> ...
>
> > >> + ret = fwnode_property_match_property_string(child,
> > >> + "adi,reference-select",
> > >> + ad7173_ref_sel_str,
> > >> + ARRAY_SIZE(ad7173_ref_sel_str));
>
> > >> +
>
> Redundant blank line.
>
> > >> + if (ret < 0)
> > >> + ref_sel = AD7173_SETUP_REF_SEL_INT_REF;
> > >> + else
> > >> + ref_sel = ret;
> > > Simpler pattern for properties with a default is not to check the error code.
> > >
> > > ref_sel = AD7173_SETUP_REF_SEL_INT_REF;
> > >
> > > fwnode_property_match_property_String(child, ...
> > >
> > > so only if it succeeds is the value overridden.
> >
> > Where exactly would the value be overridden, the function does not have an
> > argument passed for the found index. The function is written to return either
> > the found index or a negative error.
> >
> > The proposed pattern would just ignore the returned index and would always
> > leave ref_sel to default. Am I missing something?
> >
> > I can see in the thread where it was introduced that you proposed:
> > "Looking at the usecases I wonder if it would be better to pass in
> > an unsigned int *ret which is only updated on a match?"
> >
> > But on the iio togreg branch that was suggested I could the function on, it
> > does not have that parameter.
>
> Yeah, with the current API we can have one check (no 'else' branch):
>
> ref_sel = AD7173_SETUP_REF_SEL_INT_REF;
> ret = ...
> if (ret >= 0)
> ref_sel = ret;
>
Yeah. I was clearly lacking in coffee or just being an idiot that day!
> But your approach is good to me.
>
> ...
>
> It's always possible to change prototype, and now of course is the best time
> as all the users are provided in the single tree. That said, patches are
> welcome if this is what we want. (My proposal was to return index in case of
> no error, but at the same time leave it in the returned code, so it will be
> aligned with other match functions of fwnode.
>
> But this in either way will complicate the implementation. And I don't find
> critical to have if-else in each caller as some of them may do something
> different on the error case, when option is mandatory. In such cases we
> usually don't provide output if we know that an error condition occurs.
I'm fine with it being as it is. Was just having a slow brain day.
J
>
next prev parent reply other threads:[~2023-12-17 13:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 10:44 [PATCH v8 1/2] dt-bindings: adc: add AD7173 Dumitru Ceclan
2023-12-12 10:44 ` [PATCH v8 2/2] iio: adc: ad7173: add AD7173 driver Dumitru Ceclan
2023-12-13 14:24 ` Andy Shevchenko
2023-12-14 11:02 ` Ceclan Dumitru
2023-12-14 12:30 ` Jonathan Cameron
2023-12-14 12:57 ` Ceclan Dumitru
2023-12-14 14:47 ` Andy Shevchenko
2023-12-17 13:31 ` Jonathan Cameron [this message]
2023-12-12 15:09 ` [PATCH v8 1/2] dt-bindings: adc: add AD7173 David Lechner
2023-12-14 12:43 ` Ceclan Dumitru
2023-12-14 16:12 ` David Lechner
2023-12-14 17:03 ` Ceclan Dumitru
2023-12-17 13:50 ` Jonathan Cameron
2023-12-18 1:00 ` David Lechner
2023-12-20 12:38 ` Jonathan Cameron
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=20231217133112.0054ef56@jic23-huawei \
--to=jic23@kernel.org \
--cc=Jonathan.Cameron@huawei.com \
--cc=andy@kernel.org \
--cc=arnd@arndb.de \
--cc=brgl@bgdev.pl \
--cc=chiaen_wu@richtek.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dumitru.ceclan@analog.com \
--cc=haibo.chen@nxp.com \
--cc=hvilleneuve@dimonoff.com \
--cc=krzysztof.kozlowski+dt@linaro.org \
--cc=l.goehrs@pengutronix.de \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=michael@walle.cc \
--cc=mike.looijmans@topic.nl \
--cc=mitrutzceclan@gmail.com \
--cc=robh+dt@kernel.org \
--cc=schnelle@linux.ibm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox