From 2638f71307f649532f613a4bcb3b163b7b63017a Mon Sep 17 00:00:00 2001 From: Aaro Koskinen Date: Sat, 4 Apr 2015 22:51:07 +0300 Subject: [PATCH] staging: octeon-ethernet: consolidate carrier notifications Always use cvm_oct_note_carrier() to avoid copy-pasted code. Signed-off-by: Aaro Koskinen Signed-off-by: Greg Kroah-Hartman --- drivers/staging/octeon/ethernet-mdio.c | 5 ++--- drivers/staging/octeon/ethernet-rgmii.c | 19 +++---------------- drivers/staging/octeon/ethernet-sgmii.c | 20 +++----------------- drivers/staging/octeon/ethernet-xaui.c | 20 +++----------------- drivers/staging/octeon/octeon-ethernet.h | 4 ++++ 5 files changed, 15 insertions(+), 53 deletions(-) diff --git a/drivers/staging/octeon/ethernet-mdio.c b/drivers/staging/octeon/ethernet-mdio.c index 604fb581f1c3..6322d0dd4238 100644 --- a/drivers/staging/octeon/ethernet-mdio.c +++ b/drivers/staging/octeon/ethernet-mdio.c @@ -39,7 +39,6 @@ #include "ethernet-mdio.h" #include "ethernet-util.h" -#include #include #include @@ -116,8 +115,8 @@ int cvm_oct_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) return phy_mii_ioctl(priv->phydev, rq, cmd); } -static void cvm_oct_note_carrier(struct octeon_ethernet *priv, - cvmx_helper_link_info_t li) +void cvm_oct_note_carrier(struct octeon_ethernet *priv, + cvmx_helper_link_info_t li) { if (li.s.link_up) { pr_notice_ratelimited("%s: %u Mbps %s duplex, port %d, queue %d\n", diff --git a/drivers/staging/octeon/ethernet-rgmii.c b/drivers/staging/octeon/ethernet-rgmii.c index a6b853118bc5..65edfbf251c4 100644 --- a/drivers/staging/octeon/ethernet-rgmii.c +++ b/drivers/staging/octeon/ethernet-rgmii.c @@ -176,23 +176,10 @@ static void cvm_oct_rgmii_poll(struct net_device *dev) if (link_info.s.link_up) { if (!netif_carrier_ok(dev)) netif_carrier_on(dev); - if (priv->queue != -1) - printk_ratelimited("%s: %u Mbps %s duplex, port %2d, queue %2d\n", - dev->name, link_info.s.speed, - (link_info.s.full_duplex) ? - "Full" : "Half", - priv->port, priv->queue); - else - printk_ratelimited("%s: %u Mbps %s duplex, port %2d, POW\n", - dev->name, link_info.s.speed, - (link_info.s.full_duplex) ? - "Full" : "Half", - priv->port); - } else { - if (netif_carrier_ok(dev)) - netif_carrier_off(dev); - printk_ratelimited("%s: Link down\n", dev->name); + } else if (netif_carrier_ok(dev)) { + netif_carrier_off(dev); } + cvm_oct_note_carrier(priv, link_info); } } diff --git a/drivers/staging/octeon/ethernet-sgmii.c b/drivers/staging/octeon/ethernet-sgmii.c index 1158eacc57bb..9a747f94d48c 100644 --- a/drivers/staging/octeon/ethernet-sgmii.c +++ b/drivers/staging/octeon/ethernet-sgmii.c @@ -55,26 +55,12 @@ static void cvm_oct_sgmii_poll(struct net_device *dev) /* Tell Linux */ if (link_info.s.link_up) { - if (!netif_carrier_ok(dev)) netif_carrier_on(dev); - if (priv->queue != -1) - printk_ratelimited - ("%s: %u Mbps %s duplex, port %2d, queue %2d\n", - dev->name, link_info.s.speed, - (link_info.s.full_duplex) ? "Full" : "Half", - priv->port, priv->queue); - else - printk_ratelimited - ("%s: %u Mbps %s duplex, port %2d, POW\n", - dev->name, link_info.s.speed, - (link_info.s.full_duplex) ? "Full" : "Half", - priv->port); - } else { - if (netif_carrier_ok(dev)) - netif_carrier_off(dev); - printk_ratelimited("%s: Link down\n", dev->name); + } 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) diff --git a/drivers/staging/octeon/ethernet-xaui.c b/drivers/staging/octeon/ethernet-xaui.c index 3714fae201d4..888b70b93a7b 100644 --- a/drivers/staging/octeon/ethernet-xaui.c +++ b/drivers/staging/octeon/ethernet-xaui.c @@ -55,26 +55,12 @@ static void cvm_oct_xaui_poll(struct net_device *dev) /* Tell Linux */ if (link_info.s.link_up) { - if (!netif_carrier_ok(dev)) netif_carrier_on(dev); - if (priv->queue != -1) - printk_ratelimited - ("%s: %u Mbps %s duplex, port %2d, queue %2d\n", - dev->name, link_info.s.speed, - (link_info.s.full_duplex) ? "Full" : "Half", - priv->port, priv->queue); - else - printk_ratelimited - ("%s: %u Mbps %s duplex, port %2d, POW\n", - dev->name, link_info.s.speed, - (link_info.s.full_duplex) ? "Full" : "Half", - priv->port); - } else { - if (netif_carrier_ok(dev)) - netif_carrier_off(dev); - printk_ratelimited("%s: Link down\n", dev->name); + } 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) diff --git a/drivers/staging/octeon/octeon-ethernet.h b/drivers/staging/octeon/octeon-ethernet.h index 3ad713fb4725..1e77f1d23c74 100644 --- a/drivers/staging/octeon/octeon-ethernet.h +++ b/drivers/staging/octeon/octeon-ethernet.h @@ -33,6 +33,8 @@ #include +#include + /** * This is the definition of the Ethernet driver's private * driver state stored in netdev_priv(dev). @@ -86,6 +88,8 @@ void cvm_oct_adjust_link(struct net_device *dev); int cvm_oct_common_stop(struct net_device *dev); 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); extern int always_use_pow; extern int pow_send_group; -- 2.30.2