From: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
To: sre@kernel.org
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
"Jiri Slaby (SUSE)" <jirislaby@kernel.org>,
Linus Walleij <linus.walleij@linaro.org>,
Hans de Goede <hansg@kernel.org>,
Sebastian Reichel <sebastian.reichel@collabora.com>
Subject: [PATCH] power: supply: intel_dc_ti_battery: fix 64bit divisions
Date: Thu, 16 Oct 2025 08:23:57 +0200 [thread overview]
Message-ID: <20251016062401.409809-1-jirislaby@kernel.org> (raw)
On 32bit builds, I get:
ERROR: modpost: "__udivdi3" [drivers/power/supply/intel_dc_ti_battery.ko] undefined!
This is due to 64bit ktime divisions. Fix both by using div_u64().
Fixes: 8c5795fe5527 ("power: supply: Add new Intel Dollar Cove TI battery driver")
---
Cc: Linus Walleij <linus.walleij@linaro.org>
Cc: Hans de Goede <hansg@kernel.org>
Cc: Sebastian Reichel <sebastian.reichel@collabora.com>
---
drivers/power/supply/intel_dc_ti_battery.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/power/supply/intel_dc_ti_battery.c b/drivers/power/supply/intel_dc_ti_battery.c
index 56b0c92e9d28..3d38106b638b 100644
--- a/drivers/power/supply/intel_dc_ti_battery.c
+++ b/drivers/power/supply/intel_dc_ti_battery.c
@@ -141,7 +141,7 @@ static int dc_ti_battery_get_voltage_and_current_now(struct power_supply *psy, i
if (ret)
goto out_err;
- cnt_start_usec = ktime_get_ns() / NSEC_PER_USEC;
+ cnt_start_usec = div_u64(ktime_get_ns(), NSEC_PER_USEC);
/* Read Vbat, convert IIO mV to power-supply ųV */
ret = iio_read_channel_processed_scale(chip->vbat_channel, volt, 1000);
@@ -149,7 +149,7 @@ static int dc_ti_battery_get_voltage_and_current_now(struct power_supply *psy, i
goto out_err;
/* Sleep at least 3 sample-times + slack to get 3+ CC samples */
- now_usec = ktime_get_ns() / NSEC_PER_USEC;
+ now_usec = div_u64(ktime_get_ns(), NSEC_PER_USEC);
sleep_usec = 3 * SMPL_INTVL_US + SLEEP_SLACK_US - (now_usec - cnt_start_usec);
if (sleep_usec > 0 && sleep_usec < 1000000)
usleep_range(sleep_usec, sleep_usec + SLEEP_SLACK_US);
--
2.51.0
next reply other threads:[~2025-10-16 6:24 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-16 6:23 Jiri Slaby (SUSE) [this message]
2025-10-16 6:26 ` [PATCH] power: supply: intel_dc_ti_battery: fix 64bit divisions Jiri Slaby
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=20251016062401.409809-1-jirislaby@kernel.org \
--to=jirislaby@kernel.org \
--cc=hansg@kernel.org \
--cc=linus.walleij@linaro.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=sebastian.reichel@collabora.com \
--cc=sre@kernel.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