irmod.c 4.7 KB

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