From: Arnav Kapoor <kapoorarnav43@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>,
"Andy Shevchenko" <andriy.shevchenko@intel.com>,
"Yasin Lee" <yasin.lee.x@gmail.com>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
"Arnav Kapoor" <kapoorarnav43@gmail.com>
Subject: [PATCH v2 6/6] iio: proximity: hx9023s: use plain division in get_samp_freq
Date: Fri, 27 Nov 2026 03:06:51 +0530 [thread overview]
Message-ID: <20261126213710.1047676-7-kapoorarnav43@gmail.com> (raw)
In-Reply-To: <20261126213710.1047676-1-kapoorarnav43@gmail.com>
hx9023s_get_samp_freq() computes the fractional part of the sampling
frequency with div_u64(), but nothing here needs 64 bits: KILO % odr
is at most 1000, so the dividend is at most 10^9 and fits in an
unsigned long on 32-bit as well. Use a plain division, and drop the
linux/math64.h include, which has no other user left after the
previous patches.
No functional change.
Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Arnav Kapoor <kapoorarnav43@gmail.com>
---
drivers/iio/proximity/hx9023s.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/iio/proximity/hx9023s.c b/drivers/iio/proximity/hx9023s.c
index c2718723db27..98b65a3e69e1 100644
--- a/drivers/iio/proximity/hx9023s.c
+++ b/drivers/iio/proximity/hx9023s.c
@@ -18,7 +18,6 @@
#include <linux/i2c.h>
#include <linux/interrupt.h>
#include <linux/irqreturn.h>
-#include <linux/math64.h>
#include <linux/module.h>
#include <linux/mutex.h>
#include <linux/pm.h>
@@ -702,7 +701,7 @@ static int hx9023s_get_samp_freq(struct hx9023s_data *data, int *val, int *val2)
odr = hx9023s_samp_freq_table[index];
*val = KILO / odr;
- *val2 = div_u64((KILO % odr) * MICRO, odr);
+ *val2 = (KILO % odr) * MICRO / odr;
return IIO_VAL_INT_PLUS_MICRO;
}
--
2.53.0
prev parent reply other threads:[~2026-11-26 21:38 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-26 21:36 [PATCH v2 0/6] iio: proximity: hx9023s: fix sampling frequency, resume and event value handling Arnav Kapoor
2026-11-26 21:36 ` [PATCH v2 1/6] iio: proximity: hx9023s: fix division by zero in set_samp_freq Arnav Kapoor
2026-11-26 21:36 ` [PATCH v2 2/6] iio: proximity: hx9023s: check the sampling frequency index Arnav Kapoor
2026-11-26 21:36 ` [PATCH v2 3/6] iio: proximity: hx9023s: re-enable interrupts on resume for events Arnav Kapoor
2026-11-26 21:36 ` [PATCH v2 4/6] iio: proximity: hx9023s: reject out-of-range threshold values Arnav Kapoor
2026-11-26 21:36 ` [PATCH v2 5/6] iio: proximity: hx9023s: reject out-of-range debounce values Arnav Kapoor
2026-11-26 21:36 ` Arnav Kapoor [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=20261126213710.1047676-7-kapoorarnav43@gmail.com \
--to=kapoorarnav43@gmail.com \
--cc=andriy.shevchenko@intel.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=yasin.lee.x@gmail.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®