diff options
author | Patrick McHardy <kaber@trash.net> | 2008-01-21 03:25:15 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-28 18:08:30 -0500 |
commit | 69ab4b7d6db68396dbfa827daa8d6f30f9b546a8 (patch) | |
tree | 5c87d44dc524774f553f8214dad13194fef89958 /net/8021q/vlan.c | |
parent | 198a291ce3a9103f4738600e3cf5416b66e009d9 (diff) |
[VLAN]: Clean up initialization code
- move module init/exit functions to end of file, remove some now unnecessary
forward declarations
- remove some obvious comments
- clean up proc init function and move a proc-related printk there
Signed-off-by: Patrick McHardy <kaber@trash.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/8021q/vlan.c')
-rw-r--r-- | net/8021q/vlan.c | 141 |
1 files changed, 58 insertions, 83 deletions
diff --git a/net/8021q/vlan.c b/net/8021q/vlan.c index 69a9e0207b13..006d9a9bac90 100644 --- a/net/8021q/vlan.c +++ b/net/8021q/vlan.c | |||
@@ -50,16 +50,6 @@ static char vlan_version[] = DRV_VERSION; | |||
50 | static char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>"; | 50 | static char vlan_copyright[] = "Ben Greear <greearb@candelatech.com>"; |
51 | static char vlan_buggyright[] = "David S. Miller <davem@redhat.com>"; | 51 | static char vlan_buggyright[] = "David S. Miller <davem@redhat.com>"; |
52 | 52 | ||
53 | static int vlan_device_event(struct notifier_block *, unsigned long, void *); | ||
54 | static int vlan_ioctl_handler(struct net *net, void __user *); | ||
55 | static int unregister_vlan_dev(struct net_device *, unsigned short ); | ||
56 | |||
57 | static struct notifier_block vlan_notifier_block = { | ||
58 | .notifier_call = vlan_device_event, | ||
59 | }; | ||
60 | |||
61 | /* These may be changed at run-time through IOCTLs */ | ||
62 | |||
63 | /* Determines interface naming scheme. */ | 53 | /* Determines interface naming scheme. */ |
64 | unsigned short vlan_name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD; | 54 | unsigned short vlan_name_type = VLAN_NAME_TYPE_RAW_PLUS_VID_NO_PAD; |
65 | 55 | ||
@@ -70,79 +60,6 @@ static struct packet_type vlan_packet_type = { | |||
70 | 60 | ||
71 | /* End of global variables definitions. */ | 61 | /* End of global variables definitions. */ |
72 | 62 | ||
73 | /* | ||
74 | * Function vlan_proto_init (pro) | ||
75 | * | ||
76 | * Initialize VLAN protocol layer, | ||
77 | * | ||
78 | */ | ||
79 | static int __init vlan_proto_init(void) | ||
80 | { | ||
81 | int err; | ||
82 | |||
83 | pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright); | ||
84 | pr_info("All bugs added by %s\n", vlan_buggyright); | ||
85 | |||
86 | /* proc file system initialization */ | ||
87 | err = vlan_proc_init(); | ||
88 | if (err < 0) { | ||
89 | pr_err("%s: can't create entry in proc filesystem!\n", | ||
90 | __FUNCTION__); | ||
91 | return err; | ||
92 | } | ||
93 | |||
94 | dev_add_pack(&vlan_packet_type); | ||
95 | |||
96 | /* Register us to receive netdevice events */ | ||
97 | err = register_netdevice_notifier(&vlan_notifier_block); | ||
98 | if (err < 0) | ||
99 | goto err1; | ||
100 | |||
101 | err = vlan_netlink_init(); | ||
102 | if (err < 0) | ||
103 | goto err2; | ||
104 | |||
105 | vlan_ioctl_set(vlan_ioctl_handler); | ||
106 | return 0; | ||
107 | |||
108 | err2: | ||
109 | unregister_netdevice_notifier(&vlan_notifier_block); | ||
110 | err1: | ||
111 | vlan_proc_cleanup(); | ||
112 | dev_remove_pack(&vlan_packet_type); | ||
113 | return err; | ||
114 | } | ||
115 | |||
116 | /* | ||
117 | * Module 'remove' entry point. | ||
118 | * o delete /proc/net/router directory and static entries. | ||
119 | */ | ||
120 | static void __exit vlan_cleanup_module(void) | ||
121 | { | ||
122 | int i; | ||
123 | |||
124 | vlan_ioctl_set(NULL); | ||
125 | vlan_netlink_fini(); | ||
126 | |||
127 | /* Un-register us from receiving netdevice events */ | ||
128 | unregister_netdevice_notifier(&vlan_notifier_block); | ||
129 | |||
130 | dev_remove_pack(&vlan_packet_type); | ||
131 | |||
132 | /* This table must be empty if there are no module | ||
133 | * references left. | ||
134 | */ | ||
135 | for (i = 0; i < VLAN_GRP_HASH_SIZE; i++) { | ||
136 | BUG_ON(!hlist_empty(&vlan_group_hash[i])); | ||
137 | } | ||
138 | vlan_proc_cleanup(); | ||
139 | |||
140 | synchronize_net(); | ||
141 | } | ||
142 | |||
143 | module_init(vlan_proto_init); | ||
144 | module_exit(vlan_cleanup_module); | ||
145 | |||
146 | /* Must be invoked with RCU read lock (no preempt) */ | 63 | /* Must be invoked with RCU read lock (no preempt) */ |
147 | static struct vlan_group *__vlan_find_group(int real_dev_ifindex) | 64 | static struct vlan_group *__vlan_find_group(int real_dev_ifindex) |
148 | { | 65 | { |
@@ -592,6 +509,10 @@ out: | |||
592 | return NOTIFY_DONE; | 509 | return NOTIFY_DONE; |
593 | } | 510 | } |
594 | 511 | ||
512 | static struct notifier_block vlan_notifier_block __read_mostly = { | ||
513 | .notifier_call = vlan_device_event, | ||
514 | }; | ||
515 | |||
595 | /* | 516 | /* |
596 | * VLAN IOCTL handler. | 517 | * VLAN IOCTL handler. |
597 | * o execute requested action or pass command to the device driver | 518 | * o execute requested action or pass command to the device driver |
@@ -716,5 +637,59 @@ out: | |||
716 | return err; | 637 | return err; |
717 | } | 638 | } |
718 | 639 | ||
640 | static int __init vlan_proto_init(void) | ||
641 | { | ||
642 | int err; | ||
643 | |||
644 | pr_info("%s v%s %s\n", vlan_fullname, vlan_version, vlan_copyright); | ||
645 | pr_info("All bugs added by %s\n", vlan_buggyright); | ||
646 | |||
647 | err = vlan_proc_init(); | ||
648 | if (err < 0) | ||
649 | goto err1; | ||
650 | |||
651 | err = register_netdevice_notifier(&vlan_notifier_block); | ||
652 | if (err < 0) | ||
653 | goto err2; | ||
654 | |||
655 | err = vlan_netlink_init(); | ||
656 | if (err < 0) | ||
657 | goto err3; | ||
658 | |||
659 | dev_add_pack(&vlan_packet_type); | ||
660 | vlan_ioctl_set(vlan_ioctl_handler); | ||
661 | return 0; | ||
662 | |||
663 | err3: | ||
664 | unregister_netdevice_notifier(&vlan_notifier_block); | ||
665 | err2: | ||
666 | vlan_proc_cleanup(); | ||
667 | err1: | ||
668 | return err; | ||
669 | } | ||
670 | |||
671 | static void __exit vlan_cleanup_module(void) | ||
672 | { | ||
673 | unsigned int i; | ||
674 | |||
675 | vlan_ioctl_set(NULL); | ||
676 | vlan_netlink_fini(); | ||
677 | |||
678 | unregister_netdevice_notifier(&vlan_notifier_block); | ||
679 | |||
680 | dev_remove_pack(&vlan_packet_type); | ||
681 | |||
682 | /* This table must be empty if there are no module references left. */ | ||
683 | for (i = 0; i < VLAN_GRP_HASH_SIZE; i++) | ||
684 | BUG_ON(!hlist_empty(&vlan_group_hash[i])); | ||
685 | |||
686 | vlan_proc_cleanup(); | ||
687 | |||
688 | synchronize_net(); | ||
689 | } | ||
690 | |||
691 | module_init(vlan_proto_init); | ||
692 | module_exit(vlan_cleanup_module); | ||
693 | |||
719 | MODULE_LICENSE("GPL"); | 694 | MODULE_LICENSE("GPL"); |
720 | MODULE_VERSION(DRV_VERSION); | 695 | MODULE_VERSION(DRV_VERSION); |