blob: c7fad2c5b9f3508867130646681b5155e7fec108 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*********************************************************************
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +09002 *
Linus Torvalds1da177e2005-04-16 15:20:36 -07003 * 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>
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090011 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070012 * Copyright (c) 1997, 1999-2000 Dag Brattli, All Rights Reserved.
13 * Copyright (c) 2000-2004 Jean Tourrilhes <jt@hpl.hp.com>
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090014 *
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 * the License, or (at your option) any later version.
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090019 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070020 * Neither Dag Brattli nor University of Tromsø admit liability nor
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090021 * provide warranty for any of this software. This material is
Linus Torvalds1da177e2005-04-16 15:20:36 -070022 * provided "AS-IS" and at no charge.
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090023 *
Linus Torvalds1da177e2005-04-16 15:20:36 -070024 ********************************************************************/
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
Linus Torvalds1da177e2005-04-16 15:20:36 -070034#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
Linus Torvalds1da177e2005-04-16 15:20:36 -070045/*
46 * Module parameters
47 */
48#ifdef CONFIG_IRDA_DEBUG
49unsigned int irda_debug = IRDA_DEBUG_LEVEL;
50module_param_named(debug, irda_debug, uint, 0);
51MODULE_PARM_DESC(debug, "IRDA debugging level");
52EXPORT_SYMBOL(irda_debug);
53#endif
54
55/* Packet type handler.
56 * Tell the kernel how IrDA packets should be handled.
57 */
58static struct packet_type irda_packet_type = {
59 .type = __constant_htons(ETH_P_IRDA),
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 */
69void 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}
81EXPORT_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 */
89static int __init irda_init(void)
90{
91 IRDA_DEBUG(0, "%s()\n", __FUNCTION__);
92
93 /* Lower layer of the stack */
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090094 irlmp_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -070095 irlap_init();
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090096
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 /* Higher layers of the stack */
98 iriap_init();
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +090099 irttp_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 irsock_init();
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 /* Add IrDA packet type (Start receiving packets) */
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900103 dev_add_pack(&irda_packet_type);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700104
105 /* External APIs */
106#ifdef CONFIG_PROC_FS
107 irda_proc_register();
108#endif
109#ifdef CONFIG_SYSCTL
110 irda_sysctl_register();
111#endif
112
113 /* Driver/dongle support */
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900114 irda_device_init();
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
116 return 0;
117}
118
119/*
120 * Function irda_cleanup (void)
121 *
122 * Protocol stack cleanup/removal entry point.
123 * Cleanup the various components of the IrDA stack
124 */
125static void __exit irda_cleanup(void)
126{
127 /* Remove External APIs */
128#ifdef CONFIG_SYSCTL
129 irda_sysctl_unregister();
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900130#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131#ifdef CONFIG_PROC_FS
132 irda_proc_unregister();
133#endif
134
135 /* Remove IrDA packet type (stop receiving packets) */
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900136 dev_remove_pack(&irda_packet_type);
137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 /* Remove higher layers */
139 irsock_cleanup();
140 irttp_cleanup();
141 iriap_cleanup();
142
143 /* Remove lower layers */
144 irda_device_cleanup();
145 irlap_cleanup(); /* Must be done before irlmp_cleanup()! DB */
146
147 /* Remove middle layer */
148 irlmp_cleanup();
149}
150
151/*
152 * The IrDA stack must be initialised *before* drivers get initialised,
153 * and *before* higher protocols (IrLAN/IrCOMM/IrNET) get initialised,
154 * otherwise bad things will happen (hashbins will be NULL for example).
155 * Those modules are at module_init()/device_initcall() level.
156 *
157 * On the other hand, it needs to be initialised *after* the basic
158 * networking, the /proc/net filesystem and sysctl module. Those are
159 * currently initialised in .../init/main.c (before initcalls).
160 * Also, IrDA drivers needs to be initialised *after* the random number
161 * generator (main stack and higher layer init don't need it anymore).
162 *
163 * Jean II
164 */
165subsys_initcall(irda_init);
166module_exit(irda_cleanup);
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900167
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168MODULE_AUTHOR("Dag Brattli <dagb@cs.uit.no> & Jean Tourrilhes <jt@hpl.hp.com>");
YOSHIFUJI Hideaki6819bc22007-02-09 23:24:53 +0900169MODULE_DESCRIPTION("The Linux IrDA Protocol Stack");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700170MODULE_LICENSE("GPL");
171MODULE_ALIAS_NETPROTO(PF_IRDA);