summaryrefslogtreecommitdiffstats
path: root/drivers/spi
diff options
context:
space:
mode:
authorAndy Shevchenko <andriy.shevchenko@linux.intel.com>2026-02-23 16:30:54 +0100
committerMark Brown <broonie@kernel.org>2026-02-23 19:10:26 +0000
commit507a071d9868cb60e4e76f8a06fc8eb014f59ae4 (patch)
tree1dc23a47d7d9c2c1c06003c97d1136ebf835e03f /drivers/spi
parentfed6e5084894373d76270cad4a32eb6479ad8247 (diff)
downloadlinux-507a071d9868cb60e4e76f8a06fc8eb014f59ae4.tar.gz
linux-507a071d9868cb60e4e76f8a06fc8eb014f59ae4.zip
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>
Diffstat (limited to 'drivers/spi')
-rw-r--r--drivers/spi/spi-pxa2xx.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/drivers/spi/spi-pxa2xx.c b/drivers/spi/spi-pxa2xx.c
index f7881a31e4cc..6291d7c2e06f 100644
--- a/drivers/spi/spi-pxa2xx.c
+++ b/drivers/spi/spi-pxa2xx.c
@@ -796,7 +796,7 @@ static irqreturn_t ssp_int(int irq, void *dev_id)
* The function calculates parameters for all cases and chooses the one closest
* to the asked baud rate.
*/
-static unsigned int quark_x1000_get_clk_div(int rate, u32 *dds)
+static unsigned int quark_x1000_get_clk_div(u32 rate, u32 *dds)
{
unsigned long xtal = 200000000;
unsigned long fref = xtal / 2; /* mandatory division by 2,
@@ -885,12 +885,12 @@ static unsigned int quark_x1000_get_clk_div(int rate, u32 *dds)
return q - 1;
}
-static unsigned int ssp_get_clk_div(struct driver_data *drv_data, int rate)
+static unsigned int ssp_get_clk_div(struct driver_data *drv_data, u32 rate)
{
- unsigned long ssp_clk = drv_data->controller->max_speed_hz;
+ u32 ssp_clk = drv_data->controller->max_speed_hz;
const struct ssp_device *ssp = drv_data->ssp;
- rate = min_t(int, ssp_clk, rate);
+ rate = min(ssp_clk, rate);
/*
* Calculate the divisor for the SCR (Serial Clock Rate), avoiding
@@ -902,8 +902,7 @@ static unsigned int ssp_get_clk_div(struct driver_data *drv_data, int rate)
return (DIV_ROUND_UP(ssp_clk, rate) - 1) & 0xfff;
}
-static unsigned int pxa2xx_ssp_get_clk_div(struct driver_data *drv_data,
- int rate)
+static unsigned int pxa2xx_ssp_get_clk_div(struct driver_data *drv_data, u32 rate)
{
struct chip_data *chip =
spi_get_ctldata(drv_data->controller->cur_msg->spi);