Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: fs_enet: Fix warning due to wrong type

Building fs_enet on powerpc e500 leads to following warning:

CC drivers/net/ethernet/freescale/fs_enet/mac-scc.o
In file included from ./include/linux/build_bug.h:5,
from ./include/linux/container_of.h:5,
from ./include/linux/list.h:5,
from ./include/linux/module.h:12,
from drivers/net/ethernet/freescale/fs_enet/mac-scc.c:15:
drivers/net/ethernet/freescale/fs_enet/mac-scc.c: In function 'allocate_bd':
./include/linux/err.h:28:49: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
28 | #define IS_ERR_VALUE(x) unlikely((unsigned long)(void *)(x) >= (unsigned long)-MAX_ERRNO)
| ^
./include/linux/compiler.h:77:45: note: in definition of macro 'unlikely'
77 | # define unlikely(x) __builtin_expect(!!(x), 0)
| ^
drivers/net/ethernet/freescale/fs_enet/mac-scc.c:138:13: note: in expansion of macro 'IS_ERR_VALUE'
138 | if (IS_ERR_VALUE(fep->ring_mem_addr))
| ^~~~~~~~~~~~

This is due to fep->ring_mem_addr not being a pointer but a DMA
address which is 64 bits on that platform while pointers are
32 bits as this is a 32 bits platform with wider physical bus.

However, using fep->ring_mem_addr is just wrong because
cpm_muram_alloc() returns an offset within the muram and not
a physical address directly. So use fpi->dpram_offset instead.

Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Reviewed-by: Simon Horman <horms@kernel.org>
Link: https://patch.msgid.link/ec67ea3a3bef7e58b8dc959f7c17d405af0d27e4.1723101144.git.christophe.leroy@csgroup.eu
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Christophe Leroy and committed by
Jakub Kicinski
c146f3d1 2d5c9dd2

+9 -9
+9 -9
drivers/net/ethernet/freescale/fs_enet/mac-scc.c
··· 131 131 static int allocate_bd(struct net_device *dev) 132 132 { 133 133 struct fs_enet_private *fep = netdev_priv(dev); 134 - const struct fs_platform_info *fpi = fep->fpi; 134 + struct fs_platform_info *fpi = fep->fpi; 135 135 136 - fep->ring_mem_addr = cpm_muram_alloc((fpi->tx_ring + fpi->rx_ring) * 137 - sizeof(cbd_t), 8); 138 - if (IS_ERR_VALUE(fep->ring_mem_addr)) 136 + fpi->dpram_offset = cpm_muram_alloc((fpi->tx_ring + fpi->rx_ring) * 137 + sizeof(cbd_t), 8); 138 + if (IS_ERR_VALUE(fpi->dpram_offset)) 139 139 return -ENOMEM; 140 140 141 - fep->ring_base = (void __iomem __force*) 142 - cpm_muram_addr(fep->ring_mem_addr); 141 + fep->ring_base = cpm_muram_addr(fpi->dpram_offset); 143 142 144 143 return 0; 145 144 } ··· 146 147 static void free_bd(struct net_device *dev) 147 148 { 148 149 struct fs_enet_private *fep = netdev_priv(dev); 150 + const struct fs_platform_info *fpi = fep->fpi; 149 151 150 152 if (fep->ring_base) 151 - cpm_muram_free(fep->ring_mem_addr); 153 + cpm_muram_free(fpi->dpram_offset); 152 154 } 153 155 154 156 static void cleanup_data(struct net_device *dev) ··· 247 247 __fs_out8((u8 __iomem *)ep + i, 0); 248 248 249 249 /* point to bds */ 250 - W16(ep, sen_genscc.scc_rbase, fep->ring_mem_addr); 250 + W16(ep, sen_genscc.scc_rbase, fpi->dpram_offset); 251 251 W16(ep, sen_genscc.scc_tbase, 252 - fep->ring_mem_addr + sizeof(cbd_t) * fpi->rx_ring); 252 + fpi->dpram_offset + sizeof(cbd_t) * fpi->rx_ring); 253 253 254 254 /* Initialize function code registers for big-endian. 255 255 */