mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>,
	Marcelo Schmitt <marcelo.schmitt@analog.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Cristian Ciocaltea <cristian.ciocaltea@collabora.com>,
	linux@analog.com, linux-iio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: "Michael Hennerich" <michael.hennerich@analog.com>,
	"Nuno Sá" <nuno.sa@analog.com>,
	"Esteban Blanc" <eblanc@baylibre.com>,
	"Jonathan Cameron" <jic23@kernel.org>,
	"David Lechner" <dlechner@baylibre.com>,
	"Andy Shevchenko" <andy@kernel.org>
Subject: [PATCH v1 2/3] iio: adc: ad4030: Switch to use mult_fract() helper
Date: Tue, 17 Nov 2026 10:14:41 +0100	[thread overview]
Message-ID: <20261117091638.1463621-3-andriy.shevchenko@linux.intel.com> (raw)
In-Reply-To: <20261117091638.1463621-1-andriy.shevchenko@linux.intel.com>

Switch the driver to use mult_fract() helper.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/iio/adc/ad4030.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/iio/adc/ad4030.c b/drivers/iio/adc/ad4030.c
index 877b06007396..d61950129083 100644
--- a/drivers/iio/adc/ad4030.c
+++ b/drivers/iio/adc/ad4030.c
@@ -161,11 +161,11 @@ static const int adaq4216_hw_gains_vpv[] = {
 	20 * MILLI / 3,		/* 0.6666 */
 };
 
-static const int adaq4216_hw_gains_frac[][2] = {
-	{ 1, 3 },  /* 1/3 V/V gain */
-	{ 5, 9 },  /* 5/9 V/V gain */
-	{ 20, 9 }, /* 20/9 V/V gain */
-	{ 20, 3 }, /* 20/3 V/V gain */
+static const struct s32_fract adaq4216_hw_gains_frac[] = {
+	{ .numerator = 3, .denominator = 1 },  /* 1/3 V/V gain */
+	{ .numerator = 9, .denominator = 5 },  /* 5/9 V/V gain */
+	{ .numerator = 9, .denominator = 20 }, /* 20/9 V/V gain */
+	{ .numerator = 3, .denominator = 20 }, /* 20/3 V/V gain */
 };
 
 struct ad4030_chip_info {
@@ -467,8 +467,7 @@ static void ad4030_fill_scale_avail(struct ad4030_state *st)
 	mag_bits = st->chip->precision_bits - 1;
 
 	for (unsigned int i = 0; i < ARRAY_SIZE(adaq4216_hw_gains_frac); i++) {
-		range = mult_frac(st->vref_uv, adaq4216_hw_gains_frac[i][1],
-				  adaq4216_hw_gains_frac[i][0]);
+		range = mult_fract(st->vref_uv, &adaq4216_hw_gains_frac[i]);
 		/*
 		 * If range were in mV, we would multiply it by NANO below.
 		 * Though, range is in µV so multiply it by MICRO only so the
-- 
2.50.1


  parent reply	other threads:[~2026-11-17  9:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-17  9:14 [PATCH v1 0/3] iio: adc: Provide mult_fract() and make use of it Andy Shevchenko
2026-11-17  9:14 ` [PATCH v1 1/3] math.h: Add mult_fract() that takes struct __Txx_fract as argument Andy Shevchenko
2026-11-17  9:14 ` Andy Shevchenko [this message]
2026-11-17  9:14 ` [PATCH v1 3/3] iio: adc: ltc2378: Switch to use mult_fract() helper 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=20261117091638.1463621-3-andriy.shevchenko@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=andy@kernel.org \
    --cc=cristian.ciocaltea@collabora.com \
    --cc=dlechner@baylibre.com \
    --cc=eblanc@baylibre.com \
    --cc=jic23@kernel.org \
    --cc=jonathan.cameron@oss.qualcomm.com \
    --cc=linux-iio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@analog.com \
    --cc=marcelo.schmitt@analog.com \
    --cc=michael.hennerich@analog.com \
    --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®