ethernet: fix some esoteric drivers after netdev->dev_addr constification
Subsystems (5)
Jakub Kicinski
maintainerv2 cover ethernet: fix some esoteric drivers after netdev->dev_addr constification
Looking at recent fixes for drivers which don't get included with allmodconfig builds I thought it's worth grepping for more instances of:
dev->dev_addr\[.*\] =
This set contains the fixes.
v2: add last 3 patches which fix drivers for the RiscPC ARM platform. Thanks to Arnd Bergmann for explaining how to build test that.
Jakub Kicinski (6):
ethernet: 3com/typhoon: don't write directly to netdev->dev_addr
ethernet: tundra: don't write directly to netdev->dev_addr
ethernet: broadcom/sb1250-mac: don't write directly to
netdev->dev_addr
ethernet: i825xx: don't write directly to netdev->dev_addr
ethernet: 8390/etherh: don't write directly to netdev->dev_addr
ethernet: seeq/ether3: don't write directly to netdev->dev_addr
drivers/net/ethernet/3com/typhoon.c | 6 ++-- drivers/net/ethernet/8390/etherh.c | 6 ++-- drivers/net/ethernet/broadcom/sb1250-mac.c | 4 +-- drivers/net/ethernet/i825xx/ether1.c | 4 ++- drivers/net/ethernet/seeq/ether3.c | 4 ++- drivers/net/ethernet/tundra/tsi108_eth.c | 35 +++++++++++----------- 6 files changed, 33 insertions(+), 26 deletions(-)
Signature · 1 line
2.34.1
Jakub Kicinski
maintainerPATCH v2 1/6 ethernet: 3com/typhoon: don't write directly to netdev->dev_addr
This driver casts off the const and writes directly to netdev->dev_addr. This will result in a MAC address tree corruption and a warning.
Compile tested ppc6xx_defconfig.
--- drivers/net/ethernet/3com/typhoon.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/3com/typhoon.c +4 -2
@@ -2278,6 +2278,7 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)struct net_device *dev;struct typhoon *tp;int card_id = (int ) ent->driver_data; +u8 addr[ETH_ALEN ]__aligned(4) ;void __iomem *ioaddr;void *shared;dma_addr_t shared_dma;
@@ -2409,8 +2410,9 @@ typhoon_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) goto error_out_reset; } - *(__be16 *)&dev->dev_addr[0 ] =htons (le16_to_cpu (xp_resp[0 ].parm1)); - *(__be32 *)&dev->dev_addr[2 ] =htonl (le32_to_cpu (xp_resp[0 ].parm2)); + *(__be16 *)&addr[0 ] =htons (le16_to_cpu (xp_resp[0 ].parm1)); + *(__be32 *)&addr[2 ] =htonl (le32_to_cpu (xp_resp[0 ].parm2)); +eth_hw_addr_set (dev, addr);if (!is_valid_ether_addr (dev->dev_addr)) { err_msg ="Could not obtain valid ethernet address, aborting" ;
Signature · 1 line
2.34.1
Jakub Kicinski
maintainerPATCH v2 2/6 ethernet: tundra: don't write directly to netdev->dev_addr
In reply to Jakub Kicinskinetdev->dev_addr is const now.
Maintain the questionable offsetting in ndo_set_mac_address.
Compile tested holly_defconfig and mpc7448_hpc2_defconfig.
--- drivers/net/ethernet/tundra/tsi108_eth.c | 35 ++++++++++++------------ 1 file changed, 18 insertions(+), 17 deletions(-)
drivers/net/ethernet/tundra/tsi108_eth.c +18 -17
@@ -1091,20 +1091,22 @@ static int tsi108_get_mac(struct net_device *dev)struct tsi108_prv_data *data =netdev_priv (dev);u32 word1 =TSI_READ (TSI108_MAC_ADDR1 );u32 word2 =TSI_READ (TSI108_MAC_ADDR2 ); +u8 addr[ETH_ALEN ];/* Note that the octets are reversed from what the manual says, * producing an even weirder ordering... */ if (word2 ==0 && word1 ==0 ) { - dev->dev_addr[0 ] =0x00 ; - dev->dev_addr[1 ] =0x06 ; - dev->dev_addr[2 ] =0xd2 ; - dev->dev_addr[3 ] =0x00 ; - dev->dev_addr[4 ] =0x00 ; + addr[0 ] =0x00 ; + addr[1 ] =0x06 ; + addr[2 ] =0xd2 ; + addr[3 ] =0x00 ; + addr[4 ] =0x00 ;if (0x8 == data->phy) - dev->dev_addr[5 ] =0x01 ; + addr[5 ] =0x01 ;else - dev->dev_addr[5 ] =0x02 ; + addr[5 ] =0x02 ; +eth_hw_addr_set (dev, addr); word2 = (dev->dev_addr[0 ] <<16 ) | (dev->dev_addr[1 ] <<24 );
@@ -1114,12 +1116,13 @@ static int tsi108_get_mac(struct net_device *dev)TSI_WRITE (TSI108_MAC_ADDR1 , word1);TSI_WRITE (TSI108_MAC_ADDR2 , word2); }else { - dev->dev_addr[0 ] = (word2 >>16 ) &0xff ; - dev->dev_addr[1 ] = (word2 >>24 ) &0xff ; - dev->dev_addr[2 ] = (word1 >>0 ) &0xff ; - dev->dev_addr[3 ] = (word1 >>8 ) &0xff ; - dev->dev_addr[4 ] = (word1 >>16 ) &0xff ; - dev->dev_addr[5 ] = (word1 >>24 ) &0xff ; + addr[0 ] = (word2 >>16 ) &0xff ; + addr[1 ] = (word2 >>24 ) &0xff ; + addr[2 ] = (word1 >>0 ) &0xff ; + addr[3 ] = (word1 >>8 ) &0xff ; + addr[4 ] = (word1 >>16 ) &0xff ; + addr[5 ] = (word1 >>24 ) &0xff ; +eth_hw_addr_set (dev, addr); }if (!is_valid_ether_addr (dev->dev_addr)) {
@@ -1136,14 +1139,12 @@ static int tsi108_set_mac(struct net_device *dev, void *addr) {struct tsi108_prv_data *data =netdev_priv (dev);u32 word1, word2; -int i;if (!is_valid_ether_addr (addr))return -EADDRNOTAVAIL ; -for (i =0 ; i <6 ; i++) -/* +2 is for the offset of the HW addr type */ - dev->dev_addr[i] = ((unsigned char *)addr)[i +2 ]; +/* +2 is for the offset of the HW addr type */ +eth_hw_addr_set (dev, ((unsigned char *)addr) +2 ); word2 = (dev->dev_addr[0 ] <<16 ) | (dev->dev_addr[1 ] <<24 );
Signature · 1 line
2.34.1
Jakub Kicinski
maintainerPATCH v2 3/6 ethernet: broadcom/sb1250-mac: don't write directly to netdev->dev_addr
In reply to Jakub Kicinskinetdev->dev_addr is const now.
Compile tested bigsur_defconfig and sb1250_swarm_defconfig.
--- drivers/net/ethernet/broadcom/sb1250-mac.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/ethernet/broadcom/sb1250-mac.c +1 -3
@@ -2183,9 +2183,7 @@ static int sbmac_init(struct platform_device *pldev, long long base) ea_reg >>=8 ; } -for (i =0 ; i <6 ; i++) { - dev->dev_addr[i] = eaddr[i]; - } +eth_hw_addr_set (dev, eaddr);/* * Initialize context (get pointers to registers and stuff), then
Signature · 1 line
2.34.1
Jakub Kicinski
maintainerPATCH v2 4/6 ethernet: i825xx: don't write directly to netdev->dev_addr
In reply to Jakub Kicinskinetdev->dev_addr is const now.
Compile tested rpc_defconfig w/ GCC 8.5.
--- drivers/net/ethernet/i825xx/ether1.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/i825xx/ether1.c +3 -1
@@ -986,6 +986,7 @@ static int ether1_probe(struct expansion_card *ec, const struct ecard_id *id) { struct net_device *dev; +u8 addr[ETH_ALEN ];int i, ret =0 ;ether1_banner ();
@@ -1015,7 +1016,8 @@ ether1_probe(struct expansion_card *ec, const struct ecard_id *id) }for (i =0 ; i <6 ; i++) - dev->dev_addr[i] =readb (IDPROM_ADDRESS + (i <<2 )); + addr[i] =readb (IDPROM_ADDRESS + (i <<2 )); +eth_hw_addr_set (dev, addr);if (ether1_init_2 (dev)) { ret = -ENODEV ;
Signature · 1 line
2.34.1
Jakub Kicinski
maintainerPATCH v2 6/6 ethernet: seeq/ether3: don't write directly to netdev->dev_addr
In reply to Jakub Kicinskinetdev->dev_addr is const now.
Compile tested rpc_defconfig w/ GCC 8.5.
--- drivers/net/ethernet/seeq/ether3.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/ethernet/seeq/ether3.c +3 -1
@@ -749,6 +749,7 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id)const struct ether3_data *data = id->data;struct net_device *dev;int bus_type, ret; +u8 addr[ETH_ALEN ];ether3_banner ();
@@ -776,7 +777,8 @@ ether3_probe(struct expansion_card *ec, const struct ecard_id *id)priv (dev)->seeq =priv (dev)->base + data->base_offset; dev->irq = ec->irq; -ether3_addr (dev->dev_addr, ec); +ether3_addr (addr, ec); +eth_hw_addr_set (dev, addr);priv (dev)->dev = dev;timer_setup (&priv (dev)->timer, ether3_ledoff,0 );
Signature · 1 line
2.34.1
Jakub Kicinski
maintainerPATCH v2 5/6 ethernet: 8390/etherh: don't write directly to netdev->dev_addr
In reply to Jakub Kicinskinetdev->dev_addr is const now.
Compile tested rpc_defconfig w/ GCC 8.5.
--- drivers/net/ethernet/8390/etherh.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/8390/etherh.c +4 -2
@@ -655,6 +655,7 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id)struct ei_device *ei_local;struct net_device *dev;struct etherh_priv *eh; +u8 addr[ETH_ALEN ];int ret; ret =ecard_request_resources (ec);
@@ -724,12 +725,13 @@ etherh_probe(struct expansion_card *ec, const struct ecard_id *id)spin_lock_init (&ei_local->page_lock);if (ec->cid.product ==PROD_ANT_ETHERM ) { -etherm_addr (dev->dev_addr); +etherm_addr (addr); ei_local->reg_offset = etherm_regoffsets; }else { -etherh_addr (dev->dev_addr, ec); +etherh_addr (addr, ec); ei_local->reg_offset = etherh_regoffsets; } +eth_hw_addr_set (dev, addr); ei_local->name = dev->name; ei_local->word16 =1 ;
Signature · 1 line
2.34.1
Re: [PATCH net v2 4/6] ethernet: i825xx: don't write directly to netdev->dev_addr
In reply to Jakub KicinskiQuoted 6 lines · Jakub Kicinski
netdev->dev_addris const now.Compile tested
rpc_defconfigw/ GCC 8.5.Fixes adeef3e32146 ("net: constify netdev->dev_addr")Signed-off-by Jakub Kicinski <[email protected]>
Thanks!
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH net v2 5/6] ethernet: 8390/etherh: don't write directly to netdev->dev_addr
In reply to Jakub KicinskiQuoted 6 lines · Jakub Kicinski
netdev->dev_addris const now.Compile tested
rpc_defconfigw/ GCC 8.5.Fixes adeef3e32146 ("net: constify netdev->dev_addr")Signed-off-by Jakub Kicinski <[email protected]>
Thanks!
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
Re: [PATCH net v2 6/6] ethernet: seeq/ether3: don't write directly to netdev->dev_addr
In reply to Jakub KicinskiQuoted 6 lines · Jakub Kicinski
netdev->dev_addris const now.Compile tested
rpc_defconfigw/ GCC 8.5.Fixes adeef3e32146 ("net: constify netdev->dev_addr")Signed-off-by Jakub Kicinski <[email protected]>
Thanks!
Signature · 2 lines
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
This series was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Hello:
This series was applied to netdev/net.git (master) by David S. Miller <[email protected]>:
Quoted 8 lines · On Tue, 25 Jan 2022 16:37:55 -0800 you wrote:
Looking at recent fixes for drivers which don't get included with allmodconfig builds I thought it's worth grepping for more instances of:
dev->dev_addr\[.*\] =
This set contains the fixes.
[...]
Here is the summary with links:
- [net,v2,1/6] ethernet: 3com/typhoon: don't write directly to netdev->dev_addr
https://git.kernel.org/netdev/net/c/007c95120d1b - [net,v2,2/6] ethernet: tundra: don't write directly to netdev->dev_addr https://git.kernel.org/netdev/net/c/14ba66a60fbf - [net,v2,3/6] ethernet: broadcom/sb1250-mac: don't write directly to netdev->dev_addr https://git.kernel.org/netdev/net/c/7f6ec2b2f01b - [net,v2,4/6] ethernet: i825xx: don't write directly to netdev->dev_addr https://git.kernel.org/netdev/net/c/98ef22bbae78 - [net,v2,5/6] ethernet: 8390/etherh: don't write directly to netdev->dev_addr https://git.kernel.org/netdev/net/c/5518c5246ba6 - [net,v2,6/6] ethernet: seeq/ether3: don't write directly to netdev->dev_addr https://git.kernel.org/netdev/net/c/8eb86fc2f490
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html