net: nixge: fix warnings on 32-bit platforms
Subsystems (2)
PATCH 1/1 net: nixge: fix warnings on 32-bit platforms
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.
--- drivers/net/ethernet/ni/nixge.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
drivers/net/ethernet/ni/nixge.c +5 -5
@@ -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 )
Signature · 1 line
2.18.0
Hi Arnd,
Quoted 64 lines · Arnd Bergmann
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 = (structsk_buff*)^In file included from
include/linux/skbuff.h:17,
frominclude/linux/if_ether.h:23,
frominclude/linux/etherdevice.h:25,
fromdrivers/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_tavoids all these warnings.Fixes 7e8d5755be0e ("net: nixge: Add support for 64-bit platforms")Signed-off-by Arnd Bergmann <[email protected]>--- drivers/net/ethernet/ni/nixge.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)drivers/net/ethernet/ni/nixge.c +5
-5@@ -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 )Signature · 1 line
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
Quoted 11 lines · Moritz Fischer
Hi Arnd,
Quoted 3 lines · Arnd Bergmann
Making it work on 64-bit caused 32-bit builds to regress:
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?
Yes, I'm sure your version is fine as well, sorry for missing that.
Adding a fixes tag is generally a good idea, but no need to resend it. We just need one of the two to get picked up into net-next.
[note: we both forgot to tag the patch as "[PATCH net-next]"]
Arnd