[PATCH v5 09/16] iio: adc: xilinx-xadc: Add unit suffixes to macro names

Andy Shevchenko andriy.shevchenko at intel.com
Tue Nov 10 08:18:51 PST 2026


On Tue, Nov 10, 2026 at 10:31:54AM +0530, Dileep Kumar Nagavarapu wrote:
> Append the unit to the relevant macro names (_HZ, _MS, _CYCLES, _SPS)
> so that the expected unit of each value is clear at the point of use
> and to avoid ambiguity.
> 
> No functional change intended

...

> -#define XADC_MAX_SAMPLERATE 150000
> +#define XADC_MAX_SAMPLERATE_SPS 150000

Not sure if _SPS makes it anyhow better, but you may use (150 * KILO)

...

> -#define XADC_ZYNQ_TCK_RATE_MAX 50000000
> -#define XADC_ZYNQ_IGAP_DEFAULT 20
> -#define XADC_ZYNQ_PCAP_RATE_MAX 200000000
> +#define XADC_ZYNQ_TCK_RATE_MAX_HZ	50000000
> +#define XADC_ZYNQ_IGAP_DEFAULT_CYCLES	20
> +#define XADC_ZYNQ_PCAP_RATE_MAX_HZ	200000000

We have units.h full of useful multipliers, use them.

_HZ --> _Hz

...

>  	div = clk_rate / val;
> -	if (clk_rate / div / 26 > XADC_MAX_SAMPLERATE)
> +	if (clk_rate / div / 26 > XADC_MAX_SAMPLERATE_SPS)
>  		div++;

Side note, you can get rid of one division.

	if (clk_rate / div > 26 * XADC_MAX_SAMPLERATE_SPS)

>  	if (div < 2)
>  		div = 2;

-- 
With Best Regards,
Andy Shevchenko





More information about the linux-arm-kernel mailing list