mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nikhil Gautam <nikhilgtr@gmail.com>
To: Jonathan Cameron <jic23@kernel.org>
Cc: "David Lechner" <dlechner@baylibre.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Andy Shevchenko" <andy@kernel.org>,
	"Stefan Windfeldt-Prytz" <stefan.windfeldt-prytz@axis.com>,
	linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
	"Nikhil Gautam" <nikhilgtr@gmail.com>
Subject: [PATCH v3 3/4] iio: light: opt4001: Reject integration times with a non-zero seconds part
Date: Tue, 14 Jul 2026 17:01:33 +0530	[thread overview]
Message-ID: <20260714113134.3445-4-nikhilgtr@gmail.com> (raw)
In-Reply-To: <20260714113134.3445-1-nikhilgtr@gmail.com>

opt4001_write_raw() only looks at val2 when setting the integration
time, so a write such as 1.000600 is silently accepted as 600 us.
Return -EINVAL if val is non-zero.

Fixes: 9a9608418292 ("iio: light: Add support for TI OPT4001 light sensor")
Signed-off-by: Nikhil Gautam <nikhilgtr@gmail.com>
---
 drivers/iio/light/opt4001.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/iio/light/opt4001.c b/drivers/iio/light/opt4001.c
index a0f174888384..bb4be6384e4c 100644
--- a/drivers/iio/light/opt4001.c
+++ b/drivers/iio/light/opt4001.c
@@ -269,6 +269,9 @@ static int opt4001_write_raw(struct iio_dev *indio_dev,
 
 	switch (mask) {
 	case IIO_CHAN_INFO_INT_TIME:
+		if (val)
+			return -EINVAL;
+
 		int_time = opt4001_als_time_to_index(val2);
 		if (int_time < 0)
 			return int_time;
-- 
2.39.5


  parent reply	other threads:[~2026-07-14 11:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14 11:31 [PATCH v3 0/4] iio: light: opt4001: Fixes from code review Nikhil Gautam
2026-07-14 11:31 ` [PATCH v3 1/4] iio: light: opt4001: Fix power down clearing bits of the wrong register Nikhil Gautam
2026-07-14 11:31 ` [PATCH v3 2/4] iio: light: opt4001: Fix incompatible pointer type passed to div_u64_rem() Nikhil Gautam
2026-07-14 11:31 ` Nikhil Gautam [this message]
2026-07-14 11:31 ` [PATCH v3 4/4] iio: light: opt4001: Fix reversed GENMASK() arguments in fault count mask Nikhil Gautam
2026-07-14 12:44 ` [PATCH v3 0/4] iio: light: opt4001: Fixes from code review Andy Shevchenko

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=20260714113134.3445-4-nikhilgtr@gmail.com \
    --to=nikhilgtr@gmail.com \
    --cc=andy@kernel.org \
    --cc=dlechner@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nuno.sa@analog.com \
    --cc=stefan.windfeldt-prytz@axis.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

Powered by JetHome