From: Jonathan Cameron <jic23@kernel.org>
To: Vasileios Amoiridis <vassilisamir@gmail.com>
Cc: lars@metafoo.de, andriy.shevchenko@linux.intel.com,
ang.iglesiasg@gmail.com, mazziesaccount@gmail.com,
ak@it-klinger.de, petre.rodan@subdimension.ro,
phil@raspberrypi.com, 579lpy@gmail.com, linus.walleij@linaro.org,
semen.protsenko@linaro.org, linux-iio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 05/10] iio: pressure: bmp280: Make return values consistent
Date: Sun, 5 May 2024 20:08:18 +0100 [thread overview]
Message-ID: <20240505200818.1e70c664@jic23-huawei> (raw)
In-Reply-To: <20240429190046.24252-6-vassilisamir@gmail.com>
On Mon, 29 Apr 2024 21:00:41 +0200
Vasileios Amoiridis <vassilisamir@gmail.com> wrote:
> Throughout the driver there are quite a few places were return
> values are treated as errors if they are negative or not-zero.
> This commit tries to make the return values of those functions
> consistent and treat them as errors in case there is a negative
> value since the vast majority of the functions are returning
> erorrs coming from regmap_*() functions.
The changes are fine, but that argument isn't correct.
regmap_*() functions never (that I can recall) return positive
values, so if (ret) would be valid for those and I'd have expected
the exact opposite outcome if you are looking at regmap*() return
values to make the decision.
The if (ret) pattern is sometimes used throughout because it
makes
return function()
consistent without needing to do
ret = function();
if (ret < 0)
return ret;
return 0;
That pattern isn't particularly common in this driver (there are few cases).
We also tend not to worry too much about that slight inconsistency though
in a few cases it has lead to compilers failing to detect that some paths
are not possible and reporting false warnings.
However, all arguments about which is 'better' aside, key is that consistency
(either choice) is better than a mix. So I'm fine with ret < 0 on basis
it's the most common in this driver being your justification. Just don't
blame regmap*() return values!
>
> While at it, add error messages that were not implemented before.
>
> Finally, remove any extra error checks that are dead code.
Ideally this would be broken up a little more as, whilst all error
code related, these aren't all the same thing.
I'd have preferred:
1) Dead code removal.
2) Message updates.
3) Switch to consistent ret handling.
However it isn't that bad as a single patch, so just address the question
above and I think this will be fine as one patch.
>
> Signed-off-by: Vasileios Amoiridis <vassilisamir@gmail.com>
Jonathan
next prev parent reply other threads:[~2024-05-05 19:08 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 19:00 [PATCH v5 00/10] iio: pressure: bmp280: Driver cleanup and add triggered buffer support Vasileios Amoiridis
2024-04-29 19:00 ` [PATCH v5 01/10] iio: pressure: bmp280: Improve indentation and line wrapping Vasileios Amoiridis
2024-05-05 18:51 ` Jonathan Cameron
2024-05-06 0:04 ` Vasileios Amoiridis
2024-05-06 12:38 ` Jonathan Cameron
2024-04-29 19:00 ` [PATCH v5 02/10] iio: pressure: bmp280: Use BME prefix for BME280 specifics Vasileios Amoiridis
2024-05-05 18:53 ` Jonathan Cameron
2024-04-29 19:00 ` [PATCH v5 03/10] iio: pressure: bmp280: Add identifier names in function definitions Vasileios Amoiridis
2024-05-05 18:54 ` Jonathan Cameron
2024-04-29 19:00 ` [PATCH v5 04/10] iio: pressure: bmp280: Add more intuitive name for bmp180_measure() Vasileios Amoiridis
2024-04-29 19:00 ` [PATCH v5 05/10] iio: pressure: bmp280: Make return values consistent Vasileios Amoiridis
2024-05-05 19:08 ` Jonathan Cameron [this message]
2024-05-05 23:08 ` Vasileios Amoiridis
2024-04-29 19:00 ` [PATCH v5 06/10] iio: pressure: bmp280: Refactorize reading functions Vasileios Amoiridis
2024-05-05 19:21 ` Jonathan Cameron
2024-05-05 23:47 ` Vasileios Amoiridis
2024-05-06 12:46 ` Jonathan Cameron
2024-04-29 19:00 ` [PATCH v5 07/10] iio: pressure: bmp280: Introduce new cleanup routines Vasileios Amoiridis
2024-05-05 19:22 ` Jonathan Cameron
2024-04-29 19:00 ` [PATCH v5 08/10] iio: pressure: bmp280: Generalize read_{temp,press,humid}() functions Vasileios Amoiridis
2024-04-29 19:00 ` [PATCH v5 09/10] iio: pressure: bmp280: Add SCALE, RAW values in channels and refactorize them Vasileios Amoiridis
2024-04-29 19:00 ` [PATCH v5 10/10] iio: pressure: bmp280: Add triggered buffer support Vasileios Amoiridis
2024-05-05 19:34 ` Jonathan Cameron
2024-05-05 23:57 ` Vasileios Amoiridis
2024-05-06 12:50 ` 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=20240505200818.1e70c664@jic23-huawei \
--to=jic23@kernel.org \
--cc=579lpy@gmail.com \
--cc=ak@it-klinger.de \
--cc=andriy.shevchenko@linux.intel.com \
--cc=ang.iglesiasg@gmail.com \
--cc=lars@metafoo.de \
--cc=linus.walleij@linaro.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mazziesaccount@gmail.com \
--cc=petre.rodan@subdimension.ro \
--cc=phil@raspberrypi.com \
--cc=semen.protsenko@linaro.org \
--cc=vassilisamir@gmail.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