Skip to content

Commit

Permalink
r8169: add helper rtl_is_8168evl_up
Browse files Browse the repository at this point in the history
Add helper rtl_is_8168evl_up to make the code better readable and to
simplify it.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Heiner Kallweit authored and David S. Miller committed Jun 14, 2019
1 parent 20023d3 commit 9e9f33b
Showing 1 changed file with 12 additions and 17 deletions.
29 changes: 12 additions & 17 deletions drivers/net/ethernet/realtek/r8169_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,6 +724,12 @@ static void rtl_tx_performance_tweak(struct rtl8169_private *tp, u16 force)
PCI_EXP_DEVCTL_READRQ, force);
}

static bool rtl_is_8168evl_up(struct rtl8169_private *tp)
{
return tp->mac_version >= RTL_GIGA_MAC_VER_34 &&
tp->mac_version != RTL_GIGA_MAC_VER_39;
}

struct rtl_cond {
bool (*check)(struct rtl8169_private *);
const char *msg;
Expand Down Expand Up @@ -1389,20 +1395,16 @@ static void __rtl8169_set_wol(struct rtl8169_private *tp, u32 wolopts)

rtl_unlock_config_regs(tp);

switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_34 ... RTL_GIGA_MAC_VER_38:
case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_51:
if (rtl_is_8168evl_up(tp)) {
tmp = ARRAY_SIZE(cfg) - 1;
if (wolopts & WAKE_MAGIC)
rtl_eri_set_bits(tp, 0x0dc, ERIAR_MASK_0100,
MagicPacket_v2);
else
rtl_eri_clear_bits(tp, 0x0dc, ERIAR_MASK_0100,
MagicPacket_v2);
break;
default:
} else {
tmp = ARRAY_SIZE(cfg);
break;
}

for (i = 0; i < tmp; i++) {
Expand Down Expand Up @@ -4101,8 +4103,7 @@ static void rtl_set_tx_config_registers(struct rtl8169_private *tp)
u32 val = TX_DMA_BURST << TxDMAShift |
InterFrameGap << TxInterFrameGapShift;

if (tp->mac_version >= RTL_GIGA_MAC_VER_34 &&
tp->mac_version != RTL_GIGA_MAC_VER_39)
if (rtl_is_8168evl_up(tp))
val |= TXCFG_AUTO_FIFO;

RTL_W32(tp, TxConfig, val);
Expand Down Expand Up @@ -6483,13 +6484,10 @@ static int rtl_alloc_irq(struct rtl8169_private *tp)
static void rtl_read_mac_address(struct rtl8169_private *tp,
u8 mac_addr[ETH_ALEN])
{
u32 value;

/* Get MAC address */
switch (tp->mac_version) {
case RTL_GIGA_MAC_VER_35 ... RTL_GIGA_MAC_VER_38:
case RTL_GIGA_MAC_VER_40 ... RTL_GIGA_MAC_VER_51:
value = rtl_eri_read(tp, 0xe0);
if (rtl_is_8168evl_up(tp) && tp->mac_version != RTL_GIGA_MAC_VER_34) {
u32 value = rtl_eri_read(tp, 0xe0);

mac_addr[0] = (value >> 0) & 0xff;
mac_addr[1] = (value >> 8) & 0xff;
mac_addr[2] = (value >> 16) & 0xff;
Expand All @@ -6498,9 +6496,6 @@ static void rtl_read_mac_address(struct rtl8169_private *tp,
value = rtl_eri_read(tp, 0xe4);
mac_addr[4] = (value >> 0) & 0xff;
mac_addr[5] = (value >> 8) & 0xff;
break;
default:
break;
}
}

Expand Down

0 comments on commit 9e9f33b

Please sign in to comment.