irmod.c 5.2 KB

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