Skip to content

Commit ce37115

Browse files
hkallweitdavem330
authored andcommitted
r8169: factor out reading MAC address from registers
For RTL8125 we will have to read the MAC address also from another register range, therefore create a small helper. Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent c623305 commit ce37115

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/net/ethernet/realtek/r8169_main.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,14 @@ static bool rtl_supports_eee(struct rtl8169_private *tp)
741741
tp->mac_version != RTL_GIGA_MAC_VER_39;
742742
}
743743

744+
static void rtl_read_mac_from_reg(struct rtl8169_private *tp, u8 *mac, int reg)
745+
{
746+
int i;
747+
748+
for (i = 0; i < ETH_ALEN; i++)
749+
mac[i] = RTL_R8(tp, reg + i);
750+
}
751+
744752
struct rtl_cond {
745753
bool (*check)(struct rtl8169_private *);
746754
const char *msg;
@@ -6630,7 +6638,7 @@ static void rtl_init_mac_address(struct rtl8169_private *tp)
66306638
{
66316639
struct net_device *dev = tp->dev;
66326640
u8 *mac_addr = dev->dev_addr;
6633-
int rc, i;
6641+
int rc;
66346642

66356643
rc = eth_platform_get_mac_address(tp_to_dev(tp), mac_addr);
66366644
if (!rc)
@@ -6640,8 +6648,7 @@ static void rtl_init_mac_address(struct rtl8169_private *tp)
66406648
if (is_valid_ether_addr(mac_addr))
66416649
goto done;
66426650

6643-
for (i = 0; i < ETH_ALEN; i++)
6644-
mac_addr[i] = RTL_R8(tp, MAC0 + i);
6651+
rtl_read_mac_from_reg(tp, mac_addr, MAC0);
66456652
if (is_valid_ether_addr(mac_addr))
66466653
goto done;
66476654

0 commit comments

Comments
 (0)