Re: [PATCH v2 1/1] spi: pxa2xx: use min() instead of min_t()

From: Andy Shevchenko

Date: Mon Feb 23 2026 - 12:39:17 EST


On Mon, Feb 23, 2026 at 05:09:03PM +0000, David Laight wrote:
> On Mon, 23 Feb 2026 16:30:54 +0100
> Andy Shevchenko <andriy.shevchenko@xxxxxxxxxxxxxxx> wrote:
>
> > min_t(int, a, b) casts an 'u32' to 'int'. This might lead to
> > the cases when big number is wrongly chosen. On the other hand,
> > the SPI transfer speed rate is unsigned and driver uses signed type
> > for an unknown reason. Change the type of the SPI transfer speed
> > to be unsigned and convert to use min() instead of min_t().
>
> Reviewed-by: David Laight <david.laight.linux@xxxxxxxxx>

Thanks!

...

> > -static unsigned int quark_x1000_get_clk_div(int rate, u32 *dds)
> > +static unsigned int quark_x1000_get_clk_div(u32 rate, u32 *dds)

> I've looked at the file...
> I think all the 'long' in that function can be 32bit.
> Especially if the code actually works on 32bit.
> There is also the stunning:
> do_div(fssp, 1 << 24);
> in the only bit that that does need u64.

I know, but it's unrelated to this patch aim.

--
With Best Regards,
Andy Shevchenko