diff options
Diffstat (limited to 'net/netrom/af_netrom.c')
-rw-r--r-- | net/netrom/af_netrom.c | 103 |
1 files changed, 18 insertions, 85 deletions
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index cd1dca1f0df7..be99fc7679a2 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c @@ -44,8 +44,6 @@ #include <net/arp.h> #include <linux/init.h> -static int nr_ndevs = 4; - int sysctl_netrom_default_path_quality = NR_DEFAULT_QUAL; int sysctl_netrom_obsolescence_count_initialiser = NR_DEFAULT_OBS; int sysctl_netrom_network_ttl_initialiser = NR_DEFAULT_TTL; @@ -67,28 +65,6 @@ static DEFINE_SPINLOCK(nr_list_lock); static const struct proto_ops nr_proto_ops; /* - * NETROM network devices are virtual network devices encapsulating NETROM - * frames into AX.25 which will be sent through an AX.25 device, so form a - * special "super class" of normal net devices; split their locks off into a - * separate class since they always nest. - */ -static struct lock_class_key nr_netdev_xmit_lock_key; -static struct lock_class_key nr_netdev_addr_lock_key; - -static void nr_set_lockdep_one(struct net_device *dev, - struct netdev_queue *txq, - void *_unused) -{ - lockdep_set_class(&txq->_xmit_lock, &nr_netdev_xmit_lock_key); -} - -static void nr_set_lockdep_key(struct net_device *dev) -{ - lockdep_set_class(&dev->addr_list_lock, &nr_netdev_addr_lock_key); - netdev_for_each_tx_queue(dev, nr_set_lockdep_one, NULL); -} - -/* * Socket removal during an interrupt is now safe. */ static void nr_remove_socket(struct sock *sk) @@ -1376,8 +1352,6 @@ static struct notifier_block nr_dev_notifier = { .notifier_call = nr_device_event, }; -static struct net_device **dev_nr; - static struct ax25_protocol nr_pid = { .pid = AX25_P_NETROM, .func = nr_route_frame @@ -1389,47 +1363,19 @@ static struct ax25_linkfail nr_linkfail_notifier = { static int __init nr_proto_init(void) { - int i; - int rc = proto_register(&nr_proto, 0); + int err; - if (rc != 0) + err = proto_register(&nr_proto, 0); + if (err) goto out; - if (nr_ndevs > 0x7fffffff/sizeof(struct net_device *)) { - printk(KERN_ERR "NET/ROM: nr_proto_init - nr_ndevs parameter to large\n"); - return -1; - } - - dev_nr = kcalloc(nr_ndevs, sizeof(struct net_device *), GFP_KERNEL); - if (dev_nr == NULL) { - printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device array\n"); - return -1; - } - - for (i = 0; i < nr_ndevs; i++) { - char name[IFNAMSIZ]; - struct net_device *dev; - - sprintf(name, "nr%d", i); - dev = alloc_netdev(0, name, NET_NAME_UNKNOWN, nr_setup); - if (!dev) { - printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device structure\n"); - goto fail; - } - - dev->base_addr = i; - if (register_netdev(dev)) { - printk(KERN_ERR "NET/ROM: nr_proto_init - unable to register network device\n"); - free_netdev(dev); - goto fail; - } - nr_set_lockdep_key(dev); - dev_nr[i] = dev; - } + err = rtnl_link_register(&nr_link_ops); + if (err) + goto out_unregister_proto; if (sock_register(&nr_family_ops)) { printk(KERN_ERR "NET/ROM: nr_proto_init - unable to register socket family\n"); - goto fail; + goto out_rtnl_link_unregister; } register_netdevice_notifier(&nr_dev_notifier); @@ -1446,23 +1392,21 @@ static int __init nr_proto_init(void) proc_create_seq("nr", 0444, init_net.proc_net, &nr_info_seqops); proc_create_seq("nr_neigh", 0444, init_net.proc_net, &nr_neigh_seqops); proc_create_seq("nr_nodes", 0444, init_net.proc_net, &nr_node_seqops); -out: - return rc; -fail: - while (--i >= 0) { - unregister_netdev(dev_nr[i]); - free_netdev(dev_nr[i]); - } - kfree(dev_nr); + + return 0; + +out_rtnl_link_unregister: + rtnl_link_unregister(&nr_link_ops); + +out_unregister_proto: proto_unregister(&nr_proto); - rc = -1; - goto out; + +out: + return err; } static void __exit nr_exit(void) { - int i; - remove_proc_entry("nr", init_net.proc_net); remove_proc_entry("nr_neigh", init_net.proc_net); remove_proc_entry("nr_nodes", init_net.proc_net); @@ -1481,24 +1425,13 @@ static void __exit nr_exit(void) sock_unregister(PF_NETROM); - for (i = 0; i < nr_ndevs; i++) { - struct net_device *dev = dev_nr[i]; - if (dev) { - unregister_netdev(dev); - free_netdev(dev); - } - } - - kfree(dev_nr); + rtnl_link_unregister(&nr_link_ops); proto_unregister(&nr_proto); } module_init(nr_proto_init); module_exit(nr_exit); -module_param(nr_ndevs, int, 0); -MODULE_PARM_DESC(nr_ndevs, "number of NET/ROM devices"); - MODULE_AUTHOR("Jonathan Naylor G4KLX <g4klx@g4klx.demon.co.uk>"); MODULE_DESCRIPTION("The amateur radio NET/ROM network and transport layer protocol"); MODULE_LICENSE("GPL"); |