|
@@ -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;
|
|
|
}
|
|
|
|
|
|
|