From: David Lechner <dlechner@baylibre.com>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Cc: "Andy Shevchenko" <andriy.shevchenko@intel.com>,
"Jonathan Cameron" <jic23@kernel.org>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Linus Walleij" <linusw@kernel.org>,
"Bartosz Golaszewski" <brgl@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-gpio@vger.kernel.org
Subject: Re: [PATCH v2 3/4] iio: adc: ti-ads7950: switch to using guard() notation
Date: Mon, 23 Feb 2026 10:35:25 -0600 [thread overview]
Message-ID: <b1470903-f703-4408-b009-a4bdbb9ca4cf@baylibre.com> (raw)
In-Reply-To: <aZt0IGNW2hddXvRZ@google.com>
On 2/22/26 3:31 PM, Dmitry Torokhov wrote:
> On Sat, Feb 21, 2026 at 11:20:42AM -0600, David Lechner wrote:
>> On 2/19/26 1:51 AM, Andy Shevchenko wrote:
>>> On Wed, Feb 18, 2026 at 06:29:27PM -0800, Dmitry Torokhov wrote:
>>>> guard() notation allows early returns when encountering errors, making
>>>
>>> guard()()
>>>
>>> // strictly speaking
>>>
>>>> control flow more obvious. Use it.
>>>
>>> I like the change, but...
>>>
>>>> Also variables that now only hold error codes (or 0) are renamed to
>>>> "error" to make their purpose clearer.
>>
>> Normally I would not give my opinion on this, but since I wrote the driver
>> originally, I will say please don't rename. I prefer to always use "ret".
>
> I hope I can convince you otherwise.
I'm afraid not. "ret" is used > 35k times in IIO and err is used < 3k times
and error < 1k times. So I am really used to seeing only "ret" for errors and
"error" looks very unusual to my eyes because of this.
You mentioned valuing the common pattern in your other reply, so I hope
you can understand that this is what I value more here.
>
> IMO "ret" or "retval" should be used when the returned value is intended
> to be used during normal operation. For cases where we only expect to
> have an error or 0 for success "error" or "err" is more appropriate.
> This allows you to write
>
> error = do_action(...);
> if (error) {
> // handle error somehow, typically simply report.
> }
>
> This also helps when reading the code as you know that there is usually
> no reason to care about the specific value in this variable (maybe
> except -EPROBE_DEFER).
>
> I will push the conversion ret -> error to the very last patch so it can
> easily be dropped if I am unsuccessful in swaying your opinion.
>
> Thanks.
>
To give you fair warning, it will still be NAK from me.
next prev parent reply other threads:[~2026-02-23 16:35 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-19 2:29 [PATCH v2 0/4] ti-ads7950: fix gpio handling and facelift Dmitry Torokhov
2026-02-19 2:29 ` [PATCH v2 1/4] iio: adc: ti-ads7950: normalize return value of gpio_get Dmitry Torokhov
2026-02-19 7:52 ` Andy Shevchenko
2026-02-19 9:17 ` Bartosz Golaszewski
2026-02-19 18:25 ` Linus Walleij
2026-02-22 14:03 ` Jonathan Cameron
2026-02-22 21:22 ` Dmitry Torokhov
2026-02-19 2:29 ` [PATCH v2 2/4] iio: adc: ti-ads7950: do not clobber gpio state in ti_ads7950_get() Dmitry Torokhov
2026-02-19 7:55 ` Andy Shevchenko
2026-02-21 17:21 ` David Lechner
2026-02-19 2:29 ` [PATCH v2 3/4] iio: adc: ti-ads7950: switch to using guard() notation Dmitry Torokhov
2026-02-19 7:51 ` Andy Shevchenko
2026-02-21 17:20 ` David Lechner
2026-02-22 21:31 ` Dmitry Torokhov
2026-02-23 16:35 ` David Lechner [this message]
2026-02-21 17:34 ` David Lechner
2026-02-22 21:37 ` Dmitry Torokhov
2026-02-23 16:31 ` David Lechner
2026-02-19 2:29 ` [PATCH v2 4/4] iio: adc: ti-ads7950: complete conversion to using managed resources Dmitry Torokhov
2026-02-19 7:59 ` Andy Shevchenko
2026-02-21 0:09 ` Dmitry Torokhov
2026-02-22 19:12 ` Andy Shevchenko
2026-02-23 20:52 ` Jonathan Cameron
2026-02-21 17:43 ` David Lechner
2026-02-22 14:09 ` Jonathan Cameron
2026-02-22 21:39 ` Dmitry Torokhov
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=b1470903-f703-4408-b009-a4bdbb9ca4cf@baylibre.com \
--to=dlechner@baylibre.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=brgl@kernel.org \
--cc=dmitry.torokhov@gmail.com \
--cc=jic23@kernel.org \
--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 \
/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®