summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBibhay Ranjan <bibhayr@nvidia.com>2014-03-18 13:54:54 +0530
committerMandar Padmawar <mpadmawar@nvidia.com>2014-06-25 00:49:20 -0700
commit3c1272799248f9e9e1660b9eaefd2c3789274647 (patch)
tree3cb521c600127bf69ae384bc0ef9e79b754e6995
parentf0490609a8495770d329b6b84fc446436bedf338 (diff)
staging: ozwpan: add net device notifier
add notifier function to remove p2p netdevice binding on NETDEV_DOWN or NETDEV_UNREGISTER events Bug 1478118 Bug 1470921 Change-Id: I6a18c65ee45affeaa6f459b656888c1c52d2fd3b Reviewed-on: http://git-master/r/368141 (cherry picked from commit 28d61853e7f35e80ba11784eceb83acd1a870fac) Reviewed-on: http://git-master/r/383615 (cherry picked from commit c67c144624703bc7d927c6822c24ecbc9a6b04f9) Signed-off-by: Jean Huang <jeanh@nvidia.com> Reviewed-on: http://git-master/r/427951 GVS: Gerrit_Virtual_Submit
-rw-r--r--drivers/staging/ozwpan/ozproto.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/staging/ozwpan/ozproto.c b/drivers/staging/ozwpan/ozproto.c
index 8cb25b285c6a..1066c4e49ad7 100644
--- a/drivers/staging/ozwpan/ozproto.c
+++ b/drivers/staging/ozwpan/ozproto.c
@@ -445,6 +445,26 @@ done:
oz_pd_put(pd);
consume_skb(skb);
}
+
+static int oz_net_notifier(struct notifier_block *nb, unsigned long event,
+ void *ndev)
+{
+ struct net_device *dev = ndev;
+ switch (event) {
+ case NETDEV_UNREGISTER:
+ case NETDEV_DOWN:
+ oz_trace_msg(M, "%s: event %s\n", __func__,
+ (event == NETDEV_UNREGISTER) ?
+ "NETDEV_UNREGISTER" : "NETDEV_DOWN");
+ oz_binding_remove(dev->name);
+ break;
+ }
+ return NOTIFY_OK;
+}
+
+static struct notifier_block nb_oz_net_notifier = {
+ .notifier_call = oz_net_notifier
+};
/*------------------------------------------------------------------------------
* Context: process
*/
@@ -482,6 +502,7 @@ void oz_protocol_term(void)
spin_lock_bh(&g_polling_lock);
}
spin_unlock_bh(&g_polling_lock);
+ unregister_netdevice_notifier(&nb_oz_net_notifier);
oz_trace("Protocol stopped\n");
}
/*------------------------------------------------------------------------------
@@ -813,6 +834,12 @@ int oz_protocol_init(char *devs)
return -1;
} else {
char d[32];
+ int err = 0;
+ err = register_netdevice_notifier(&nb_oz_net_notifier);
+ if (err) {
+ oz_trace("notifier registration failed. err %d\n", err);
+ return -1;
+ }
while (*devs) {
devs = oz_get_next_device_name(devs, d, sizeof(d));
if (d[0])