1 /*********************************************************************
5 * Description: IrDA stack main entry points
6 * Status: Experimental.
7 * Author: Dag Brattli <dagb@cs.uit.no>
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 <dagb@cs.uit.no>
12 * Copyright (c) 1997, 1999-2000 Dag Brattli, All Rights Reserved.
13 * Copyright (c) 2000-2004 Jean Tourrilhes <jt@hpl.hp.com>
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
18 * the License, or (at your option) any later version.
20 * Neither Dag Brattli nor University of Tromsø admit liability nor
21 * provide warranty for any of this software. This material is
22 * provided "AS-IS" and at no charge.
24 ********************************************************************/
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
34 #include <linux/module.h>
35 #include <linux/moduleparam.h>
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 */
45 /* Packet type handler.
46 * Tell the kernel how IrDA packets should be handled.
48 static struct packet_type irda_packet_type __read_mostly
= {
49 .type
= cpu_to_be16(ETH_P_IRDA
),
50 .func
= irlap_driver_rcv
, /* Packet type handler irlap_frame.c */
54 * Function irda_notify_init (notify)
56 * Used for initializing the notify structure
59 void irda_notify_init(notify_t
*notify
)
61 notify
->data_indication
= NULL
;
62 notify
->udata_indication
= NULL
;
63 notify
->connect_confirm
= NULL
;
64 notify
->connect_indication
= NULL
;
65 notify
->disconnect_indication
= NULL
;
66 notify
->flow_indication
= NULL
;
67 notify
->status_indication
= NULL
;
68 notify
->instance
= NULL
;
69 strlcpy(notify
->name
, "Unknown", sizeof(notify
->name
));
71 EXPORT_SYMBOL(irda_notify_init
);
74 * Function irda_init (void)
76 * Protocol stack initialisation entry point.
77 * Initialise the various components of the IrDA stack
79 static int __init
irda_init(void)
83 /* Lower layer of the stack */
87 /* Driver/dongle support */
90 /* Higher layers of the stack */
97 /* Add IrDA packet type (Start receiving packets) */
98 dev_add_pack(&irda_packet_type
);
101 #ifdef CONFIG_PROC_FS
102 irda_proc_register();
105 ret
= irda_sysctl_register();
110 ret
= irda_nl_register();
118 irda_sysctl_unregister();
121 #ifdef CONFIG_PROC_FS
122 irda_proc_unregister();
125 /* Remove IrDA packet type (stop receiving packets) */
126 dev_remove_pack(&irda_packet_type
);
128 /* Remove higher layers */
134 /* Remove lower layers */
135 irda_device_cleanup();
136 irlap_cleanup(); /* Must be done before irlmp_cleanup()! DB */
138 /* Remove middle layer */
146 * Function irda_cleanup (void)
148 * Protocol stack cleanup/removal entry point.
149 * Cleanup the various components of the IrDA stack
151 static void __exit
irda_cleanup(void)
153 /* Remove External APIs */
154 irda_nl_unregister();
157 irda_sysctl_unregister();
159 #ifdef CONFIG_PROC_FS
160 irda_proc_unregister();
163 /* Remove IrDA packet type (stop receiving packets) */
164 dev_remove_pack(&irda_packet_type
);
166 /* Remove higher layers */
171 /* Remove lower layers */
172 irda_device_cleanup();
173 irlap_cleanup(); /* Must be done before irlmp_cleanup()! DB */
175 /* Remove middle layer */
180 * The IrDA stack must be initialised *before* drivers get initialised,
181 * and *before* higher protocols (IrLAN/IrCOMM/IrNET) get initialised,
182 * otherwise bad things will happen (hashbins will be NULL for example).
183 * Those modules are at module_init()/device_initcall() level.
185 * On the other hand, it needs to be initialised *after* the basic
186 * networking, the /proc/net filesystem and sysctl module. Those are
187 * currently initialised in .../init/main.c (before initcalls).
188 * Also, IrDA drivers needs to be initialised *after* the random number
189 * generator (main stack and higher layer init don't need it anymore).
193 subsys_initcall(irda_init
);
194 module_exit(irda_cleanup
);
196 MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no> & Jean Tourrilhes <jt@hpl.hp.com>");
197 MODULE_DESCRIPTION("The Linux IrDA Protocol Stack");
198 MODULE_LICENSE("GPL");
199 MODULE_ALIAS_NETPROTO(PF_IRDA
);