25 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
27 #include <linux/errno.h>
28 #include <linux/hdlc.h>
29 #include <linux/if_arp.h>
32 #include <linux/kernel.h>
33 #include <linux/module.h>
36 #include <linux/poll.h>
37 #include <linux/rtnetlink.h>
39 #include <linux/slab.h>
43 static const char*
version =
"HDLC support module revision 1.22";
62 if (!net_eq(dev_net(dev), &
init_net)) {
68 return hdlc->
proto->netif_rx(skb);
75 if (hdlc->
proto->xmit)
76 return hdlc->
proto->xmit(skb, dev);
78 return hdlc->
xmit(skb, dev);
81 static inline void hdlc_proto_start(
struct net_device *dev)
84 if (hdlc->
proto->start)
85 hdlc->
proto->start(dev);
90 static inline void hdlc_proto_stop(
struct net_device *dev)
93 if (hdlc->
proto->stop)
94 hdlc->
proto->stop(dev);
107 if (!net_eq(dev_net(dev), &
init_net))
116 on = netif_carrier_ok(dev);
123 hdlc = dev_to_hdlc(dev);
135 netdev_info(dev,
"Carrier detected\n");
136 hdlc_proto_start(dev);
138 netdev_info(dev,
"Carrier lost\n");
139 hdlc_proto_stop(dev);
143 spin_unlock_irqrestore(&hdlc->
state_lock, flags);
161 if (hdlc->
proto->open) {
170 netdev_info(dev,
"Carrier detected\n");
171 hdlc_proto_start(dev);
173 netdev_info(dev,
"No carrier\n");
196 hdlc_proto_stop(dev);
200 if (hdlc->
proto->close)
201 hdlc->
proto->close(dev);
214 if (dev_to_hdlc(dev)->proto) {
215 result = dev_to_hdlc(dev)->proto->ioctl(dev, ifr);
232 static void hdlc_setup_dev(
struct net_device *dev)
246 static void hdlc_setup(
struct net_device *dev)
261 dev_to_hdlc(dev)->priv =
priv;
268 unregister_netdevice(dev);
280 if (!try_module_get(proto->
module))
287 "Memory squeeze on hdlc_proto_attach()\n");
288 module_put(proto->
module);
291 dev_to_hdlc(dev)->proto =
proto;
301 if (hdlc->
proto->detach)
302 hdlc->
proto->detach(dev);
303 module_put(hdlc->
proto->module);
315 proto->
next = first_proto;
327 while (*p != proto) {
360 .notifier_call = hdlc_device_event,
364 static int __init hdlc_module_init(
void)
377 static void __exit hdlc_module_exit(
void)