linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: Herbert Xu <herbert@gondor.apana.org.au>
Cc: Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Joerg Roedel <joerg.roedel@amd.com>,
	Luc Van Oostenryck <luc.vanoostenryck@gmail.com>,
	Wen He <wen.he_1@nxp.com>, Peng Ma <peng.ma@nxp.com>,
	Vinod Koul <vkoul@kernel.org>
Subject: Re: [PATCH] dmaengine: fsldma: Do not pass pointers to lower_32_bits
Date: Sat, 29 Aug 2020 08:08:02 -0700	[thread overview]
Message-ID: <5614461b-02ae-5cb5-cca8-0525ffaacc13@roeck-us.net> (raw)
In-Reply-To: <20200829124535.GA11751@gondor.apana.org.au>

On 8/29/20 5:45 AM, Herbert Xu wrote:
> On Sat, Aug 29, 2020 at 03:51:16AM -0700, Guenter Roeck wrote:
>>
>> This patch results in the following compile error when compiling 
>> ppc:mpc85xx_defconfig.
>>
>> Error log:
>> In file included from ./include/linux/list.h:9,
>>                  from ./include/linux/module.h:12,
>>                  from drivers/dma/fsldma.c:23:
>> drivers/dma/fsldma.h: In function 'fsl_ioread64':
>> ./include/linux/kernel.h:189:37: error: invalid operands to binary & (have 'const u64 *' {aka 'const long long unsigned int *'} and 'unsigned int')
>>   189 | #define lower_32_bits(n) ((u32)((n) & 0xffffffff))
>>       |                                     ^
>> drivers/dma/fsldma.h:208:17: note: in expansion of macro 'lower_32_bits'
>>   208 |  u32 fsl_addr = lower_32_bits(addr);
>>       |                 ^~~~~~~~~~~~~
>> drivers/dma/fsldma.h: In function 'fsl_ioread64be':
>> ./include/linux/kernel.h:189:37: error: invalid operands to binary & (have 'const u64 *' {aka 'const long long unsigned int *'} and 'unsigned int')
>>   189 | #define lower_32_bits(n) ((u32)((n) & 0xffffffff))
>>       |                                     ^
>> drivers/dma/fsldma.h:222:17: note: in expansion of macro 'lower_32_bits'
>>   222 |  u32 fsl_addr = lower_32_bits(addr);
>>       |                 ^~~~~~~~~~~~~
>> make[2]: *** [drivers/dma/fsldma.o] Error 1
> 
> Thanks for the report.  Passing a pointer to lower_32_bits is just
> bad.
> 
> ---8<---
> The functions fsl_ioread64* were passing a pointer to lower_32_bits
> which just happened to work because it was a macro that simply did
> a cast on the argument.
> 
> However, now that lower_32_bits does a mask on the argument it no
> longer works.  Passing a pointer to lower_32_bits doesn't look
> right anyway.
> 
> This patch adds explicit casts so that an integer is passed along
> as the argument to lower_32_bits.
> 
> Reported-by: Guenter Roeck <linux@roeck-us.net>
> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

Works as well as the other patch.

Tested-by: Guenter Roeck <linux@roeck-us.net>

Guenter

> 
> diff --git a/drivers/dma/fsldma.h b/drivers/dma/fsldma.h
> index 56f18ae99233..da5816b1706e 100644
> --- a/drivers/dma/fsldma.h
> +++ b/drivers/dma/fsldma.h
> @@ -205,7 +205,7 @@ struct fsldma_chan {
>  #else
>  static u64 fsl_ioread64(const u64 __iomem *addr)
>  {
> -	u32 fsl_addr = lower_32_bits(addr);
> +	u32 fsl_addr = lower_32_bits((unsigned long)addr);
>  	u64 fsl_addr_hi = (u64)in_le32((u32 *)(fsl_addr + 1)) << 32;
>  
>  	return fsl_addr_hi | in_le32((u32 *)fsl_addr);
> @@ -219,7 +219,7 @@ static void fsl_iowrite64(u64 val, u64 __iomem *addr)
>  
>  static u64 fsl_ioread64be(const u64 __iomem *addr)
>  {
> -	u32 fsl_addr = lower_32_bits(addr);
> +	u32 fsl_addr = lower_32_bits((unsigned long)addr);
>  	u64 fsl_addr_hi = (u64)in_be32((u32 *)fsl_addr) << 32;
>  
>  	return fsl_addr_hi | in_be32((u32 *)(fsl_addr + 1));
> 


  reply	other threads:[~2020-08-29 15:08 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-28  7:11 [PATCH] kernel.h: Silence sparse warning in lower_32_bits Herbert Xu
2020-08-29 10:51 ` Guenter Roeck
2020-08-29 12:45   ` [PATCH] dmaengine: fsldma: Do not pass pointers to lower_32_bits Herbert Xu
2020-08-29 15:08     ` Guenter Roeck [this message]
2020-08-29 12:45   ` [PATCH] fsldma: fsl_ioread64*() do not need lower_32_bits() Luc Van Oostenryck
2020-08-29 17:29     ` Linus Torvalds
2020-08-29 20:40       ` Guenter Roeck
2020-08-29 21:20         ` Linus Torvalds
2020-08-31  1:54           ` Michael Ellerman
2020-08-31  6:39           ` Vinod Koul
2020-08-31 14:25           ` Leo Li
2020-08-30 12:11       ` Luc Van Oostenryck

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=5614461b-02ae-5cb5-cca8-0525ffaacc13@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=akpm@linux-foundation.org \
    --cc=herbert@gondor.apana.org.au \
    --cc=joerg.roedel@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luc.vanoostenryck@gmail.com \
    --cc=peng.ma@nxp.com \
    --cc=torvalds@linux-foundation.org \
    --cc=vkoul@kernel.org \
    --cc=wen.he_1@nxp.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;
as well as URLs for NNTP newsgroup(s).