From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Jonathan Cameron <jonathan.cameron@oss.qualcomm.com>,
Nikhil Gautam <nikhilgtr@gmail.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: "Jonathan Cameron" <jic23@kernel.org>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Jesper X Nilsson" <jesper.x.nilsson@axis.com>
Subject: [PATCH v1 1/1] iio: light: opt4001: Re-use generic struct s32_fract
Date: Fri, 23 Oct 2026 11:08:02 +0200 [thread overview]
Message-ID: <20261023090802.1957593-1-andriy.shevchenko@linux.intel.com> (raw)
Instead of custom data type re-use generic struct s32_fract.
No functional changes intended.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
drivers/iio/light/opt4001.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)
diff --git a/drivers/iio/light/opt4001.c b/drivers/iio/light/opt4001.c
index aa3d87995b7c..b2e7abc22434 100644
--- a/drivers/iio/light/opt4001.c
+++ b/drivers/iio/light/opt4001.c
@@ -75,8 +75,7 @@
* lux values.
*/
struct opt4001_chip_info {
- int mul;
- int div;
+ struct s32_fract ratio;
const char *name;
};
@@ -88,14 +87,12 @@ struct opt4001_chip {
};
static const struct opt4001_chip_info opt4001_sot_5x3_info = {
- .mul = 4375,
- .div = 10000000,
+ ,ratio = { .numerator = 4375, .denominator = 10000000 },
.name = "opt4001-sot-5x3"
};
static const struct opt4001_chip_info opt4001_picostar_info = {
- .mul = 3125,
- .div = 10000000,
+ ,ratio = { .numerator = 3125, .denominator = 10000000 },
.name = "opt4001-picostar"
};
@@ -199,8 +196,8 @@ static int opt4001_read_lux_value(struct iio_dev *indio_dev,
return -EIO;
lux_raw = lux_raw << exp;
- lux_raw = lux_raw * chip->chip_info->mul;
- *val = div_u64_rem(lux_raw, chip->chip_info->div, &rem);
+ lux_raw = lux_raw * chip->chip_info->ratio.numerator;
+ *val = div_u64_rem(lux_raw, chip->chip_info->ratio.denominator, &rem);
*val2 = rem * 100;
return IIO_VAL_INT_PLUS_NANO;
--
2.50.1
next reply other threads:[~2026-10-23 9:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 9:08 Andy Shevchenko [this message]
2026-10-23 9:21 ` [PATCH v1 1/1] iio: light: opt4001: Re-use generic struct s32_fract Andy Shevchenko
2026-10-23 10:02 ` Jesper X Nilsson
2026-10-25 20:41 ` kernel test robot
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=20261023090802.1957593-1-andriy.shevchenko@linux.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=andy@kernel.org \
--cc=dlechner@baylibre.com \
--cc=jesper.x.nilsson@axis.com \
--cc=jic23@kernel.org \
--cc=jonathan.cameron@oss.qualcomm.com \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nikhilgtr@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.