* [PATCH v2] spi: nxp-fspi: Use max macro
@ 2024-08-27 13:12 Yan Zhen
2024-08-29 17:38 ` Mark Brown
2024-08-31 12:27 ` David Laight
0 siblings, 2 replies; 3+ messages in thread
From: Yan Zhen @ 2024-08-27 13:12 UTC (permalink / raw)
To: han.xu, haibo.chen, broonie
Cc: yogeshgaur.83, linux-spi, linux-kernel, opensource.kernel, Yan Zhen
When the original file is guaranteed to contain the minmax.h header file
and compile correctly, using the real macro is usually
more intuitive and readable.
Signed-off-by: Yan Zhen <yanzhen@vivo.com>
---
Changes in v2:
- Rewrite the subject.
- Using max_t() instead of max().
drivers/spi/spi-nxp-fspi.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
index 88397f712a3b..fda902aa5815 100644
--- a/drivers/spi/spi-nxp-fspi.c
+++ b/drivers/spi/spi-nxp-fspi.c
@@ -756,8 +756,7 @@ static int nxp_fspi_read_ahb(struct nxp_fspi *f, const struct spi_mem_op *op)
iounmap(f->ahb_addr);
f->memmap_start = start;
- f->memmap_len = len > NXP_FSPI_MIN_IOMAP ?
- len : NXP_FSPI_MIN_IOMAP;
+ f->memmap_len = max_t(u32, len, NXP_FSPI_MIN_IOMAP);
f->ahb_addr = ioremap(f->memmap_phy + f->memmap_start,
f->memmap_len);
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v2] spi: nxp-fspi: Use max macro
2024-08-27 13:12 [PATCH v2] spi: nxp-fspi: Use max macro Yan Zhen
@ 2024-08-29 17:38 ` Mark Brown
2024-08-31 12:27 ` David Laight
1 sibling, 0 replies; 3+ messages in thread
From: Mark Brown @ 2024-08-29 17:38 UTC (permalink / raw)
To: han.xu, haibo.chen, Yan Zhen
Cc: yogeshgaur.83, linux-spi, linux-kernel, opensource.kernel
On Tue, 27 Aug 2024 21:12:03 +0800, Yan Zhen wrote:
> When the original file is guaranteed to contain the minmax.h header file
> and compile correctly, using the real macro is usually
> more intuitive and readable.
>
>
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next
Thanks!
[1/1] spi: nxp-fspi: Use max macro
commit: 3959d1f0f8d6682aa896a8f78a9f5ebfd2b6f6c8
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] 3+ messages in thread
* RE: [PATCH v2] spi: nxp-fspi: Use max macro
2024-08-27 13:12 [PATCH v2] spi: nxp-fspi: Use max macro Yan Zhen
2024-08-29 17:38 ` Mark Brown
@ 2024-08-31 12:27 ` David Laight
1 sibling, 0 replies; 3+ messages in thread
From: David Laight @ 2024-08-31 12:27 UTC (permalink / raw)
To: 'Yan Zhen', han.xu, haibo.chen, broonie
Cc: yogeshgaur.83, linux-spi, linux-kernel, opensource.kernel
From: Yan Zhen
> Sent: 27 August 2024 14:12
>
> When the original file is guaranteed to contain the minmax.h header file
> and compile correctly, using the real macro is usually
> more intuitive and readable.
>
> Signed-off-by: Yan Zhen <yanzhen@vivo.com>
> ---
>
> Changes in v2:
> - Rewrite the subject.
> - Using max_t() instead of max().
>
> drivers/spi/spi-nxp-fspi.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/drivers/spi/spi-nxp-fspi.c b/drivers/spi/spi-nxp-fspi.c
> index 88397f712a3b..fda902aa5815 100644
> --- a/drivers/spi/spi-nxp-fspi.c
> +++ b/drivers/spi/spi-nxp-fspi.c
> @@ -756,8 +756,7 @@ static int nxp_fspi_read_ahb(struct nxp_fspi *f, const struct spi_mem_op *op)
> iounmap(f->ahb_addr);
>
> f->memmap_start = start;
> - f->memmap_len = len > NXP_FSPI_MIN_IOMAP ?
> - len : NXP_FSPI_MIN_IOMAP;
> + f->memmap_len = max_t(u32, len, NXP_FSPI_MIN_IOMAP);
>
This shouldn't be max_t().
That is equivalent to:
(u32)len > (u32)NXP_FSPI_MIN_IOMAP ? (u32)len) : (u32)NXP_FSPI_MIN_IOMAP;
Which you'd never write and has the obvious fubar that is 'len' is 64bit
and greater that 2^32 the wrong thing happens.
David
> f->ahb_addr = ioremap(f->memmap_phy + f->memmap_start,
> f->memmap_len);
> --
> 2.34.1
>
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-31 12:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-27 13:12 [PATCH v2] spi: nxp-fspi: Use max macro Yan Zhen
2024-08-29 17:38 ` Mark Brown
2024-08-31 12:27 ` David Laight
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®