From: David Laight <David.Laight@ACULAB.COM>
To: 'Yan Zhen' <yanzhen@vivo.com>, "han.xu@nxp.com" <han.xu@nxp.com>,
"haibo.chen@nxp.com" <haibo.chen@nxp.com>,
"broonie@kernel.org" <broonie@kernel.org>
Cc: "yogeshgaur.83@gmail.com" <yogeshgaur.83@gmail.com>,
"linux-spi@vger.kernel.org" <linux-spi@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"opensource.kernel@vivo.com" <opensource.kernel@vivo.com>
Subject: RE: [PATCH v2] spi: nxp-fspi: Use max macro
Date: Sat, 31 Aug 2024 12:27:19 +0000 [thread overview]
Message-ID: <1ac834f698524ef8bce28a4a1024a3a7@AcuMS.aculab.com> (raw)
In-Reply-To: <20240827131203.3918516-1-yanzhen@vivo.com>
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)
prev parent reply other threads:[~2024-08-31 12:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-27 13:12 Yan Zhen
2024-08-29 17:38 ` Mark Brown
2024-08-31 12:27 ` David Laight [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1ac834f698524ef8bce28a4a1024a3a7@AcuMS.aculab.com \
--to=david.laight@aculab.com \
--cc=broonie@kernel.org \
--cc=haibo.chen@nxp.com \
--cc=han.xu@nxp.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=opensource.kernel@vivo.com \
--cc=yanzhen@vivo.com \
--cc=yogeshgaur.83@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®