divert_init.c 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* $Id divert_init.c,v 1.5.6.2 2001/01/24 22:18:17 kai Exp $
  2. *
  3. * Module init for DSS1 diversion services for i4l.
  4. *
  5. * Copyright 1999 by Werner Cornelius (werner@isdn4linux.de)
  6. *
  7. * This software may be used and distributed according to the terms
  8. * of the GNU General Public License, incorporated herein by reference.
  9. *
  10. */
  11. #include <linux/module.h>
  12. #include <linux/init.h>
  13. #include <linux/kernel.h>
  14. #include "isdn_divert.h"
  15. MODULE_DESCRIPTION("ISDN4Linux: Call diversion support");
  16. MODULE_AUTHOR("Werner Cornelius");
  17. MODULE_LICENSE("GPL");
  18. /****************************************/
  19. /* structure containing interface to hl */
  20. /****************************************/
  21. isdn_divert_if divert_if =
  22. { DIVERT_IF_MAGIC, /* magic value */
  23. DIVERT_CMD_REG, /* register cmd */
  24. ll_callback, /* callback routine from ll */
  25. NULL, /* command still not specified */
  26. NULL, /* drv_to_name */
  27. NULL, /* name_to_drv */
  28. };
  29. /*************************/
  30. /* Module interface code */
  31. /* no cmd line parms */
  32. /*************************/
  33. static int __init divert_init(void)
  34. { int i;
  35. if (divert_dev_init())
  36. { printk(KERN_WARNING "dss1_divert: cannot install device, not loaded\n");
  37. return(-EIO);
  38. }
  39. if ((i = DIVERT_REG_NAME(&divert_if)) != DIVERT_NO_ERR)
  40. { divert_dev_deinit();
  41. printk(KERN_WARNING "dss1_divert: error %d registering module, not loaded\n",i);
  42. return(-EIO);
  43. }
  44. printk(KERN_INFO "dss1_divert module successfully installed\n");
  45. return(0);
  46. }
  47. /**********************/
  48. /* Module deinit code */
  49. /**********************/
  50. static void __exit divert_exit(void)
  51. {
  52. unsigned long flags;
  53. int i;
  54. spin_lock_irqsave(&divert_lock, flags);
  55. divert_if.cmd = DIVERT_CMD_REL; /* release */
  56. if ((i = DIVERT_REG_NAME(&divert_if)) != DIVERT_NO_ERR)
  57. { printk(KERN_WARNING "dss1_divert: error %d releasing module\n",i);
  58. spin_unlock_irqrestore(&divert_lock, flags);
  59. return;
  60. }
  61. if (divert_dev_deinit())
  62. { printk(KERN_WARNING "dss1_divert: device busy, remove cancelled\n");
  63. spin_unlock_irqrestore(&divert_lock, flags);
  64. return;
  65. }
  66. spin_unlock_irqrestore(&divert_lock, flags);
  67. deleterule(-1); /* delete all rules and free mem */
  68. deleteprocs();
  69. printk(KERN_INFO "dss1_divert module successfully removed \n");
  70. }
  71. module_init(divert_init);
  72. module_exit(divert_exit);