From: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>
To: Joshua Crofts <joshua.crofts1@gmail.com>
Cc: "Andy Shevchenko" <andriy.shevchenko@intel.com>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4] iio: light: opt3001: split opt3001_get_processed() logic
Date: Mon, 20 Jul 2026 02:50:27 +0100 [thread overview]
Message-ID: <20260720025027.20f2083f@jic23-huawei> (raw)
In-Reply-To: <20260715100958.000046d9@gmail.com>
On Wed, 15 Jul 2026 10:09:58 +0200
Joshua Crofts <joshua.crofts1@gmail.com> wrote:
> On Tue, 14 Jul 2026 20:04:10 +0300
> Andy Shevchenko <andriy.shevchenko@intel.com> wrote:
> > > - if (ret < 0) {
> > > + if (ret < 0)
> >
> > At some point consider dropping ' < 0' pieces for the i2c_smbus_write_*() cases.
> > Read cases are different, of course.
Excellent point Andy, and this case is a bit special..
> >
> > > dev_err(dev, "failed to write register %02x\n",
> > > OPT3001_CONFIGURATION);
> > > +
> > > + return ret;
If ret could be positive then this would be letting an unexpected
positive return value escape the function. So I've tweaked the two
cases of this pattern to if (ret) to avoid that implication.
Applied with
diff --git a/drivers/iio/light/opt3001.c b/drivers/iio/light/opt3001.c
index 12cfb0e58870..a948353014ac 100644
--- a/drivers/iio/light/opt3001.c
+++ b/drivers/iio/light/opt3001.c
@@ -337,7 +337,7 @@ static int opt3001_start_conversion(struct opt3001 *opt)
opt3001_set_mode(opt, ®, OPT3001_CONFIGURATION_M_SINGLE);
ret = i2c_smbus_write_word_swapped(client, OPT3001_CONFIGURATION, reg);
- if (ret < 0)
+ if (ret)
dev_err(dev, "failed to write register %02x\n",
OPT3001_CONFIGURATION);
@@ -392,7 +392,7 @@ static int opt3001_get_processed_irq(struct opt3001 *opt)
*/
value = (opt->low_thresh_exp << 12) | opt->low_thresh_mantissa;
ret = i2c_smbus_write_word_swapped(client, OPT3001_LOW_LIMIT, value);
- if (ret < 0)
+ if (ret)
dev_err(dev, "failed to write register %02x\n",
OPT3001_LOW_LIMIT);
> >
>
> Even after an 8-part patch set, this driver still needs cleaning up!
>
:) You'd be amazed how many patches it takes to clean up some drivers
that are in 'reasonable' condition!
Jonathan
prev parent reply other threads:[~2026-07-20 1:50 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 15:36 [PATCH v4] iio: light: opt3001: split opt3001_get_processed() logic Joshua Crofts
2026-07-14 17:04 ` Andy Shevchenko
2026-07-15 8:09 ` Joshua Crofts
2026-07-20 1:50 ` Jonathan Cameron [this message]
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=20260720025027.20f2083f@jic23-huawei \
--to=jonathan.cameron@oss.qualcomm.com \
--cc=andriy.shevchenko@intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=joshua.crofts1@gmail.com \
--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