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