diff options
author | juhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2012-11-25 16:23:03 +0000 |
---|---|---|
committer | juhosg <juhosg@3c298f89-4303-0410-b956-a3cf2f4a3e73> | 2012-11-25 16:23:03 +0000 |
commit | ac8a06ae909035f6aeaf3cdf000f4d3b3a9c086d (patch) | |
tree | 9e312582682f94e98cf2b572a5be2a81af90b6c9 /target/linux/generic/files/drivers/net | |
parent | 7931b6c13db572b93df431bf4e049303d4e7b72d (diff) | |
download | openwrt-ac8a06ae909035f6aeaf3cdf000f4d3b3a9c086d.tar.gz openwrt-ac8a06ae909035f6aeaf3cdf000f4d3b3a9c086d.zip |
AA: generic: ar8216: introduce ar8216_mib_op helper
Backport of r34297.
The ar8216_mib_{capture,flush} functions are similar.
Move the common code into a helper and use that from
the original functions.
This change also fixes a lockdep warning in
ar8216_mib_flush.
Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
git-svn-id: svn://svn.openwrt.org/openwrt/branches/attitude_adjustment@34372 3c298f89-4303-0410-b956-a3cf2f4a3e73
Diffstat (limited to 'target/linux/generic/files/drivers/net')
-rw-r--r-- | target/linux/generic/files/drivers/net/phy/ar8216.c | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/target/linux/generic/files/drivers/net/phy/ar8216.c b/target/linux/generic/files/drivers/net/phy/ar8216.c index 6187d523a..8f3aded48 100644 --- a/target/linux/generic/files/drivers/net/phy/ar8216.c +++ b/target/linux/generic/files/drivers/net/phy/ar8216.c @@ -361,7 +361,7 @@ ar8216_reg_wait(struct ar8216_priv *priv, u32 reg, u32 mask, u32 val, } static int -ar8216_mib_capture(struct ar8216_priv *priv) +ar8216_mib_op(struct ar8216_priv *priv, u32 op) { unsigned mib_func; int ret; @@ -375,8 +375,7 @@ ar8216_mib_capture(struct ar8216_priv *priv) mutex_lock(&priv->reg_mutex); /* Capture the hardware statistics for all ports */ - ar8216_rmw(priv, mib_func, AR8216_MIB_FUNC, - (AR8216_MIB_FUNC_CAPTURE << AR8216_MIB_FUNC_S)); + ar8216_rmw(priv, mib_func, AR8216_MIB_FUNC, (op << AR8216_MIB_FUNC_S)); mutex_unlock(&priv->reg_mutex); /* Wait for the capturing to complete. */ @@ -391,31 +390,15 @@ out: } static int -ar8216_mib_flush(struct ar8216_priv *priv) +ar8216_mib_capture(struct ar8216_priv *priv) { - unsigned mib_func; - int ret; - - lockdep_assert_held(&priv->mib_lock); - - if (chip_is_ar8327(priv)) - mib_func = AR8327_REG_MIB_FUNC; - else - mib_func = AR8216_REG_MIB_FUNC; - - /* Flush hardware statistics for all ports */ - ar8216_rmw(priv, mib_func, AR8216_MIB_FUNC, - (AR8216_MIB_FUNC_FLUSH << AR8216_MIB_FUNC_S)); - - /* Wait for the capturing to complete. */ - ret = ar8216_reg_wait(priv, mib_func, AR8216_MIB_BUSY, 0, 10); - if (ret) - goto out; - - ret = 0; + return ar8216_mib_op(priv, AR8216_MIB_FUNC_CAPTURE); +} -out: - return ret; +static int +ar8216_mib_flush(struct ar8216_priv *priv) +{ + return ar8216_mib_op(priv, AR8216_MIB_FUNC_FLUSH); } static void |