linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] SPI: Fix distinct pointer types warning for ARCH=MIPS
@ 2021-01-07 11:57 Yanteng Si
  2021-01-07 13:53 ` Mark Brown
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Yanteng Si @ 2021-01-07 11:57 UTC (permalink / raw)
  To: Mark Brown
  Cc: Philipp Zabel, linux-spi, Huacai Chen, Jiaxun Yang, Yanteng Si,
	Yanteng Si

Fix a new warning report by build for make ARCH=MIPS allmodconfig:

drivers/spi/spi-cadence-quadspi.c: In function 'cqspi_direct_read_execute':
 ./include/linux/minmax.h:18:28: warning: comparison of distinct pointer types lacks a cast
    18 |  (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
       |                            ^~
 ./include/linux/minmax.h:32:4: note: in expansion of macro '__typecheck'
    32 |   (__typecheck(x, y) && __no_side_effects(x, y))
       |    ^~~~~~~~~~~
 ./include/linux/minmax.h:42:24: note: in expansion of macro '__safe_cmp'
    42 |  __builtin_choose_expr(__safe_cmp(x, y), \
       |                        ^~~~~~~~~~
 ./include/linux/minmax.h:58:19: note: in expansion of macro '__careful_cmp'
    58 | #define max(x, y) __careful_cmp(x, y, >)
       |                   ^~~~~~~~~~~~~
 drivers/spi/spi-cadence-quadspi.c:1153:24: note: in expansion of macro 'max'
  1153 |       msecs_to_jiffies(max(len, 500UL)))) {
       |                        ^~~

"len" is unsigned,however,"500" is unsigned long.

Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
---
 drivers/spi/spi-cadence-quadspi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index 06a65e9a8a60..576610ba1118 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -1150,7 +1150,7 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,
 
 	dma_async_issue_pending(cqspi->rx_chan);
 	if (!wait_for_completion_timeout(&cqspi->rx_dma_complete,
-					 msecs_to_jiffies(max(len, 500UL)))) {
+					 msecs_to_jiffies(max(len, 500U)))) {
 		dmaengine_terminate_sync(cqspi->rx_chan);
 		dev_err(dev, "DMA wait_for_completion_timeout\n");
 		ret = -ETIMEDOUT;
-- 
2.27.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] SPI: Fix distinct pointer types warning for ARCH=MIPS
  2021-01-07 11:57 [PATCH] SPI: Fix distinct pointer types warning for ARCH=MIPS Yanteng Si
@ 2021-01-07 13:53 ` Mark Brown
  2021-01-07 17:30 ` Nathan Chancellor
  2021-01-08 16:30 ` Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2021-01-07 13:53 UTC (permalink / raw)
  To: Yanteng Si; +Cc: Philipp Zabel, linux-spi, Huacai Chen, Jiaxun Yang, Yanteng Si

