Skip to content

Commit

Permalink
Merge branch 'r8169-small-improvements'
Browse files Browse the repository at this point in the history
Heiner Kallweit says:

====================
r8169: small improvements

This series includes a number of smaller improvements.

v2:
- return on WARN in patch 1
====================

Link: https://lore.kernel.org/r/938caef4-8a0b-bbbd-66aa-76f758ff877a@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Jakub Kicinski committed Jan 10, 2021
2 parents 4b9c935 + bb703e5 commit 43b3983
Showing 1 changed file with 10 additions and 13 deletions.
23 changes: 10 additions & 13 deletions drivers/net/ethernet/realtek/r8169_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -763,7 +763,9 @@ static void _rtl_eri_write(struct rtl8169_private *tp, int addr, u32 mask,
{
u32 cmd = ERIAR_WRITE_CMD | type | mask | addr;

BUG_ON((addr & 3) || (mask == 0));
if (WARN(addr & 3 || !mask, "addr: 0x%x, mask: 0x%08x\n", addr, mask))
return;

RTL_W32(tp, ERIDR, val);
r8168fp_adjust_ocp_cmd(tp, &cmd, type);
RTL_W32(tp, ERIAR, cmd);
Expand Down Expand Up @@ -810,14 +812,9 @@ static void rtl_eri_clear_bits(struct rtl8169_private *tp, int addr, u32 m)
rtl_w0w1_eri(tp, addr, 0, m);
}

static bool rtl_ocp_reg_failure(struct rtl8169_private *tp, u32 reg)
static bool rtl_ocp_reg_failure(u32 reg)
{
if (reg & 0xffff0001) {
if (net_ratelimit())
netdev_err(tp->dev, "Invalid ocp reg %x!\n", reg);
return true;
}
return false;
return WARN_ONCE(reg & 0xffff0001, "Invalid ocp reg %x!\n", reg);
}

DECLARE_RTL_COND(rtl_ocp_gphy_cond)
Expand All @@ -827,7 +824,7 @@ DECLARE_RTL_COND(rtl_ocp_gphy_cond)

static void r8168_phy_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data)
{
if (rtl_ocp_reg_failure(tp, reg))
if (rtl_ocp_reg_failure(reg))
return;

RTL_W32(tp, GPHY_OCP, OCPAR_FLAG | (reg << 15) | data);
Expand All @@ -837,7 +834,7 @@ static void r8168_phy_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data)

static int r8168_phy_ocp_read(struct rtl8169_private *tp, u32 reg)
{
if (rtl_ocp_reg_failure(tp, reg))
if (rtl_ocp_reg_failure(reg))
return 0;

RTL_W32(tp, GPHY_OCP, reg << 15);
Expand All @@ -848,15 +845,15 @@ static int r8168_phy_ocp_read(struct rtl8169_private *tp, u32 reg)

static void r8168_mac_ocp_write(struct rtl8169_private *tp, u32 reg, u32 data)
{
if (rtl_ocp_reg_failure(tp, reg))
if (rtl_ocp_reg_failure(reg))
return;

RTL_W32(tp, OCPDR, OCPAR_FLAG | (reg << 15) | data);
}

static u16 r8168_mac_ocp_read(struct rtl8169_private *tp, u32 reg)
{
if (rtl_ocp_reg_failure(tp, reg))
if (rtl_ocp_reg_failure(reg))
return 0;

RTL_W32(tp, OCPDR, reg << 15);
Expand Down Expand Up @@ -4895,7 +4892,7 @@ static void rtl_shutdown(struct pci_dev *pdev)
rtl_wol_shutdown_quirk(tp);
}

pci_wake_from_d3(pdev, true);
pci_wake_from_d3(pdev, tp->saved_wolopts);
pci_set_power_state(pdev, PCI_D3hot);
}
}
Expand Down

0 comments on commit 43b3983

Please sign in to comment.