Re: [PATCH v7 2/2] iio: adc: Add ti-ads1018 driver
From: Kurt Borja
Date: Tue Dec 09 2025 - 23:07:59 EST
On Mon Dec 8, 2025 at 3:19 PM -05, Andy Shevchenko wrote:
...
>> +/**
>> + * ads1018_calc_delay - Calculates a suitable delay for a single-shot reading
>> + * @hz: Sampling frequency
>> + *
>> + * Calculates an appropriate delay for a single shot reading given a sampling
>> + * frequency.
>> + *
>> + * Return: Delay in microseconds (Always greater than 0).
>> + */
>> +static u32 ads1018_calc_delay(unsigned int hz)
>> +{
>> + /*
>> + * Calculate the worst-case sampling rate by subtracting 10% error
>> + * specified in the datasheet...
>> + */
>> + hz -= DIV_ROUND_UP(hz, 10);
>> +
>> + /* ...Then calculate time per sample in microseconds. */
>> + return DIV_ROUND_UP(MICROHZ_PER_HZ, hz);
>
> If time per sample is in µs, the associated frequency is in MHz, so
> the correct constant is HZ_PER_MHZ. What did I miss here?
I was very confused about this, but the dimensional analysis works with
HZ_PER_MHZ so it should be the right constant. Thanks!
...
> Other than above, LGTM!
> Reviewed-by: Andy Shevchenko <andy@xxxxxxxxxx>
Thanks a lot for all your feedback!
I also found that the sysfs ABI specifies millivolt for voltage final
calculation and millidegree for temps. I will adjust scales to comply
with this in the next version.
Do you have a suggestion for this? I can keep the ADS1018_FSR_TO_SCALE()
macro but it will get a bit more complex or I can just hard code the
scales and document the calculation. I'm inclined to do the latter.
--
~ Kurt