[PATCH v1 1/5] j1939: unmap all ECUs if we put down interface

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Oleksij Rempel <o.rempel@xxxxxxxxxxxxxx>
---
 net/can/j1939/bus.c        | 11 +++++++++++
 net/can/j1939/j1939-priv.h |  1 +
 net/can/j1939/main.c       |  1 +
 3 files changed, 13 insertions(+)

diff --git a/net/can/j1939/bus.c b/net/can/j1939/bus.c
index 5b6d762f0448..171fbdb2a1a8 100644
--- a/net/can/j1939/bus.c
+++ b/net/can/j1939/bus.c
@@ -84,6 +84,17 @@ void j1939_ecu_unmap(struct j1939_ecu *ecu)
 	write_unlock_bh(&ecu->priv->lock);
 }
 
+void j1939_ecu_unmap_all(struct j1939_priv *priv)
+{
+	int i;
+
+	write_lock_bh(&priv->lock);
+	for(i = 0; i < ARRAY_SIZE(priv->ents); i++)
+		if (priv->ents[i].ecu)
+			j1939_ecu_unmap_locked(priv->ents[i].ecu);
+	write_unlock_bh(&priv->lock);
+}
+
 void j1939_ecu_timer_start(struct j1939_ecu *ecu)
 {
 	/* The ECU is held here and released in the
diff --git a/net/can/j1939/j1939-priv.h b/net/can/j1939/j1939-priv.h
index 9db9077849e7..3c0bb9d4eb5c 100644
--- a/net/can/j1939/j1939-priv.h
+++ b/net/can/j1939/j1939-priv.h
@@ -154,6 +154,7 @@ struct j1939_ecu *j1939_ecu_create_locked(struct j1939_priv *priv, name_t name);
 
 void j1939_ecu_timer_start(struct j1939_ecu *ecu);
 void j1939_ecu_timer_cancel(struct j1939_ecu *ecu);
+void j1939_ecu_unmap_all(struct j1939_priv *priv);
 
 int j1939_netdev_start(struct net *net, struct net_device *ndev);
 void j1939_netdev_stop(struct net_device *ndev);
diff --git a/net/can/j1939/main.c b/net/can/j1939/main.c
index 73d3f590adc6..29a2be9b7168 100644
--- a/net/can/j1939/main.c
+++ b/net/can/j1939/main.c
@@ -321,6 +321,7 @@ static int j1939_netdev_notify(struct notifier_block *nb,
 
 	case NETDEV_DOWN:
 		j1939_sk_netdev_event(ndev, ENETDOWN);
+		j1939_ecu_unmap_all(priv);
 		break;
 	}
 
-- 
2.19.1




[Index of Archives]     [Automotive Discussions]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [eCos]     [Asterisk Internet PBX]     [Linux API]     [CAN Bus]

  Powered by Linux