All of lore.kernel.org
 help / color / mirror / Atom feed
From: Moritz Fischer <mdf@kernel.org>
To: Arnd Bergmann <arnd@arndb.de>
Cc: "David S. Miller" <davem@davemloft.net>,
	Moritz Fischer <mdf@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] net: nixge: fix warnings on 32-bit platforms
Date: Wed, 26 Sep 2018 09:03:29 -0700	[thread overview]
Message-ID: <20180926160328.GA1927@archbook> (raw)
In-Reply-To: <20180926124808.1867468-1-arnd@arndb.de>

Hi Arnd,

On Wed, Sep 26, 2018 at 02:47:24PM +0200, Arnd Bergmann wrote:
> Making it work on 64-bit caused 32-bit builds to regress:
> 
> drivers/net/ethernet/ni/nixge.c: In function 'nixge_hw_dma_bd_release':
> drivers/net/ethernet/ni/nixge.c:254:9: error: cast to pointer from integer of different size [-Werror=int-to-pointer-cast]
>    skb = (struct sk_buff *)
>          ^
> In file included from include/linux/skbuff.h:17,
>                  from include/linux/if_ether.h:23,
>                  from include/linux/etherdevice.h:25,
>                  from drivers/net/ethernet/ni/nixge.c:7:
> drivers/net/ethernet/ni/nixge.c: In function 'nixge_hw_dma_bd_init':
> drivers/net/ethernet/ni/nixge.c:130:37: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
>    (bd)->field##_lo = lower_32_bits(((u64)addr)); \
>                                      ^
> include/linux/kernel.h:234:33: note: in definition of macro 'lower_32_bits'
>  #define lower_32_bits(n) ((u32)(n))
>                                  ^
> 
> Casting to a uintptr_t avoids all these warnings.
> 
> Fixes: 7e8d5755be0e ("net: nixge: Add support for 64-bit platforms")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/net/ethernet/ni/nixge.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c
> index 74cf52e3fb09..2e132f6a7c36 100644
> --- a/drivers/net/ethernet/ni/nixge.c
> +++ b/drivers/net/ethernet/ni/nixge.c
> @@ -127,8 +127,8 @@ struct nixge_hw_dma_bd {
>  #ifdef CONFIG_PHYS_ADDR_T_64BIT
>  #define nixge_hw_dma_bd_set_addr(bd, field, addr) \
>  	do { \
> -		(bd)->field##_lo = lower_32_bits(((u64)addr)); \
> -		(bd)->field##_hi = upper_32_bits(((u64)addr)); \
> +		(bd)->field##_lo = lower_32_bits(((uintptr_t)addr)); \
> +		(bd)->field##_hi = upper_32_bits(((uintptr_t)addr)); \
>  	} while (0)
>  #else
>  #define nixge_hw_dma_bd_set_addr(bd, field, addr) \
> @@ -251,7 +251,7 @@ static void nixge_hw_dma_bd_release(struct net_device *ndev)
>  				 NIXGE_MAX_JUMBO_FRAME_SIZE,
>  				 DMA_FROM_DEVICE);
>  
> -		skb = (struct sk_buff *)
> +		skb = (struct sk_buff *)(uintptr_t)
>  			nixge_hw_dma_bd_get_addr(&priv->rx_bd_v[i],
>  						 sw_id_offset);
>  		dev_kfree_skb(skb);
> @@ -601,8 +601,8 @@ static int nixge_recv(struct net_device *ndev, int budget)
>  		tail_p = priv->rx_bd_p + sizeof(*priv->rx_bd_v) *
>  			 priv->rx_bd_ci;
>  
> -		skb = (struct sk_buff *)nixge_hw_dma_bd_get_addr(cur_p,
> -								 sw_id_offset);
> +		skb = (struct sk_buff *)(uintptr_t)
> +			nixge_hw_dma_bd_get_addr(cur_p, sw_id_offset);
>  
>  		length = cur_p->status & XAXIDMA_BD_STS_ACTUAL_LEN_MASK;
>  		if (length > NIXGE_MAX_JUMBO_FRAME_SIZE)
> -- 
> 2.18.0
> 

I had submitted a similar patch https://lkml.org/lkml/2018/9/24/1719
here. I should probably add the Fixes tag yours has but other than that
they look largely equivalent. Comments?

Thanks,

Moritz

  reply	other threads:[~2018-09-26 16:03 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-26 12:47 [PATCH] net: nixge: fix warnings on 32-bit platforms Arnd Bergmann
2018-09-26 16:03 ` Moritz Fischer [this message]
2018-09-26 18:47   ` Arnd Bergmann

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=20180926160328.GA1927@archbook \
    --to=mdf@kernel.org \
    --cc=arnd@arndb.de \
    --cc=davem@davemloft.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.