Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

spi: pxa2xx: use min() instead of min_t()

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().

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: David Laight <david.laight.linux@gmail.com>
Link: https://patch.msgid.link/20260223153117.2838840-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Andy Shevchenko and committed by
Mark Brown
507a071d fed6e508

+5 -6
+5 -6
drivers/spi/spi-pxa2xx.c
··· 796 796 * The function calculates parameters for all cases and chooses the one closest 797 797 * to the asked baud rate. 798 798 */ 799 - static unsigned int quark_x1000_get_clk_div(int rate, u32 *dds) 799 + static unsigned int quark_x1000_get_clk_div(u32 rate, u32 *dds) 800 800 { 801 801 unsigned long xtal = 200000000; 802 802 unsigned long fref = xtal / 2; /* mandatory division by 2, ··· 885 885 return q - 1; 886 886 } 887 887 888 - static unsigned int ssp_get_clk_div(struct driver_data *drv_data, int rate) 888 + static unsigned int ssp_get_clk_div(struct driver_data *drv_data, u32 rate) 889 889 { 890 - unsigned long ssp_clk = drv_data->controller->max_speed_hz; 890 + u32 ssp_clk = drv_data->controller->max_speed_hz; 891 891 const struct ssp_device *ssp = drv_data->ssp; 892 892 893 - rate = min_t(int, ssp_clk, rate); 893 + rate = min(ssp_clk, rate); 894 894 895 895 /* 896 896 * Calculate the divisor for the SCR (Serial Clock Rate), avoiding ··· 902 902 return (DIV_ROUND_UP(ssp_clk, rate) - 1) & 0xfff; 903 903 } 904 904 905 - static unsigned int pxa2xx_ssp_get_clk_div(struct driver_data *drv_data, 906 - int rate) 905 + static unsigned int pxa2xx_ssp_get_clk_div(struct driver_data *drv_data, u32 rate) 907 906 { 908 907 struct chip_data *chip = 909 908 spi_get_ctldata(drv_data->controller->cur_msg->spi);