diff options
author | Aaro Koskinen <aaro.koskinen@iki.fi> | 2015-04-04 19:51:08 (GMT) |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-04-30 14:59:24 (GMT) |
commit | a8d2e8171082854dadea64b808af4b54f78c0384 (patch) | |
tree | 953355b1057fc7335ba1808e032eb09a307b3985 /drivers/staging/octeon | |
parent | 2638f71307f649532f613a4bcb3b163b7b63017a (diff) | |
download | linux-a8d2e8171082854dadea64b808af4b54f78c0384.tar.xz |
staging: octeon-ethernet: sgmii/xaui: make link poll generic
Make link poll generic to avoid copy paste.
Signed-off-by: Aaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/octeon')
-rw-r--r-- | drivers/staging/octeon/ethernet-sgmii.c | 24 | ||||
-rw-r--r-- | drivers/staging/octeon/ethernet-xaui.c | 26 | ||||
-rw-r--r-- | drivers/staging/octeon/ethernet.c | 21 | ||||
-rw-r--r-- | drivers/staging/octeon/octeon-ethernet.h | 1 |
4 files changed, 25 insertions, 47 deletions
diff --git a/drivers/staging/octeon/ethernet-sgmii.c b/drivers/staging/octeon/ethernet-sgmii.c index 9a747f9..1940f4b 100644 --- a/drivers/staging/octeon/ethernet-sgmii.c +++ b/drivers/staging/octeon/ethernet-sgmii.c @@ -41,31 +41,9 @@ #include <asm/octeon/cvmx-gmxx-defs.h> -static void cvm_oct_sgmii_poll(struct net_device *dev) -{ - struct octeon_ethernet *priv = netdev_priv(dev); - cvmx_helper_link_info_t link_info; - - link_info = cvmx_helper_link_get(priv->port); - if (link_info.u64 == priv->link_info) - return; - - link_info = cvmx_helper_link_autoconf(priv->port); - priv->link_info = link_info.u64; - - /* Tell Linux */ - if (link_info.s.link_up) { - if (!netif_carrier_ok(dev)) - netif_carrier_on(dev); - } else if (netif_carrier_ok(dev)) { - netif_carrier_off(dev); - } - cvm_oct_note_carrier(priv, link_info); -} - int cvm_oct_sgmii_open(struct net_device *dev) { - return cvm_oct_common_open(dev, cvm_oct_sgmii_poll, true); + return cvm_oct_common_open(dev, cvm_oct_link_poll, true); } int cvm_oct_sgmii_init(struct net_device *dev) diff --git a/drivers/staging/octeon/ethernet-xaui.c b/drivers/staging/octeon/ethernet-xaui.c index 888b70b..42a4d2b 100644 --- a/drivers/staging/octeon/ethernet-xaui.c +++ b/drivers/staging/octeon/ethernet-xaui.c @@ -41,31 +41,9 @@ #include <asm/octeon/cvmx-gmxx-defs.h> -static void cvm_oct_xaui_poll(struct net_device *dev) -{ - struct octeon_ethernet *priv = netdev_priv(dev); - cvmx_helper_link_info_t link_info; - - link_info = cvmx_helper_link_get(priv->port); - if (link_info.u64 == priv->link_info) - return; - - link_info = cvmx_helper_link_autoconf(priv->port); - priv->link_info = link_info.u64; - - /* Tell Linux */ - if (link_info.s.link_up) { - if (!netif_carrier_ok(dev)) - netif_carrier_on(dev); - } else if (netif_carrier_ok(dev)) { - netif_carrier_off(dev); - } - cvm_oct_note_carrier(priv, link_info); -} - int cvm_oct_xaui_open(struct net_device *dev) { - return cvm_oct_common_open(dev, cvm_oct_xaui_poll, true); + return cvm_oct_common_open(dev, cvm_oct_link_poll, true); } int cvm_oct_xaui_init(struct net_device *dev) @@ -74,7 +52,7 @@ int cvm_oct_xaui_init(struct net_device *dev) cvm_oct_common_init(dev); if (!octeon_is_simulation() && priv->phydev == NULL) - priv->poll = cvm_oct_xaui_poll; + priv->poll = cvm_oct_link_poll; return 0; } diff --git a/drivers/staging/octeon/ethernet.c b/drivers/staging/octeon/ethernet.c index a7f1fcb..d395bf5 100644 --- a/drivers/staging/octeon/ethernet.c +++ b/drivers/staging/octeon/ethernet.c @@ -541,6 +541,27 @@ int cvm_oct_common_open(struct net_device *dev, return 0; } +void cvm_oct_link_poll(struct net_device *dev) +{ + struct octeon_ethernet *priv = netdev_priv(dev); + cvmx_helper_link_info_t link_info; + + link_info = cvmx_helper_link_get(priv->port); + if (link_info.u64 == priv->link_info) + return; + + link_info = cvmx_helper_link_autoconf(priv->port); + priv->link_info = link_info.u64; + + if (link_info.s.link_up) { + if (!netif_carrier_ok(dev)) + netif_carrier_on(dev); + } else if (netif_carrier_ok(dev)) { + netif_carrier_off(dev); + } + cvm_oct_note_carrier(priv, link_info); +} + static const struct net_device_ops cvm_oct_npi_netdev_ops = { .ndo_init = cvm_oct_common_init, .ndo_uninit = cvm_oct_common_uninit, diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h index 1e77f1d..22d726e 100644 --- a/drivers/staging/octeon/octeon-ethernet.h +++ b/drivers/staging/octeon/octeon-ethernet.h @@ -90,6 +90,7 @@ int cvm_oct_common_open(struct net_device *dev, void (*link_poll)(struct net_device *), bool poll_now); void cvm_oct_note_carrier(struct octeon_ethernet *priv, cvmx_helper_link_info_t li); +void cvm_oct_link_poll(struct net_device *dev); extern int always_use_pow; extern int pow_send_group; |