Re: [PATCH v6 7/8] iio: adc: at91_adc: use HZ_PER_KHZ instead of raw 1000
From: David Laight
Date: Fri Dec 04 2026 - 09:33:09 EST
On Thu, 03 Dec 2026 19:30:11 +0200
Abdelnasser Hussein <abdelnasserhussein11@xxxxxxxxx> wrote:
> Convert adc_clk to kHz with HZ_PER_KHZ instead of the open-coded
> divisor in at91_adc_probe().
>
> Reviewed-by: Joshua Crofts <crofts@xxxxxxxxxx>
> Signed-off-by: Abdelnasser Hussein <abdelnasserhussein11@xxxxxxxxx>
> ---
> drivers/iio/adc/at91_adc.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c
> index ca998dc91af4..ed3431b17ad8 100644
> --- a/drivers/iio/adc/at91_adc.c
> +++ b/drivers/iio/adc/at91_adc.c
> @@ -20,6 +20,7 @@
> #include <linux/property.h>
> #include <linux/sched.h>
> #include <linux/slab.h>
> +#include <linux/units.h>
> #include <linux/wait.h>
>
> #include <linux/iio/iio.h>
> @@ -1113,7 +1114,7 @@ static int at91_adc_probe(struct platform_device *pdev)
> */
> mstrclk = clk_get_rate(st->clk);
> adc_clk = clk_get_rate(st->adc_clk);
> - adc_clk_khz = adc_clk / 1000;
> + adc_clk_khz = adc_clk / HZ_PER_KHZ;
That doesn't seem to be the correct name for the division.
HZ_PER_KHZ is (named) for converting between Hz and kHz,
but you are converting between MHz and kHz so it is worse than
the literal 1000.
It is also entirely pointless churn.
David
>
> dev_dbg(dev, "Master clock is set as: %d Hz, adc_clk should set as: %d Hz\n",
> mstrclk, adc_clk);
>