/*********************************************************************1*2* Filename: irmod.c3* Version: 0.94* Description: IrDA stack main entry points5* Status: Experimental.6* Author: Dag Brattli <[email protected]>7* Created at: Mon Dec 15 13:55:39 19978* Modified at: Wed Jan 5 15:12:41 20009* Modified by: Dag Brattli <[email protected]>10*11* Copyright (c) 1997, 1999-2000 Dag Brattli, All Rights Reserved.12* Copyright (c) 2000-2004 Jean Tourrilhes <[email protected]>13*14* This program is free software; you can redistribute it and/or15* modify it under the terms of the GNU General Public License as16* published by the Free Software Foundation; either version 2 of17* the License, or (at your option) any later version.18*19* Neither Dag Brattli nor University of Tromsø admit liability nor20* provide warranty for any of this software. This material is21* provided "AS-IS" and at no charge.22*23********************************************************************/2425/*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 developpers28* are using the IrDA stack without the socket API (compiling out29* af_irda.c).30* Jean II31*/3233#include <linux/module.h>34#include <linux/moduleparam.h>3536#include <net/irda/irda.h>37#include <net/irda/irmod.h> /* notify_t */38#include <net/irda/irlap.h> /* irlap_init */39#include <net/irda/irlmp.h> /* irlmp_init */40#include <net/irda/iriap.h> /* iriap_init */41#include <net/irda/irttp.h> /* irttp_init */42#include <net/irda/irda_device.h> /* irda_device_init */4344/*45* Module parameters46*/47#ifdef CONFIG_IRDA_DEBUG48unsigned int irda_debug = IRDA_DEBUG_LEVEL;49module_param_named(debug, irda_debug, uint, 0);50MODULE_PARM_DESC(debug, "IRDA debugging level");51EXPORT_SYMBOL(irda_debug);52#endif5354/* Packet type handler.55* Tell the kernel how IrDA packets should be handled.56*/57static struct packet_type irda_packet_type __read_mostly = {58.type = cpu_to_be16(ETH_P_IRDA),59.func = irlap_driver_rcv, /* Packet type handler irlap_frame.c */60};6162/*63* Function irda_notify_init (notify)64*65* Used for initializing the notify structure66*67*/68void irda_notify_init(notify_t *notify)69{70notify->data_indication = NULL;71notify->udata_indication = NULL;72notify->connect_confirm = NULL;73notify->connect_indication = NULL;74notify->disconnect_indication = NULL;75notify->flow_indication = NULL;76notify->status_indication = NULL;77notify->instance = NULL;78strlcpy(notify->name, "Unknown", sizeof(notify->name));79}80EXPORT_SYMBOL(irda_notify_init);8182/*83* Function irda_init (void)84*85* Protocol stack initialisation entry point.86* Initialise the various components of the IrDA stack87*/88static int __init irda_init(void)89{90int ret = 0;9192IRDA_DEBUG(0, "%s()\n", __func__);9394/* Lower layer of the stack */95irlmp_init();96irlap_init();9798/* Driver/dongle support */99irda_device_init();100101/* Higher layers of the stack */102iriap_init();103irttp_init();104ret = irsock_init();105if (ret < 0)106goto out_err_1;107108/* Add IrDA packet type (Start receiving packets) */109dev_add_pack(&irda_packet_type);110111/* External APIs */112#ifdef CONFIG_PROC_FS113irda_proc_register();114#endif115#ifdef CONFIG_SYSCTL116ret = irda_sysctl_register();117if (ret < 0)118goto out_err_2;119#endif120121ret = irda_nl_register();122if (ret < 0)123goto out_err_3;124125return 0;126127out_err_3:128#ifdef CONFIG_SYSCTL129irda_sysctl_unregister();130out_err_2:131#endif132#ifdef CONFIG_PROC_FS133irda_proc_unregister();134#endif135136/* Remove IrDA packet type (stop receiving packets) */137dev_remove_pack(&irda_packet_type);138139/* Remove higher layers */140irsock_cleanup();141out_err_1:142irttp_cleanup();143iriap_cleanup();144145/* Remove lower layers */146irda_device_cleanup();147irlap_cleanup(); /* Must be done before irlmp_cleanup()! DB */148149/* Remove middle layer */150irlmp_cleanup();151152153return ret;154}155156/*157* Function irda_cleanup (void)158*159* Protocol stack cleanup/removal entry point.160* Cleanup the various components of the IrDA stack161*/162static void __exit irda_cleanup(void)163{164/* Remove External APIs */165irda_nl_unregister();166167#ifdef CONFIG_SYSCTL168irda_sysctl_unregister();169#endif170#ifdef CONFIG_PROC_FS171irda_proc_unregister();172#endif173174/* Remove IrDA packet type (stop receiving packets) */175dev_remove_pack(&irda_packet_type);176177/* Remove higher layers */178irsock_cleanup();179irttp_cleanup();180iriap_cleanup();181182/* Remove lower layers */183irda_device_cleanup();184irlap_cleanup(); /* Must be done before irlmp_cleanup()! DB */185186/* Remove middle layer */187irlmp_cleanup();188}189190/*191* The IrDA stack must be initialised *before* drivers get initialised,192* and *before* higher protocols (IrLAN/IrCOMM/IrNET) get initialised,193* otherwise bad things will happen (hashbins will be NULL for example).194* Those modules are at module_init()/device_initcall() level.195*196* On the other hand, it needs to be initialised *after* the basic197* networking, the /proc/net filesystem and sysctl module. Those are198* currently initialised in .../init/main.c (before initcalls).199* Also, IrDA drivers needs to be initialised *after* the random number200* generator (main stack and higher layer init don't need it anymore).201*202* Jean II203*/204subsys_initcall(irda_init);205module_exit(irda_cleanup);206207MODULE_AUTHOR("Dag Brattli <[email protected]> & Jean Tourrilhes <[email protected]>");208MODULE_DESCRIPTION("The Linux IrDA Protocol Stack");209MODULE_LICENSE("GPL");210MODULE_ALIAS_NETPROTO(PF_IRDA);211212213