WAN: HDLC: Call notifiers before and after changing device type
[deliverable/linux.git] / drivers / net / wan / hdlc.c
index 2a6595b4ae15896bf55e212f8946f50b45251147..9bd4aa8083ce787cc93ed5cfe416175b8f2b7d24 100644 (file)
@@ -276,7 +276,11 @@ void unregister_hdlc_device(struct net_device *dev)
 int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto,
                         size_t size)
 {
-       detach_hdlc_protocol(dev);
+       int err;
+
+       err = detach_hdlc_protocol(dev);
+       if (err)
+               return err;
 
        if (!try_module_get(proto->module))
                return -ENOSYS;
@@ -289,15 +293,24 @@ int attach_hdlc_protocol(struct net_device *dev, struct hdlc_proto *proto,
                }
        }
        dev_to_hdlc(dev)->proto = proto;
+
        return 0;
 }
 
 
-void detach_hdlc_protocol(struct net_device *dev)
+int detach_hdlc_protocol(struct net_device *dev)
 {
        hdlc_device *hdlc = dev_to_hdlc(dev);
+       int err;
 
        if (hdlc->proto) {
+               err = call_netdevice_notifiers(NETDEV_PRE_TYPE_CHANGE, dev);
+               err = notifier_to_errno(err);
+               if (err) {
+                       netdev_err(dev, "Refused to change device type\n");
+                       return err;
+               }
+
                if (hdlc->proto->detach)
                        hdlc->proto->detach(dev);
                module_put(hdlc->proto->module);
@@ -306,6 +319,8 @@ void detach_hdlc_protocol(struct net_device *dev)
        kfree(hdlc->state);
        hdlc->state = NULL;
        hdlc_setup_dev(dev);
+
+       return 0;
 }
 
 
This page took 0.04148 seconds and 5 git commands to generate.