2005-04-16 15:20:36 -07:00
/* $Id divert_init.c,v 1.5.6.2 2001/01/24 22:18:17 kai Exp $
*
* Module init for DSS1 diversion services for i4l .
*
* Copyright 1999 by Werner Cornelius ( werner @ isdn4linux . de )
2012-02-19 19:52:38 -08:00
*
2005-04-16 15:20:36 -07:00
* This software may be used and distributed according to the terms
* of the GNU General Public License , incorporated herein by reference .
*
*/
# include <linux/module.h>
# include <linux/init.h>
# include <linux/kernel.h>
# include "isdn_divert.h"
MODULE_DESCRIPTION ( " ISDN4Linux: Call diversion support " ) ;
MODULE_AUTHOR ( " Werner Cornelius " ) ;
MODULE_LICENSE ( " GPL " ) ;
/****************************************/
/* structure containing interface to hl */
/****************************************/
2013-01-21 11:57:20 +00:00
isdn_divert_if divert_if = {
DIVERT_IF_MAGIC , /* magic value */
DIVERT_CMD_REG , /* register cmd */
ll_callback , /* callback routine from ll */
NULL , /* command still not specified */
NULL , /* drv_to_name */
NULL , /* name_to_drv */
2012-02-19 19:52:38 -08:00
} ;
2005-04-16 15:20:36 -07:00
/*************************/
/* Module interface code */
/* no cmd line parms */
/*************************/
static int __init divert_init ( void )
2013-01-21 11:57:20 +00:00
{
int i ;
2005-04-16 15:20:36 -07:00
2013-01-21 11:57:20 +00:00
if ( divert_dev_init ( ) ) {
printk ( KERN_WARNING " dss1_divert: cannot install device, not loaded \n " ) ;
2012-02-19 19:52:38 -08:00
return ( - EIO ) ;
}
2013-01-21 11:57:20 +00:00
if ( ( i = DIVERT_REG_NAME ( & divert_if ) ) ! = DIVERT_NO_ERR ) {
divert_dev_deinit ( ) ;
2012-02-19 19:52:38 -08:00
printk ( KERN_WARNING " dss1_divert: error %d registering module, not loaded \n " , i ) ;
return ( - EIO ) ;
}
printk ( KERN_INFO " dss1_divert module successfully installed \n " ) ;
return ( 0 ) ;
2005-04-16 15:20:36 -07:00
}
/**********************/
/* Module deinit code */
/**********************/
static void __exit divert_exit ( void )
{
2012-02-19 19:52:38 -08:00
unsigned long flags ;
int i ;
2005-04-16 15:20:36 -07:00
2012-02-19 19:52:38 -08:00
spin_lock_irqsave ( & divert_lock , flags ) ;
divert_if . cmd = DIVERT_CMD_REL ; /* release */
2013-01-21 11:57:20 +00:00
if ( ( i = DIVERT_REG_NAME ( & divert_if ) ) ! = DIVERT_NO_ERR ) {
printk ( KERN_WARNING " dss1_divert: error %d releasing module \n " , i ) ;
2012-02-19 19:52:38 -08:00
spin_unlock_irqrestore ( & divert_lock , flags ) ;
return ;
}
2013-01-21 11:57:20 +00:00
if ( divert_dev_deinit ( ) ) {
printk ( KERN_WARNING " dss1_divert: device busy, remove cancelled \n " ) ;
2012-02-19 19:52:38 -08:00
spin_unlock_irqrestore ( & divert_lock , flags ) ;
return ;
}
spin_unlock_irqrestore ( & divert_lock , flags ) ;
deleterule ( - 1 ) ; /* delete all rules and free mem */
deleteprocs ( ) ;
printk ( KERN_INFO " dss1_divert module successfully removed \n " ) ;
2005-04-16 15:20:36 -07:00
}
module_init ( divert_init ) ;
module_exit ( divert_exit ) ;