]>
Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /********************************************************************* |
6819bc2e | 2 | * |
1da177e4 LT |
3 | * Filename: irmod.c |
4 | * Version: 0.9 | |
5 | * Description: IrDA stack main entry points | |
6 | * Status: Experimental. | |
7 | * Author: Dag Brattli <[email protected]> | |
8 | * Created at: Mon Dec 15 13:55:39 1997 | |
9 | * Modified at: Wed Jan 5 15:12:41 2000 | |
10 | * Modified by: Dag Brattli <[email protected]> | |
6819bc2e | 11 | * |
1da177e4 LT |
12 | * Copyright (c) 1997, 1999-2000 Dag Brattli, All Rights Reserved. |
13 | * Copyright (c) 2000-2004 Jean Tourrilhes <[email protected]> | |
6819bc2e YH |
14 | * |
15 | * This program is free software; you can redistribute it and/or | |
16 | * modify it under the terms of the GNU General Public License as | |
17 | * published by the Free Software Foundation; either version 2 of | |
1da177e4 | 18 | * the License, or (at your option) any later version. |
6819bc2e | 19 | * |
96de0e25 | 20 | * Neither Dag Brattli nor University of Tromsø admit liability nor |
6819bc2e | 21 | * provide warranty for any of this software. This material is |
1da177e4 | 22 | * provided "AS-IS" and at no charge. |
6819bc2e | 23 | * |
1da177e4 LT |
24 | ********************************************************************/ |
25 | ||
26 | /* | |
27 | * This file contains the main entry points of the IrDA stack. | |
28 | * They are in this file and not af_irda.c because some developpers | |
29 | * are using the IrDA stack without the socket API (compiling out | |
30 | * af_irda.c). | |
31 | * Jean II | |
32 | */ | |
33 | ||
1da177e4 LT |
34 | #include <linux/module.h> |
35 | #include <linux/moduleparam.h> | |
36 | ||
37 | #include <net/irda/irda.h> | |
38 | #include <net/irda/irmod.h> /* notify_t */ | |
39 | #include <net/irda/irlap.h> /* irlap_init */ | |
40 | #include <net/irda/irlmp.h> /* irlmp_init */ | |
41 | #include <net/irda/iriap.h> /* iriap_init */ | |
42 | #include <net/irda/irttp.h> /* irttp_init */ | |
43 | #include <net/irda/irda_device.h> /* irda_device_init */ | |
44 | ||
1da177e4 LT |
45 | /* |
46 | * Module parameters | |
47 | */ | |
48 | #ifdef CONFIG_IRDA_DEBUG | |
49 | unsigned int irda_debug = IRDA_DEBUG_LEVEL; | |
50 | module_param_named(debug, irda_debug, uint, 0); | |
51 | MODULE_PARM_DESC(debug, "IRDA debugging level"); | |
52 | EXPORT_SYMBOL(irda_debug); | |
53 | #endif | |
54 | ||
55 | /* Packet type handler. | |
56 | * Tell the kernel how IrDA packets should be handled. | |
57 | */ | |
7546dd97 | 58 | static struct packet_type irda_packet_type __read_mostly = { |
09640e63 | 59 | .type = cpu_to_be16(ETH_P_IRDA), |
1da177e4 LT |
60 | .func = irlap_driver_rcv, /* Packet type handler irlap_frame.c */ |
61 | }; | |
62 | ||
63 | /* | |
64 | * Function irda_notify_init (notify) | |
65 | * | |
66 | * Used for initializing the notify structure | |
67 | * | |
68 | */ | |
69 | void irda_notify_init(notify_t *notify) | |
70 | { | |
71 | notify->data_indication = NULL; | |
72 | notify->udata_indication = NULL; | |
73 | notify->connect_confirm = NULL; | |
74 | notify->connect_indication = NULL; | |
75 | notify->disconnect_indication = NULL; | |
76 | notify->flow_indication = NULL; | |
77 | notify->status_indication = NULL; | |
78 | notify->instance = NULL; | |
79 | strlcpy(notify->name, "Unknown", sizeof(notify->name)); | |
80 | } | |
81 | EXPORT_SYMBOL(irda_notify_init); | |
82 | ||
83 | /* | |
84 | * Function irda_init (void) | |
85 | * | |
86 | * Protocol stack initialisation entry point. | |
87 | * Initialise the various components of the IrDA stack | |
88 | */ | |
89 | static int __init irda_init(void) | |
90 | { | |
89da1ecf SO |
91 | int ret = 0; |
92 | ||
0dc47877 | 93 | IRDA_DEBUG(0, "%s()\n", __func__); |
1da177e4 LT |
94 | |
95 | /* Lower layer of the stack */ | |
6819bc2e | 96 | irlmp_init(); |
1da177e4 | 97 | irlap_init(); |
6819bc2e | 98 | |
89da1ecf SO |
99 | /* Driver/dongle support */ |
100 | irda_device_init(); | |
101 | ||
1da177e4 LT |
102 | /* Higher layers of the stack */ |
103 | iriap_init(); | |
6819bc2e | 104 | irttp_init(); |
89da1ecf SO |
105 | ret = irsock_init(); |
106 | if (ret < 0) | |
107 | goto out_err_1; | |
6819bc2e | 108 | |
1da177e4 | 109 | /* Add IrDA packet type (Start receiving packets) */ |
6819bc2e | 110 | dev_add_pack(&irda_packet_type); |
1da177e4 LT |
111 | |
112 | /* External APIs */ | |
113 | #ifdef CONFIG_PROC_FS | |
114 | irda_proc_register(); | |
115 | #endif | |
116 | #ifdef CONFIG_SYSCTL | |
89da1ecf SO |
117 | ret = irda_sysctl_register(); |
118 | if (ret < 0) | |
119 | goto out_err_2; | |
1da177e4 LT |
120 | #endif |
121 | ||
89da1ecf SO |
122 | ret = irda_nl_register(); |
123 | if (ret < 0) | |
124 | goto out_err_3; | |
1da177e4 LT |
125 | |
126 | return 0; | |
89da1ecf SO |
127 | |
128 | out_err_3: | |
129 | #ifdef CONFIG_SYSCTL | |
130 | irda_sysctl_unregister(); | |
89da1ecf | 131 | out_err_2: |
2c20d72a | 132 | #endif |
89da1ecf SO |
133 | #ifdef CONFIG_PROC_FS |
134 | irda_proc_unregister(); | |
135 | #endif | |
136 | ||
137 | /* Remove IrDA packet type (stop receiving packets) */ | |
138 | dev_remove_pack(&irda_packet_type); | |
139 | ||
140 | /* Remove higher layers */ | |
141 | irsock_cleanup(); | |
142 | out_err_1: | |
143 | irttp_cleanup(); | |
144 | iriap_cleanup(); | |
145 | ||
146 | /* Remove lower layers */ | |
147 | irda_device_cleanup(); | |
148 | irlap_cleanup(); /* Must be done before irlmp_cleanup()! DB */ | |
149 | ||
150 | /* Remove middle layer */ | |
151 | irlmp_cleanup(); | |
152 | ||
153 | ||
154 | return ret; | |
1da177e4 LT |
155 | } |
156 | ||
157 | /* | |
158 | * Function irda_cleanup (void) | |
159 | * | |
160 | * Protocol stack cleanup/removal entry point. | |
161 | * Cleanup the various components of the IrDA stack | |
162 | */ | |
163 | static void __exit irda_cleanup(void) | |
164 | { | |
165 | /* Remove External APIs */ | |
89da1ecf SO |
166 | irda_nl_unregister(); |
167 | ||
1da177e4 LT |
168 | #ifdef CONFIG_SYSCTL |
169 | irda_sysctl_unregister(); | |
6819bc2e | 170 | #endif |
1da177e4 LT |
171 | #ifdef CONFIG_PROC_FS |
172 | irda_proc_unregister(); | |
173 | #endif | |
174 | ||
175 | /* Remove IrDA packet type (stop receiving packets) */ | |
6819bc2e YH |
176 | dev_remove_pack(&irda_packet_type); |
177 | ||
1da177e4 LT |
178 | /* Remove higher layers */ |
179 | irsock_cleanup(); | |
180 | irttp_cleanup(); | |
181 | iriap_cleanup(); | |
182 | ||
183 | /* Remove lower layers */ | |
184 | irda_device_cleanup(); | |
185 | irlap_cleanup(); /* Must be done before irlmp_cleanup()! DB */ | |
186 | ||
187 | /* Remove middle layer */ | |
188 | irlmp_cleanup(); | |
189 | } | |
190 | ||
191 | /* | |
192 | * The IrDA stack must be initialised *before* drivers get initialised, | |
193 | * and *before* higher protocols (IrLAN/IrCOMM/IrNET) get initialised, | |
194 | * otherwise bad things will happen (hashbins will be NULL for example). | |
195 | * Those modules are at module_init()/device_initcall() level. | |
196 | * | |
197 | * On the other hand, it needs to be initialised *after* the basic | |
198 | * networking, the /proc/net filesystem and sysctl module. Those are | |
199 | * currently initialised in .../init/main.c (before initcalls). | |
200 | * Also, IrDA drivers needs to be initialised *after* the random number | |
201 | * generator (main stack and higher layer init don't need it anymore). | |
202 | * | |
203 | * Jean II | |
204 | */ | |
205 | subsys_initcall(irda_init); | |
206 | module_exit(irda_cleanup); | |
6819bc2e | 207 | |
1da177e4 | 208 | MODULE_AUTHOR("Dag Brattli <[email protected]> & Jean Tourrilhes <[email protected]>"); |
6819bc2e | 209 | MODULE_DESCRIPTION("The Linux IrDA Protocol Stack"); |
1da177e4 LT |
210 | MODULE_LICENSE("GPL"); |
211 | MODULE_ALIAS_NETPROTO(PF_IRDA); |