Commit a8d2e817 authored by Aaro Koskinen's avatar Aaro Koskinen Committed by Greg Kroah-Hartman

staging: octeon-ethernet: sgmii/xaui: make link poll generic

Make link poll generic to avoid copy paste.
Signed-off-by: default avatarAaro Koskinen <aaro.koskinen@iki.fi>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2638f713
...@@ -41,31 +41,9 @@ ...@@ -41,31 +41,9 @@
#include <asm/octeon/cvmx-gmxx-defs.h> #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) 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) int cvm_oct_sgmii_init(struct net_device *dev)
......
...@@ -41,31 +41,9 @@ ...@@ -41,31 +41,9 @@
#include <asm/octeon/cvmx-gmxx-defs.h> #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) 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) int cvm_oct_xaui_init(struct net_device *dev)
...@@ -74,7 +52,7 @@ 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); cvm_oct_common_init(dev);
if (!octeon_is_simulation() && priv->phydev == NULL) if (!octeon_is_simulation() && priv->phydev == NULL)
priv->poll = cvm_oct_xaui_poll; priv->poll = cvm_oct_link_poll;
return 0; return 0;
} }
...@@ -541,6 +541,27 @@ int cvm_oct_common_open(struct net_device *dev, ...@@ -541,6 +541,27 @@ int cvm_oct_common_open(struct net_device *dev,
return 0; 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 = { static const struct net_device_ops cvm_oct_npi_netdev_ops = {
.ndo_init = cvm_oct_common_init, .ndo_init = cvm_oct_common_init,
.ndo_uninit = cvm_oct_common_uninit, .ndo_uninit = cvm_oct_common_uninit,
......
...@@ -90,6 +90,7 @@ int cvm_oct_common_open(struct net_device *dev, ...@@ -90,6 +90,7 @@ int cvm_oct_common_open(struct net_device *dev,
void (*link_poll)(struct net_device *), bool poll_now); void (*link_poll)(struct net_device *), bool poll_now);
void cvm_oct_note_carrier(struct octeon_ethernet *priv, void cvm_oct_note_carrier(struct octeon_ethernet *priv,
cvmx_helper_link_info_t li); cvmx_helper_link_info_t li);
void cvm_oct_link_poll(struct net_device *dev);
extern int always_use_pow; extern int always_use_pow;
extern int pow_send_group; extern int pow_send_group;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment