Skip to content

Commit

Permalink
net: natsemi: fix hw address initialization for jazz and xtensa
Browse files Browse the repository at this point in the history
Use eth_hw_addr_set function instead of writing the address directly to
net_device::dev_addr.

Fixes: adeef3e ("net: constify netdev->dev_addr")
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Link: https://lore.kernel.org/r/20211130143600.31970-1-jcmvbkbc@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Max Filippov authored and Jakub Kicinski committed Dec 1, 2021
1 parent 5cfe53c commit 23ea630
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions drivers/net/ethernet/natsemi/jazzsonic.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ static int sonic_probe1(struct net_device *dev)
struct sonic_local *lp = netdev_priv(dev);
int err = -ENODEV;
int i;
unsigned char addr[ETH_ALEN];

if (!request_mem_region(dev->base_addr, SONIC_MEM_SIZE, jazz_sonic_string))
return -EBUSY;
Expand Down Expand Up @@ -143,9 +144,10 @@ static int sonic_probe1(struct net_device *dev)
SONIC_WRITE(SONIC_CEP,0);
for (i=0; i<3; i++) {
val = SONIC_READ(SONIC_CAP0-i);
dev->dev_addr[i*2] = val;
dev->dev_addr[i*2+1] = val >> 8;
addr[i*2] = val;
addr[i*2+1] = val >> 8;
}
eth_hw_addr_set(dev, addr);

lp->dma_bitmode = SONIC_BITMODE32;

Expand Down
6 changes: 4 additions & 2 deletions drivers/net/ethernet/natsemi/xtsonic.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ static int __init sonic_probe1(struct net_device *dev)
unsigned int base_addr = dev->base_addr;
int i;
int err = 0;
unsigned char addr[ETH_ALEN];

if (!request_mem_region(base_addr, 0x100, xtsonic_string))
return -EBUSY;
Expand Down Expand Up @@ -163,9 +164,10 @@ static int __init sonic_probe1(struct net_device *dev)

for (i=0; i<3; i++) {
unsigned int val = SONIC_READ(SONIC_CAP0-i);
dev->dev_addr[i*2] = val;
dev->dev_addr[i*2+1] = val >> 8;
addr[i*2] = val;
addr[i*2+1] = val >> 8;
}
eth_hw_addr_set(dev, addr);

lp->dma_bitmode = SONIC_BITMODE32;

Expand Down

0 comments on commit 23ea630

Please sign in to comment.