]> nv-tegra.nvidia Code Review - linux-2.6.git/blob - net/irda/irmod.c
Merge branch 'audit.b10' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/audit...
[linux-2.6.git] / net / irda / irmod.c
1 /*********************************************************************
2  *                
3  * Filename:      irmod.c
4  * Version:       0.9
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>
11  * 
12  *     Copyright (c) 1997, 1999-2000 Dag Brattli, All Rights Reserved.
13  *     Copyright (c) 2000-2004 Jean Tourrilhes <jt@hpl.hp.com>
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 
18  *     the License, or (at your option) any later version.
19  *  
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.
23  *     
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
34 #include <linux/config.h>
35 #include <linux/module.h>
36 #include <linux/moduleparam.h>
37
38 #include <net/irda/irda.h>
39 #include <net/irda/irmod.h>             /* notify_t */
40 #include <net/irda/irlap.h>             /* irlap_init */
41 #include <net/irda/irlmp.h>             /* irlmp_init */
42 #include <net/irda/iriap.h>             /* iriap_init */
43 #include <net/irda/irttp.h>             /* irttp_init */
44 #include <net/irda/irda_device.h>       /* irda_device_init */
45
46 /* irproc.c */
47 extern void irda_proc_register(void);
48 extern void irda_proc_unregister(void);
49 /* irsysctl.c */
50 extern int  irda_sysctl_register(void);
51 extern void irda_sysctl_unregister(void);
52 /* af_irda.c */
53 extern int  irsock_init(void);
54 extern void irsock_cleanup(void);
55 /* irlap_frame.c */
56 extern int  irlap_driver_rcv(struct sk_buff *, struct net_device *, 
57                              struct packet_type *, struct net_device *);
58
59 /*
60  * Module parameters
61  */
62 #ifdef CONFIG_IRDA_DEBUG
63 unsigned int irda_debug = IRDA_DEBUG_LEVEL;
64 module_param_named(debug, irda_debug, uint, 0);
65 MODULE_PARM_DESC(debug, "IRDA debugging level");
66 EXPORT_SYMBOL(irda_debug);
67 #endif
68
69 /* Packet type handler.
70  * Tell the kernel how IrDA packets should be handled.
71  */
72 static struct packet_type irda_packet_type = {
73         .type   = __constant_htons(ETH_P_IRDA),
74         .func   = irlap_driver_rcv,     /* Packet type handler irlap_frame.c */
75 };
76
77 /*
78  * Function irda_notify_init (notify)
79  *
80  *    Used for initializing the notify structure
81  *
82  */
83 void irda_notify_init(notify_t *notify)
84 {
85         notify->data_indication = NULL;
86         notify->udata_indication = NULL;
87         notify->connect_confirm = NULL;
88         notify->connect_indication = NULL;
89         notify->disconnect_indication = NULL;
90         notify->flow_indication = NULL;
91         notify->status_indication = NULL;
92         notify->instance = NULL;
93         strlcpy(notify->name, "Unknown", sizeof(notify->name));
94 }
95 EXPORT_SYMBOL(irda_notify_init);
96
97 /*
98  * Function irda_init (void)
99  *
100  *  Protocol stack initialisation entry point.
101  *  Initialise the various components of the IrDA stack
102  */
103 static int __init irda_init(void)
104 {
105         IRDA_DEBUG(0, "%s()\n", __FUNCTION__);
106
107         /* Lower layer of the stack */
108         irlmp_init();
109         irlap_init();
110         
111         /* Higher layers of the stack */
112         iriap_init();
113         irttp_init();
114         irsock_init();
115         
116         /* Add IrDA packet type (Start receiving packets) */
117         dev_add_pack(&irda_packet_type);
118
119         /* External APIs */
120 #ifdef CONFIG_PROC_FS
121         irda_proc_register();
122 #endif
123 #ifdef CONFIG_SYSCTL
124         irda_sysctl_register();
125 #endif
126
127         /* Driver/dongle support */
128         irda_device_init();
129
130         return 0;
131 }
132
133 /*
134  * Function irda_cleanup (void)
135  *
136  *  Protocol stack cleanup/removal entry point.
137  *  Cleanup the various components of the IrDA stack
138  */
139 static void __exit irda_cleanup(void)
140 {
141         /* Remove External APIs */
142 #ifdef CONFIG_SYSCTL
143         irda_sysctl_unregister();
144 #endif  
145 #ifdef CONFIG_PROC_FS
146         irda_proc_unregister();
147 #endif
148
149         /* Remove IrDA packet type (stop receiving packets) */
150         dev_remove_pack(&irda_packet_type);
151         
152         /* Remove higher layers */
153         irsock_cleanup();
154         irttp_cleanup();
155         iriap_cleanup();
156
157         /* Remove lower layers */
158         irda_device_cleanup();
159         irlap_cleanup(); /* Must be done before irlmp_cleanup()! DB */
160
161         /* Remove middle layer */
162         irlmp_cleanup();
163 }
164
165 /*
166  * The IrDA stack must be initialised *before* drivers get initialised,
167  * and *before* higher protocols (IrLAN/IrCOMM/IrNET) get initialised,
168  * otherwise bad things will happen (hashbins will be NULL for example).
169  * Those modules are at module_init()/device_initcall() level.
170  *
171  * On the other hand, it needs to be initialised *after* the basic
172  * networking, the /proc/net filesystem and sysctl module. Those are
173  * currently initialised in .../init/main.c (before initcalls).
174  * Also, IrDA drivers needs to be initialised *after* the random number
175  * generator (main stack and higher layer init don't need it anymore).
176  *
177  * Jean II
178  */
179 subsys_initcall(irda_init);
180 module_exit(irda_cleanup);
181  
182 MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no> & Jean Tourrilhes <jt@hpl.hp.com>");
183 MODULE_DESCRIPTION("The Linux IrDA Protocol Stack"); 
184 MODULE_LICENSE("GPL");
185 MODULE_ALIAS_NETPROTO(PF_IRDA);