[-- Attachment #1: Type: text/plain, Size: 461 bytes --]

On Thu, Jan 07, 2021 at 07:57:04PM +0800, Yanteng Si wrote:

> Fix a new warning report by build for make ARCH=MIPS allmodconfig:

Please submit patches using subject lines reflecting the style for the
subsystem, this makes it easier for people to identify relevant patches.
Look at what existing commits in the area you're changing are doing and
make sure your subject lines visually resemble what they're doing.
There's no need to resubmit to fix this alone.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] SPI: Fix distinct pointer types warning for ARCH=MIPS
  2021-01-07 11:57 [PATCH] SPI: Fix distinct pointer types warning for ARCH=MIPS Yanteng Si
  2021-01-07 13:53 ` Mark Brown
@ 2021-01-07 17:30 ` Nathan Chancellor
  2021-01-11  8:14   ` Geert Uytterhoeven
  2021-01-08 16:30 ` Mark Brown
  2 siblings, 1 reply; 5+ messages in thread
From: Nathan Chancellor @ 2021-01-07 17:30 UTC (permalink / raw)
  To: Yanteng Si
  Cc: Mark Brown, Philipp Zabel, linux-spi, Huacai Chen, Jiaxun Yang,
	Yanteng Si

On Thu, Jan 07, 2021 at 07:57:04PM +0800, Yanteng Si wrote:
> Fix a new warning report by build for make ARCH=MIPS allmodconfig:
> 
> drivers/spi/spi-cadence-quadspi.c: In function 'cqspi_direct_read_execute':
>  ./include/linux/minmax.h:18:28: warning: comparison of distinct pointer types lacks a cast
>     18 |  (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
>        |                            ^~
>  ./include/linux/minmax.h:32:4: note: in expansion of macro '__typecheck'
>     32 |   (__typecheck(x, y) && __no_side_effects(x, y))
>        |    ^~~~~~~~~~~
>  ./include/linux/minmax.h:42:24: note: in expansion of macro '__safe_cmp'
>     42 |  __builtin_choose_expr(__safe_cmp(x, y), \
>        |                        ^~~~~~~~~~
>  ./include/linux/minmax.h:58:19: note: in expansion of macro '__careful_cmp'
>     58 | #define max(x, y) __careful_cmp(x, y, >)
>        |                   ^~~~~~~~~~~~~
>  drivers/spi/spi-cadence-quadspi.c:1153:24: note: in expansion of macro 'max'
>   1153 |       msecs_to_jiffies(max(len, 500UL)))) {
>        |                        ^~~
> 
> "len" is unsigned,however,"500" is unsigned long.
> 
> Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
> ---
>  drivers/spi/spi-cadence-quadspi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
> index 06a65e9a8a60..576610ba1118 100644
> --- a/drivers/spi/spi-cadence-quadspi.c
> +++ b/drivers/spi/spi-cadence-quadspi.c
> @@ -1150,7 +1150,7 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,
>  
>  	dma_async_issue_pending(cqspi->rx_chan);
>  	if (!wait_for_completion_timeout(&cqspi->rx_dma_complete,
> -					 msecs_to_jiffies(max(len, 500UL)))) {
> +					 msecs_to_jiffies(max(len, 500U)))) {
>  		dmaengine_terminate_sync(cqspi->rx_chan);
>  		dev_err(dev, "DMA wait_for_completion_timeout\n");
>  		ret = -ETIMEDOUT;
> -- 
> 2.27.0
> 

Isn't this just going to cause warnings on 64-bit platforms now because
size_t is defined as unsigned long and it will now be compared against
unsigned int? This fix should work for everyone, not sure how pretty it
is though.

Cheers,
Nathan

diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
index 06a65e9a8a60..af13c0025bf5 100644
--- a/drivers/spi/spi-cadence-quadspi.c
+++ b/drivers/spi/spi-cadence-quadspi.c
@@ -1150,7 +1150,7 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,
 
 	dma_async_issue_pending(cqspi->rx_chan);
 	if (!wait_for_completion_timeout(&cqspi->rx_dma_complete,
-					 msecs_to_jiffies(max(len, 500UL)))) {
+					 msecs_to_jiffies(max_t(size_t, len, 500)))) {
 		dmaengine_terminate_sync(cqspi->rx_chan);
 		dev_err(dev, "DMA wait_for_completion_timeout\n");
 		ret = -ETIMEDOUT;

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] SPI: Fix distinct pointer types warning for ARCH=MIPS
  2021-01-07 11:57 [PATCH] SPI: Fix distinct pointer types warning for ARCH=MIPS Yanteng Si
  2021-01-07 13:53 ` Mark Brown
  2021-01-07 17:30 ` Nathan Chancellor
@ 2021-01-08 16:30 ` Mark Brown
  2 siblings, 0 replies; 5+ messages in thread
From: Mark Brown @ 2021-01-08 16:30 UTC (permalink / raw)
  To: Yanteng Si; +Cc: linux-spi, Jiaxun Yang, Philipp Zabel, Yanteng Si, Huacai Chen

On Thu, 7 Jan 2021 19:57:04 +0800, Yanteng Si wrote:
> Fix a new warning report by build for make ARCH=MIPS allmodconfig:
> 
> drivers/spi/spi-cadence-quadspi.c: In function 'cqspi_direct_read_execute':
>  ./include/linux/minmax.h:18:28: warning: comparison of distinct pointer types lacks a cast
>     18 |  (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
>        |                            ^~
>  ./include/linux/minmax.h:32:4: note: in expansion of macro '__typecheck'
>     32 |   (__typecheck(x, y) && __no_side_effects(x, y))
>        |    ^~~~~~~~~~~
>  ./include/linux/minmax.h:42:24: note: in expansion of macro '__safe_cmp'
>     42 |  __builtin_choose_expr(__safe_cmp(x, y), \
>        |                        ^~~~~~~~~~
>  ./include/linux/minmax.h:58:19: note: in expansion of macro '__careful_cmp'
>     58 | #define max(x, y) __careful_cmp(x, y, >)
>        |                   ^~~~~~~~~~~~~
>  drivers/spi/spi-cadence-quadspi.c:1153:24: note: in expansion of macro 'max'
>   1153 |       msecs_to_jiffies(max(len, 500UL)))) {
>        |                        ^~~
> 
> [...]

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/spi.git for-next

Thanks!

[1/1] SPI: Fix distinct pointer types warning for ARCH=MIPS
      commit: 8728a81b8f1007426d8f341c5d2400da60f4cea2

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] 5+ messages in thread

* Re: [PATCH] SPI: Fix distinct pointer types warning for ARCH=MIPS
  2021-01-07 17:30 ` Nathan Chancellor
@ 2021-01-11  8:14   ` Geert Uytterhoeven
  0 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2021-01-11  8:14 UTC (permalink / raw)
  To: Nathan Chancellor
  Cc: Yanteng Si, Mark Brown, Philipp Zabel, linux-spi, Huacai Chen,
	Jiaxun Yang, Yanteng Si

Hi Nathan,

On Thu, Jan 7, 2021 at 6:31 PM Nathan Chancellor
<natechancellor@gmail.com> wrote:
> On Thu, Jan 07, 2021 at 07:57:04PM +0800, Yanteng Si wrote:
> > Fix a new warning report by build for make ARCH=MIPS allmodconfig:
> >
> > drivers/spi/spi-cadence-quadspi.c: In function 'cqspi_direct_read_execute':
> >  ./include/linux/minmax.h:18:28: warning: comparison of distinct pointer types lacks a cast
> >     18 |  (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
> >        |                            ^~
> >  ./include/linux/minmax.h:32:4: note: in expansion of macro '__typecheck'
> >     32 |   (__typecheck(x, y) && __no_side_effects(x, y))
> >        |    ^~~~~~~~~~~
> >  ./include/linux/minmax.h:42:24: note: in expansion of macro '__safe_cmp'
> >     42 |  __builtin_choose_expr(__safe_cmp(x, y), \
> >        |                        ^~~~~~~~~~
> >  ./include/linux/minmax.h:58:19: note: in expansion of macro '__careful_cmp'
> >     58 | #define max(x, y) __careful_cmp(x, y, >)
> >        |                   ^~~~~~~~~~~~~
> >  drivers/spi/spi-cadence-quadspi.c:1153:24: note: in expansion of macro 'max'
> >   1153 |       msecs_to_jiffies(max(len, 500UL)))) {
> >        |                        ^~~
> >
> > "len" is unsigned,however,"500" is unsigned long.

len is size_t, which us either unsigned int or unsigned long.

> > Signed-off-by: Yanteng Si <siyanteng@loongson.cn>
> > ---
> >  drivers/spi/spi-cadence-quadspi.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/spi/spi-cadence-quadspi.c b/drivers/spi/spi-cadence-quadspi.c
> > index 06a65e9a8a60..576610ba1118 100644
> > --- a/drivers/spi/spi-cadence-quadspi.c
> > +++ b/drivers/spi/spi-cadence-quadspi.c
> > @@ -1150,7 +1150,7 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,
> >
> >       dma_async_issue_pending(cqspi->rx_chan);
> >       if (!wait_for_completion_timeout(&cqspi->rx_dma_complete,
> > -                                      msecs_to_jiffies(max(len, 500UL)))) {
> > +                                      msecs_to_jiffies(max(len, 500U)))) {
> >               dmaengine_terminate_sync(cqspi->rx_chan);
> >               dev_err(dev, "DMA wait_for_completion_timeout\n");
> >               ret = -ETIMEDOUT;
> > --
> > 2.27.0
> >
>
> Isn't this just going to cause warnings on 64-bit platforms now because
> size_t is defined as unsigned long and it will now be compared against
> unsigned int? This fix should work for everyone, not sure how pretty it

Yes it is!

> is though.

> --- a/drivers/spi/spi-cadence-quadspi.c
> +++ b/drivers/spi/spi-cadence-quadspi.c
> @@ -1150,7 +1150,7 @@ static int cqspi_direct_read_execute(struct cqspi_flash_pdata *f_pdata,
>
>         dma_async_issue_pending(cqspi->rx_chan);
>         if (!wait_for_completion_timeout(&cqspi->rx_dma_complete,
> -                                        msecs_to_jiffies(max(len, 500UL)))) {
> +                                        msecs_to_jiffies(max_t(size_t, len, 500)))) {
>                 dmaengine_terminate_sync(cqspi->rx_chan);
>                 dev_err(dev, "DMA wait_for_completion_timeout\n");
>                 ret = -ETIMEDOUT;

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-01-11  8:15 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-01-07 11:57 [PATCH] SPI: Fix distinct pointer types warning for ARCH=MIPS Yanteng Si
2021-01-07 13:53 ` Mark Brown
2021-01-07 17:30 ` Nathan Chancellor
2021-01-11  8:14   ` Geert Uytterhoeven
2021-01-08 16:30 ` Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).