Re: [PATCH v3 1/1] clk: divider: Fix divisor masking on 64 bit platforms

From: Andy Shevchenko
Date: Tue Oct 24 2023 - 06:55:57 EST


On Mon, Oct 23, 2023 at 08:34:12PM -0700, Stephen Boyd wrote:
> Quoting Sebastian Reichel (2023-06-30 11:38:35)

> > --- a/include/linux/math.h
> > +++ b/include/linux/math.h
> > @@ -36,6 +36,17 @@
> >
> > #define DIV_ROUND_UP __KERNEL_DIV_ROUND_UP
> >
> > +/**
> > + * DIV_ROUND_UP_NO_OVERFLOW - divide two numbers and always round up
> > + * @n: numerator / dividend
> > + * @d: denominator / divisor
> > + *
> > + * This functions does the same as DIV_ROUND_UP, but internally uses a
> > + * division and a modulo operation instead of math tricks. This way it
> > + * avoids overflowing when handling big numbers.
> > + */
> > +#define DIV_ROUND_UP_NO_OVERFLOW(n, d) (((n) / (d)) + !!((n) % (d)))
>
> Can you get someone to review/ack this macro? Maybe Andy?
>
> > +
> > #define DIV_ROUND_DOWN_ULL(ll, d) \
> > ({ unsigned long long _tmp = (ll); do_div(_tmp, d); _tmp; })

First of all, it should be a separate patch and second, same issue is being
discussed here (as it needs to be fixed in UAPI header directly):

https://lore.kernel.org/all/your-ad-here.call-01697881440-ext-2458@work.hours/

--
With Best Regards,
Andy Shevchenko