Skip to contentSkip to conversation

iio: common: scmi_sensors: Get rid of const_ilog2()

PATCH Applied Andy Shevchenko 2 participants 2 messages Nov 3, 2025 – Nov 9, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 iio: common: scmi_sensors: Get rid of const_ilog2()

Fisrt of all, const_ilog2() was a workaround of some sparse issue, which was never appeared in the C functions. Second, the calls here are done against constants and work with a bit of luck. Replace this altogether by a pre-calculated simple integer constant. Amend a comment to give a hint where it comes from.

---

v2: Rewrite the patch completely (David)

 drivers/iio/common/scmi_sensors/scmi_iio.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iio/common/scmi_sensors/scmi_iio.c +2 -3
index 39c61c47022a..5136ad9ada04 100644
@@ -66,10 +66,9 @@ static int scmi_iio_sensor_update_cb(struct notifier_block *nb,
 		/*
 		 *  Timestamp returned by SCMI is in seconds and is equal to
 		 *  time * power-of-10 multiplier(tstamp_scale) seconds.
-		 *  Converting the timestamp to nanoseconds below.
+		 *  Converting the timestamp to nanoseconds (10⁹) below.
 		 */
-		tstamp_scale = sensor->sensor_info->tstamp_scale +
-			       const_ilog2(NSEC_PER_SEC) / const_ilog2(10);
+		tstamp_scale = sensor->sensor_info->tstamp_scale + 9;
 		if (tstamp_scale < 0) {
 			do_div(time, int_pow(10, abs(tstamp_scale)));
 			time_ns = time;
Signature · 1 line
2.50.1
maintainer Applied
#1 lore raw
Quoted 7 lines · On Mon, 3 Nov 2025 09:29:11 +0100 Andy Shevchenko…

Fisrt of all, const_ilog2() was a workaround of some sparse issue, which was never appeared in the C functions. Second, the calls here are done against constants and work with a bit of luck. Replace this altogether by a pre-calculated simple integer constant. Amend a comment to give a hint where it comes from.

Applied.

thanks,

J