Skip to content

Commit

Permalink
r8169: change argument type of counters handling functions
Browse files Browse the repository at this point in the history
The counter handling functions don't deal with the net_device, so code
can be simplified by changing the argument type to
struct rtl8169_private *.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
hkallweit authored and davem330 committed Apr 19, 2018
1 parent 61cb532 commit e71c9ce
Showing 1 changed file with 13 additions and 19 deletions.
32 changes: 13 additions & 19 deletions drivers/net/ethernet/realtek/r8169.c
Original file line number Diff line number Diff line change
Expand Up @@ -2151,9 +2151,8 @@ DECLARE_RTL_COND(rtl_counters_cond)
return RTL_R32(tp, CounterAddrLow) & (CounterReset | CounterDump);
}

static bool rtl8169_do_counters(struct net_device *dev, u32 counter_cmd)
static bool rtl8169_do_counters(struct rtl8169_private *tp, u32 counter_cmd)
{
struct rtl8169_private *tp = netdev_priv(dev);
dma_addr_t paddr = tp->counters_phys_addr;
u32 cmd;

Expand All @@ -2166,37 +2165,32 @@ static bool rtl8169_do_counters(struct net_device *dev, u32 counter_cmd)
return rtl_udelay_loop_wait_low(tp, &rtl_counters_cond, 10, 1000);
}

static bool rtl8169_reset_counters(struct net_device *dev)
static bool rtl8169_reset_counters(struct rtl8169_private *tp)
{
struct rtl8169_private *tp = netdev_priv(dev);

/*
* Versions prior to RTL_GIGA_MAC_VER_19 don't support resetting the
* tally counters.
*/
if (tp->mac_version < RTL_GIGA_MAC_VER_19)
return true;

return rtl8169_do_counters(dev, CounterReset);
return rtl8169_do_counters(tp, CounterReset);
}

static bool rtl8169_update_counters(struct net_device *dev)
static bool rtl8169_update_counters(struct rtl8169_private *tp)
{
struct rtl8169_private *tp = netdev_priv(dev);

/*
* Some chips are unable to dump tally counters when the receiver
* is disabled.
*/
if ((RTL_R8(tp, ChipCmd) & CmdRxEnb) == 0)
return true;

return rtl8169_do_counters(dev, CounterDump);
return rtl8169_do_counters(tp, CounterDump);
}

static bool rtl8169_init_counter_offsets(struct net_device *dev)
static bool rtl8169_init_counter_offsets(struct rtl8169_private *tp)
{
struct rtl8169_private *tp = netdev_priv(dev);
struct rtl8169_counters *counters = tp->counters;
bool ret = false;

Expand All @@ -2219,10 +2213,10 @@ static bool rtl8169_init_counter_offsets(struct net_device *dev)
return true;

/* If both, reset and update fail, propagate to caller. */
if (rtl8169_reset_counters(dev))
if (rtl8169_reset_counters(tp))
ret = true;

if (rtl8169_update_counters(dev))
if (rtl8169_update_counters(tp))
ret = true;

tp->tc_offset.tx_errors = counters->tx_errors;
Expand All @@ -2245,7 +2239,7 @@ static void rtl8169_get_ethtool_stats(struct net_device *dev,
pm_runtime_get_noresume(d);

if (pm_runtime_active(d))
rtl8169_update_counters(dev);
rtl8169_update_counters(tp);

pm_runtime_put_noidle(d);

Expand Down Expand Up @@ -7601,7 +7595,7 @@ static int rtl8169_close(struct net_device *dev)
pm_runtime_get_sync(&pdev->dev);

/* Update counters before going down */
rtl8169_update_counters(dev);
rtl8169_update_counters(tp);

rtl_lock_work(tp);
clear_bit(RTL_FLAG_TASK_ENABLED, tp->wk.flags);
Expand Down Expand Up @@ -7685,7 +7679,7 @@ static int rtl_open(struct net_device *dev)

rtl_hw_start(tp);

if (!rtl8169_init_counter_offsets(dev))
if (!rtl8169_init_counter_offsets(tp))
netif_warn(tp, hw, dev, "counter reset/update failed\n");

netif_start_queue(dev);
Expand Down Expand Up @@ -7754,7 +7748,7 @@ rtl8169_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
* from tally counters.
*/
if (pm_runtime_active(&pdev->dev))
rtl8169_update_counters(dev);
rtl8169_update_counters(tp);

/*
* Subtract values fetched during initalization.
Expand Down Expand Up @@ -7850,7 +7844,7 @@ static int rtl8169_runtime_suspend(struct device *device)

/* Update counters before going runtime suspend */
rtl8169_rx_missed(dev);
rtl8169_update_counters(dev);
rtl8169_update_counters(tp);

return 0;
}
Expand Down

0 comments on commit e71c9ce

Please sign in to comment.