Re: [PATCH 2/5] iio: proximity: hx9023s: Protect against division by zero in set_samp_freq
From: Yasin Lee
Date: Tue Feb 10 2026 - 11:30:42 EST
On Mon, Feb 9, 2026 at 4:46 PM Andy Shevchenko
<andriy.shevchenko@xxxxxxxxx> wrote:
>
> 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?
>
This is a proactive fix for an original implementation issue I found
as maintainer.
> ...
>
> > + if (!val && !val2)
>
> What's wrong with the positive conditional?
>
Agreed. Positive conditional will be present in v2.
> 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
>
>