Skip to content

Commit

Permalink
Merge branch 'renesas-read-mac'
Browse files Browse the repository at this point in the history
Sergei Shtylyov says:

====================
Renesas: read MAC address registers only once

Here's 2 patches against DaveM's 'net-next.git' repo. Here we optimize
the MAC address register reading (left over from a bootloader).

[1/2] ravb: read MAC address registers only once
[2/2] sh_eth: read MAC address registers only once
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Dec 6, 2015
2 parents 04f9646 + 37742f0 commit b82583e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
15 changes: 9 additions & 6 deletions drivers/net/ethernet/renesas/ravb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,15 @@ static void ravb_read_mac_address(struct net_device *ndev, const u8 *mac)
if (mac) {
ether_addr_copy(ndev->dev_addr, mac);
} else {
ndev->dev_addr[0] = (ravb_read(ndev, MAHR) >> 24);
ndev->dev_addr[1] = (ravb_read(ndev, MAHR) >> 16) & 0xFF;
ndev->dev_addr[2] = (ravb_read(ndev, MAHR) >> 8) & 0xFF;
ndev->dev_addr[3] = (ravb_read(ndev, MAHR) >> 0) & 0xFF;
ndev->dev_addr[4] = (ravb_read(ndev, MALR) >> 8) & 0xFF;
ndev->dev_addr[5] = (ravb_read(ndev, MALR) >> 0) & 0xFF;
u32 mahr = ravb_read(ndev, MAHR);
u32 malr = ravb_read(ndev, MALR);

ndev->dev_addr[0] = (mahr >> 24) & 0xFF;
ndev->dev_addr[1] = (mahr >> 16) & 0xFF;
ndev->dev_addr[2] = (mahr >> 8) & 0xFF;
ndev->dev_addr[3] = (mahr >> 0) & 0xFF;
ndev->dev_addr[4] = (malr >> 8) & 0xFF;
ndev->dev_addr[5] = (malr >> 0) & 0xFF;
}
}

Expand Down
15 changes: 9 additions & 6 deletions drivers/net/ethernet/renesas/sh_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -989,12 +989,15 @@ static void read_mac_address(struct net_device *ndev, unsigned char *mac)
if (mac[0] || mac[1] || mac[2] || mac[3] || mac[4] || mac[5]) {
memcpy(ndev->dev_addr, mac, ETH_ALEN);
} else {
ndev->dev_addr[0] = (sh_eth_read(ndev, MAHR) >> 24);
ndev->dev_addr[1] = (sh_eth_read(ndev, MAHR) >> 16) & 0xFF;
ndev->dev_addr[2] = (sh_eth_read(ndev, MAHR) >> 8) & 0xFF;
ndev->dev_addr[3] = (sh_eth_read(ndev, MAHR) & 0xFF);
ndev->dev_addr[4] = (sh_eth_read(ndev, MALR) >> 8) & 0xFF;
ndev->dev_addr[5] = (sh_eth_read(ndev, MALR) & 0xFF);
u32 mahr = sh_eth_read(ndev, MAHR);
u32 malr = sh_eth_read(ndev, MALR);

ndev->dev_addr[0] = (mahr >> 24) & 0xFF;
ndev->dev_addr[1] = (mahr >> 16) & 0xFF;
ndev->dev_addr[2] = (mahr >> 8) & 0xFF;
ndev->dev_addr[3] = (mahr >> 0) & 0xFF;
ndev->dev_addr[4] = (malr >> 8) & 0xFF;
ndev->dev_addr[5] = (malr >> 0) & 0xFF;
}
}

Expand Down

0 comments on commit b82583e

Please sign in to comment.