irmod.c 5.2 KB

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