From: Roman Vivchar via B4 Relay <devnull+rva333.protonmail.com@kernel.org>
To: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Matthias Brugger" <matthias.bgg@gmail.com>,
"AngeloGioacchino Del Regno"
<angelogioacchino.delregno@collabora.com>,
"Nícolas F. R. A. Prado" <nfraprado@collabora.com>
Cc: Chen-Yu Tsai <wenst@chromium.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org,
Roman Vivchar <rva333@protonmail.com>,
Jonathan Cameron <jic23@kernel.org>
Subject: [PATCH v2 3/3] iio: adc: mt6359-auxadc: fix scale calculation
Date: Tue, 17 Nov 2026 19:56:34 +0200 [thread overview]
Message-ID: <20261117-6768-6358-fixes-v2-3-1ffc3c2f3c80@protonmail.com> (raw)
In-Reply-To: <20261117-6768-6358-fixes-v2-0-1ffc3c2f3c80@protonmail.com>
From: Roman Vivchar <rva333@protonmail.com>
IIO_CHAN_INFO_SCALE currently returns value without dividing by
2^realbits, overflowing the integer to an invalid value.
Fix this by using IIO_VAL_FRACTIONAL and setting val2 to the ADC
resolution.
Fixes: 3587914bf61d ("iio: adc: Add support for MediaTek MT6357/8/9 Auxiliary ADC")
Signed-off-by: Roman Vivchar <rva333@protonmail.com>
---
drivers/iio/adc/mt6359-auxadc.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/drivers/iio/adc/mt6359-auxadc.c b/drivers/iio/adc/mt6359-auxadc.c
index 09432d0974cf..3a969c30f633 100644
--- a/drivers/iio/adc/mt6359-auxadc.c
+++ b/drivers/iio/adc/mt6359-auxadc.c
@@ -770,13 +770,9 @@ static int mt6359_auxadc_read_raw(struct iio_dev *indio_dev,
if (mask == IIO_CHAN_INFO_SCALE) {
*val = desc->r_ratio.numerator * cinfo->vref_mV;
+ *val2 = desc->r_ratio.denominator << chan->scan_type.realbits;
- if (desc->r_ratio.denominator > 1) {
- *val2 = desc->r_ratio.denominator;
- return IIO_VAL_FRACTIONAL;
- }
-
- return IIO_VAL_INT;
+ return IIO_VAL_FRACTIONAL;
}
scoped_guard(mutex, &adc_dev->lock) {
--
2.56.1
next prev parent reply other threads:[~2026-11-17 17:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-17 17:56 [PATCH v2 0/3] iio: adc: mt6359-auxadc: various fixes Roman Vivchar via B4 Relay
2026-11-17 17:56 ` [PATCH v2 1/3] iio: adc: mt6359-auxadc: correct channel types to IIO_VOLTAGE Roman Vivchar via B4 Relay
2026-11-17 17:56 ` [PATCH v2 2/3] iio: adc: mt6359-auxadc: mask conversion ready bit in mt6358_read_imp Roman Vivchar via B4 Relay
2026-11-17 17:56 ` Roman Vivchar via B4 Relay [this message]
2026-11-21 23:56 ` [PATCH v2 0/3] iio: adc: mt6359-auxadc: various fixes 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=20261117-6768-6358-fixes-v2-3-1ffc3c2f3c80@protonmail.com \
--to=devnull+rva333.protonmail.com@kernel.org \
--cc=andy@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=nfraprado@collabora.com \
--cc=nuno.sa@analog.com \
--cc=rva333@protonmail.com \
--cc=wenst@chromium.org \
/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®