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 | * |
Jan Engelhardt | 96de0e2 | 2007-10-19 23:21:04 +0200 | [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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | /* Packet type handler. |
| 46 | * Tell the kernel how IrDA packets should be handled. |
| 47 | */ |
Stephen Hemminger | 7546dd9 | 2009-03-09 08:18:29 +0000 | [diff] [blame] | 48 | static struct packet_type irda_packet_type __read_mostly = { |
Harvey Harrison | 09640e6 | 2009-02-01 00:45:17 -0800 | [diff] [blame] | 49 | .type = cpu_to_be16(ETH_P_IRDA), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | .func = irlap_driver_rcv, /* Packet type handler irlap_frame.c */ |
| 51 | }; |
| 52 | |
| 53 | /* |
| 54 | * Function irda_notify_init (notify) |
| 55 | * |
| 56 | * Used for initializing the notify structure |
| 57 | * |
| 58 | */ |
| 59 | void irda_notify_init(notify_t *notify) |
| 60 | { |
| 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)); |
| 70 | } |
| 71 | EXPORT_SYMBOL(irda_notify_init); |
| 72 | |
| 73 | /* |
| 74 | * Function irda_init (void) |
| 75 | * |
| 76 | * Protocol stack initialisation entry point. |
| 77 | * Initialise the various components of the IrDA stack |
| 78 | */ |
| 79 | static int __init irda_init(void) |
| 80 | { |
Samuel Ortiz | 89da1ec | 2007-07-02 22:54:18 -0700 | [diff] [blame] | 81 | int ret = 0; |
| 82 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | /* Lower layer of the stack */ |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 84 | irlmp_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | irlap_init(); |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 86 | |
Samuel Ortiz | 89da1ec | 2007-07-02 22:54:18 -0700 | [diff] [blame] | 87 | /* Driver/dongle support */ |
| 88 | irda_device_init(); |
| 89 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | /* Higher layers of the stack */ |
| 91 | iriap_init(); |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 92 | irttp_init(); |
Samuel Ortiz | 89da1ec | 2007-07-02 22:54:18 -0700 | [diff] [blame] | 93 | ret = irsock_init(); |
| 94 | if (ret < 0) |
| 95 | goto out_err_1; |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 96 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 97 | /* Add IrDA packet type (Start receiving packets) */ |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 98 | dev_add_pack(&irda_packet_type); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 99 | |
| 100 | /* External APIs */ |
| 101 | #ifdef CONFIG_PROC_FS |
| 102 | irda_proc_register(); |
| 103 | #endif |
| 104 | #ifdef CONFIG_SYSCTL |
Samuel Ortiz | 89da1ec | 2007-07-02 22:54:18 -0700 | [diff] [blame] | 105 | ret = irda_sysctl_register(); |
| 106 | if (ret < 0) |
| 107 | goto out_err_2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 108 | #endif |
| 109 | |
Samuel Ortiz | 89da1ec | 2007-07-02 22:54:18 -0700 | [diff] [blame] | 110 | ret = irda_nl_register(); |
| 111 | if (ret < 0) |
| 112 | goto out_err_3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | |
| 114 | return 0; |
Samuel Ortiz | 89da1ec | 2007-07-02 22:54:18 -0700 | [diff] [blame] | 115 | |
| 116 | out_err_3: |
| 117 | #ifdef CONFIG_SYSCTL |
| 118 | irda_sysctl_unregister(); |
Samuel Ortiz | 89da1ec | 2007-07-02 22:54:18 -0700 | [diff] [blame] | 119 | out_err_2: |
Jesper Juhl | 2c20d72 | 2007-08-21 00:10:50 -0700 | [diff] [blame] | 120 | #endif |
Samuel Ortiz | 89da1ec | 2007-07-02 22:54:18 -0700 | [diff] [blame] | 121 | #ifdef CONFIG_PROC_FS |
| 122 | irda_proc_unregister(); |
| 123 | #endif |
| 124 | |
| 125 | /* Remove IrDA packet type (stop receiving packets) */ |
| 126 | dev_remove_pack(&irda_packet_type); |
| 127 | |
| 128 | /* Remove higher layers */ |
| 129 | irsock_cleanup(); |
| 130 | out_err_1: |
| 131 | irttp_cleanup(); |
| 132 | iriap_cleanup(); |
| 133 | |
| 134 | /* Remove lower layers */ |
| 135 | irda_device_cleanup(); |
| 136 | irlap_cleanup(); /* Must be done before irlmp_cleanup()! DB */ |
| 137 | |
| 138 | /* Remove middle layer */ |
| 139 | irlmp_cleanup(); |
| 140 | |
| 141 | |
| 142 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | /* |
| 146 | * Function irda_cleanup (void) |
| 147 | * |
| 148 | * Protocol stack cleanup/removal entry point. |
| 149 | * Cleanup the various components of the IrDA stack |
| 150 | */ |
| 151 | static void __exit irda_cleanup(void) |
| 152 | { |
| 153 | /* Remove External APIs */ |
Samuel Ortiz | 89da1ec | 2007-07-02 22:54:18 -0700 | [diff] [blame] | 154 | irda_nl_unregister(); |
| 155 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 156 | #ifdef CONFIG_SYSCTL |
| 157 | irda_sysctl_unregister(); |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 158 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 159 | #ifdef CONFIG_PROC_FS |
| 160 | irda_proc_unregister(); |
| 161 | #endif |
| 162 | |
| 163 | /* Remove IrDA packet type (stop receiving packets) */ |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 164 | dev_remove_pack(&irda_packet_type); |
| 165 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | /* Remove higher layers */ |
| 167 | irsock_cleanup(); |
| 168 | irttp_cleanup(); |
| 169 | iriap_cleanup(); |
| 170 | |
| 171 | /* Remove lower layers */ |
| 172 | irda_device_cleanup(); |
| 173 | irlap_cleanup(); /* Must be done before irlmp_cleanup()! DB */ |
| 174 | |
| 175 | /* Remove middle layer */ |
| 176 | irlmp_cleanup(); |
| 177 | } |
| 178 | |
| 179 | /* |
| 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. |
| 184 | * |
| 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). |
| 190 | * |
| 191 | * Jean II |
| 192 | */ |
| 193 | subsys_initcall(irda_init); |
| 194 | module_exit(irda_cleanup); |
YOSHIFUJI Hideaki | 6819bc2 | 2007-02-09 23:24:53 +0900 | [diff] [blame] | 195 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | 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] | 197 | MODULE_DESCRIPTION("The Linux IrDA Protocol Stack"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 198 | MODULE_LICENSE("GPL"); |
| 199 | MODULE_ALIAS_NETPROTO(PF_IRDA); |