summaryrefslogtreecommitdiff
path: root/net/hsr/hsr_device.c
diff options
context:
space:
mode:
authorArvid Brodin <arvid.brodin@alten.se>2014-07-04 23:36:40 +0200
committerDavid S. Miller <davem@davemloft.net>2014-07-08 11:35:30 -0700
commite9aae56ea43ef4a32527b9d86c1f6b5eebfbd223 (patch)
tree9d98af0ddd4feed4266745d7a2b5fcc45445e65c /net/hsr/hsr_device.c
parentabff7162765cd66ab109c97fd433ef1f39299120 (diff)
net/hsr: Operstate handling cleanup.
Signed-off-by: Arvid Brodin <arvid.brodin@alten.se> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/hsr/hsr_device.c')
-rw-r--r--net/hsr/hsr_device.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/net/hsr/hsr_device.c b/net/hsr/hsr_device.c
index f224067153e4..8936b3c2bb84 100644
--- a/net/hsr/hsr_device.c
+++ b/net/hsr/hsr_device.c
@@ -46,31 +46,36 @@ static void __hsr_set_operstate(struct net_device *dev, int transition)
}
}
-void hsr_set_operstate(struct net_device *hsr_dev, struct net_device *slave1,
- struct net_device *slave2)
+static void hsr_set_operstate(struct net_device *hsr_dev, bool has_carrier)
{
if (!is_admin_up(hsr_dev)) {
__hsr_set_operstate(hsr_dev, IF_OPER_DOWN);
return;
}
- if (is_slave_up(slave1) || is_slave_up(slave2))
+ if (has_carrier)
__hsr_set_operstate(hsr_dev, IF_OPER_UP);
else
__hsr_set_operstate(hsr_dev, IF_OPER_LOWERLAYERDOWN);
}
-void hsr_set_carrier(struct net_device *hsr_dev, struct net_device *slave1,
- struct net_device *slave2)
+static bool hsr_check_carrier(struct hsr_priv *hsr)
{
- if (is_slave_up(slave1) || is_slave_up(slave2))
- netif_carrier_on(hsr_dev);
+ bool has_carrier;
+
+ has_carrier = (is_slave_up(hsr->slave[0]) || is_slave_up(hsr->slave[1]));
+
+ if (has_carrier)
+ netif_carrier_on(hsr->dev);
else
- netif_carrier_off(hsr_dev);
+ netif_carrier_off(hsr->dev);
+
+ return has_carrier;
}
-void hsr_check_announce(struct net_device *hsr_dev, int old_operstate)
+static void hsr_check_announce(struct net_device *hsr_dev,
+ unsigned char old_operstate)
{
struct hsr_priv *hsr;
@@ -89,6 +94,20 @@ void hsr_check_announce(struct net_device *hsr_dev, int old_operstate)
del_timer(&hsr->announce_timer);
}
+void hsr_check_carrier_and_operstate(struct hsr_priv *hsr)
+{
+ unsigned char old_operstate;
+ bool has_carrier;
+
+ /* netif_stacked_transfer_operstate() cannot be used here since
+ * it doesn't set IF_OPER_LOWERLAYERDOWN (?)
+ */
+ old_operstate = hsr->dev->operstate;
+ has_carrier = hsr_check_carrier(hsr);
+ hsr_set_operstate(hsr->dev, has_carrier);
+ hsr_check_announce(hsr->dev, old_operstate);
+}
+
int hsr_get_max_mtu(struct hsr_priv *hsr)
{