Re: [PATCH 2/5] iio: proximity: hx9023s: Protect against division by zero in set_samp_freq
From: Andy Shevchenko
Date: Mon Feb 09 2026 - 03:46:43 EST
On Mon, Feb 09, 2026 at 11:37:03AM +0800, Yasin Lee wrote:
> Avoid division by zero when sampling frequency is unspecified by
> falling back to a default 100ms sampling period.
Fixes tag?
...
> + if (!val && !val2)
What's wrong with the positive conditional?
if (val || val2)
...
else
...
> + /* Fallback to a safe default sampling period */
> + period_ms = 100;
> + else
> + period_ms = div_u64(NANO, (val * MEGA + val2));
--
With Best Regards,
Andy Shevchenko