From a8d2e8171082854dadea64b808af4b54f78c0384 Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:08 +0300 Subject: [PATCH] staging: octeon-ethernet: sgmii/xaui: make link poll generic Make link poll generic to avoid copy paste. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-sgmii.c | 24 +--------------------- drivers/staging/octeon/ethernet-xaui.c | 26 ++---------------------- drivers/staging/octeon/ethernet.c | 21 +++++++++++++++++++ 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 9a747f94d48c..1940f4b72a66 100644 --- a/drivers/staging/octeon/ethernet-sgmii.c +++ b/drivers/staging/octeon/ethernet-sgmii.c @@ -41,31 +41,9 @@ #include -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 888b70b93a7b..42a4d2be0cff 100644 --- a/drivers/staging/octeon/ethernet-xaui.c +++ b/drivers/staging/octeon/ethernet-xaui.c @@ -41,31 +41,9 @@ #include -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 a7f1fcb4762a..d395bf527d91 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 1e77f1d23c74..22d726e0d2d0 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; -- 2.20.1