]> git.ipfire.org Git - thirdparty/kernel/linux.git/commit
staging: iio: impedance-analyzer: ad5933: use div64_ul() instead of do_div()
authorArchit Anant <architanant5@gmail.com>
Wed, 18 Feb 2026 12:53:27 +0000 (18:23 +0530)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 23 Feb 2026 20:44:19 +0000 (20:44 +0000)
commit0e2af0fc30eca0ae92abcf1c8fc7be94a8cc95c3
tree66dc09beae631aae1a0c5c72532fdd8e90eda81f
parent08eea726f4a30dc7e3ee4bf76a1497c54948ff51
staging: iio: impedance-analyzer: ad5933: use div64_ul() instead of do_div()

Replace do_div() with div64_ul() since the remainder is not used.
div64_ul() is the preferred API for 64-bit by 32-bit division when
only the quotient is needed.

Also replace explicit casting and shifting with the BIT_ULL(27) macro
for clarity.

Note: A mathematical simplification to `(freq * BIT_ULL(29)) / mclk` was
suggested during review to improve precision. However, as confirmed by
maintainers, the original driver's truncation via `(mclk / 4)` might
be intentional or relied upon by userspace. Since hardware is not
available for verification, this patch preserves the original logic
to avoid regression risk in the absence of testing.

Issue identified by coccicheck using do_div.cocci.

Signed-off-by: Archit Anant <architanant5@gmail.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/staging/iio/impedance-analyzer/ad5933.c