staging: octeon-ethernet: sgmii/xaui: make link poll generic
authorAaro Koskinen <aaro.koskinen@iki.fi>
Sat, 4 Apr 2015 19:51:08 +0000 (22:51 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 30 Apr 2015 14:59:24 +0000 (16:59 +0200)
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>
drivers/staging/octeon/ethernet-sgmii.c
drivers/staging/octeon/ethernet-xaui.c
drivers/staging/octeon/ethernet.c
drivers/staging/octeon/octeon-ethernet.h

index 9a747f94d48c2ae6e4d51271e63d03767deab343..1940f4b72a66ebb38a6d61af8b07c0b74b438871 100644 (file)
 
 #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)
index 888b70b93a7b3d02e11ec80cb23a4865f2e0caf8..42a4d2be0cffb6391513197b955dcd2cd4f82fa2 100644 (file)
 
 #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;
 }
index a7f1fcb4762a8d89c224d41b9d231302e613e3bd..d395bf527d916dbacef0ccd800cd6065eaabe7c1 100644 (file)
@@ -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,
index 1e77f1d23c7410fbc700712e2513364329a99bd0..22d726e0d2d03b2f4859c0645107efe063d2b6bc 100644 (file)
@@ -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;