* [PATCH] spi: spi-fsl-lpspi: convert min_t() to simple min()
@ 2025-12-09 5:56 Carlos Song
2025-12-09 16:18 ` Frank Li
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Carlos Song @ 2025-12-09 5:56 UTC (permalink / raw)
To: Frank.Li, broonie, daniel.baluta, carlos.song, andriy.shevchenko,
david.laight
Cc: linux-spi, imx, linux-kernel
Convert min_t() to simple min() for better readability.
Fixes: 9f0c21bac5a8 ("spi: spi-fsl-lpspi: fix watermark truncation caused by type cast")
Signed-off-by: Carlos Song <carlos.song@nxp.com>
---
drivers/spi/spi-fsl-lpspi.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
index 065456aba2ae..01c674d466ed 100644
--- a/drivers/spi/spi-fsl-lpspi.c
+++ b/drivers/spi/spi-fsl-lpspi.c
@@ -489,12 +489,9 @@ static int fsl_lpspi_setup_transfer(struct spi_controller *controller,
/*
* t->len is 'unsigned' and txfifosize and watermrk is 'u8', force
* type cast is inevitable. When len > 255, len will be truncated in min_t(),
- * it caused wrong watermark set. 'unsigned int' is as the designated type
- * for min_t() to avoid truncation.
+ * it caused wrong watermark set. Simple min() helps to do type cast.
*/
- fsl_lpspi->watermark = min_t(unsigned int,
- fsl_lpspi->txfifosize,
- t->len);
+ fsl_lpspi->watermark = min(fsl_lpspi->txfifosize, t->len);
if (fsl_lpspi_can_dma(controller, spi, t))
fsl_lpspi->usedma = true;
--
2.34.1
^ permalink raw reply related [flat|nested] 4+ messages in thread* Re: [PATCH] spi: spi-fsl-lpspi: convert min_t() to simple min()
2025-12-09 5:56 [PATCH] spi: spi-fsl-lpspi: convert min_t() to simple min() Carlos Song
@ 2025-12-09 16:18 ` Frank Li
2025-12-09 19:20 ` david laight
2025-12-15 13:59 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Frank Li @ 2025-12-09 16:18 UTC (permalink / raw)
To: Carlos Song
Cc: broonie, daniel.baluta, andriy.shevchenko, david.laight,
linux-spi, imx, linux-kernel
On Tue, Dec 09, 2025 at 01:56:34PM +0800, Carlos Song wrote:
> Convert min_t() to simple min() for better readability.
>
Ref below thread.
https://lore.kernel.org/all/20251119224140.8616-1-david.laight.linux@gmail.com/
at least need summary some important information here even it is simple
change.
Frank
> Fixes: 9f0c21bac5a8 ("spi: spi-fsl-lpspi: fix watermark truncation caused by type cast")
> Signed-off-by: Carlos Song <carlos.song@nxp.com>
> ---
> drivers/spi/spi-fsl-lpspi.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
> index 065456aba2ae..01c674d466ed 100644
> --- a/drivers/spi/spi-fsl-lpspi.c
> +++ b/drivers/spi/spi-fsl-lpspi.c
> @@ -489,12 +489,9 @@ static int fsl_lpspi_setup_transfer(struct spi_controller *controller,
> /*
> * t->len is 'unsigned' and txfifosize and watermrk is 'u8', force
> * type cast is inevitable. When len > 255, len will be truncated in min_t(),
> - * it caused wrong watermark set. 'unsigned int' is as the designated type
> - * for min_t() to avoid truncation.
> + * it caused wrong watermark set. Simple min() helps to do type cast.
> */
> - fsl_lpspi->watermark = min_t(unsigned int,
> - fsl_lpspi->txfifosize,
> - t->len);
> + fsl_lpspi->watermark = min(fsl_lpspi->txfifosize, t->len);
>
> if (fsl_lpspi_can_dma(controller, spi, t))
> fsl_lpspi->usedma = true;
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] spi: spi-fsl-lpspi: convert min_t() to simple min()
2025-12-09 5:56 [PATCH] spi: spi-fsl-lpspi: convert min_t() to simple min() Carlos Song
2025-12-09 16:18 ` Frank Li
@ 2025-12-09 19:20 ` david laight
2025-12-15 13:59 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: david laight @ 2025-12-09 19:20 UTC (permalink / raw)
To: Carlos Song
Cc: Frank.Li, broonie, daniel.baluta, andriy.shevchenko, linux-spi,
imx, linux-kernel
On Tue, 9 Dec 2025 13:56:34 +0800
Carlos Song <carlos.song@nxp.com> wrote:
> Convert min_t() to simple min() for better readability.
>
> Fixes: 9f0c21bac5a8 ("spi: spi-fsl-lpspi: fix watermark truncation caused by type cast")
> Signed-off-by: Carlos Song <carlos.song@nxp.com>
> ---
> drivers/spi/spi-fsl-lpspi.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/spi/spi-fsl-lpspi.c b/drivers/spi/spi-fsl-lpspi.c
> index 065456aba2ae..01c674d466ed 100644
> --- a/drivers/spi/spi-fsl-lpspi.c
> +++ b/drivers/spi/spi-fsl-lpspi.c
> @@ -489,12 +489,9 @@ static int fsl_lpspi_setup_transfer(struct spi_controller *controller,
> /*
> * t->len is 'unsigned' and txfifosize and watermrk is 'u8', force
> * type cast is inevitable. When len > 255, len will be truncated in min_t(),
> - * it caused wrong watermark set. 'unsigned int' is as the designated type
> - * for min_t() to avoid truncation.
> + * it caused wrong watermark set. Simple min() helps to do type cast.
> */
That comment doesn't make any sense and can probably be deleted.
I'm not sure its did before either.
Looks like it was added because the code was originally min_t(u8, ...),
even then I looks like text for the commit message not a code comment.
With the current version of min() no casts are required, the comparison
uses the normal integer promotion rules, so u8 => int => unsigned int.
min() allows the comparison because both variables are unsigned.
David
> - fsl_lpspi->watermark = min_t(unsigned int,
> - fsl_lpspi->txfifosize,
> - t->len);
> + fsl_lpspi->watermark = min(fsl_lpspi->txfifosize, t->len);
>
> if (fsl_lpspi_can_dma(controller, spi, t))
> fsl_lpspi->usedma = true;
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: [PATCH] spi: spi-fsl-lpspi: convert min_t() to simple min()
2025-12-09 5:56 [PATCH] spi: spi-fsl-lpspi: convert min_t() to simple min() Carlos Song
2025-12-09 16:18 ` Frank Li
2025-12-09 19:20 ` david laight
@ 2025-12-15 13:59 ` Mark Brown
2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2025-12-15 13:59 UTC (permalink / raw)
To: Frank.Li, daniel.baluta, andriy.shevchenko, david.laight,
Carlos Song
Cc: linux-spi, imx, linux-kernel
On Tue, 09 Dec 2025 13:56:34 +0800, Carlos Song wrote:
> Convert min_t() to simple min() for better readability.
>
>
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: spi-fsl-lpspi: convert min_t() to simple min()
commit: b884e34994ca41f7b7819f3c41b78ff494787b27
All being well this means that it will be integrated into the linux-next
tree (usually sometime in the next 24 hours) and sent to Linus during
the next merge window (or sooner if it is a bug fix), however if
problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing
and review of the tree, please engage with people reporting problems and
send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they
should be sent as incremental updates against current git, existing
patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying
to this mail.
Thanks,
Mark
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-12-15 13:59 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-09 5:56 [PATCH] spi: spi-fsl-lpspi: convert min_t() to simple min() Carlos Song
2025-12-09 16:18 ` Frank Li
2025-12-09 19:20 ` david laight
2025-12-15 13:59 ` Mark Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox