static void __exit divert_exit(void)
{
	unsigned long flags;
	int i;

	spin_lock_irqsave(&divert_lock, flags);
	divert_if.cmd = DIVERT_CMD_REL; /* release */
	if ((i = DIVERT_REG_NAME(&divert_if)) != DIVERT_NO_ERR)
	{ printk(KERN_WARNING "dss1_divert: error %d releasing module\n", i);
		spin_unlock_irqrestore(&divert_lock, flags);
		return;
	}
	if (divert_dev_deinit())
	{ printk(KERN_WARNING "dss1_divert: device busy, remove cancelled\n");
		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");
}
Esempio n. 2
0
void cleanup_module(void)
{ int flags;
  int i;

  save_flags(flags);
  cli();
  divert_if.cmd = DIVERT_CMD_REL; /* release */
  if ((i = DIVERT_REG_NAME(&divert_if)) != DIVERT_NO_ERR)
   { printk(KERN_WARNING "dss1_divert: error %d releasing module\n",i);
     restore_flags(flags);
     return;
   } 
  if (divert_dev_deinit()) 
   { printk(KERN_WARNING "dss1_divert: device busy, remove cancelled\n");
     restore_flags(flags);
     return;
   }
  restore_flags(flags);
  deleterule(-1); /* delete all rules and free mem */
  deleteprocs();
  printk(KERN_INFO "dss1_divert module successfully removed \n");
} /* cleanup_module */
Esempio n. 3
0
static int __init divert_init(void)
{ int i;

  if (divert_dev_init())
#ifdef CONFIG_DEBUG_PRINTK
   { printk(KERN_WARNING "dss1_divert: cannot install device, not loaded\n");
#else
   { ;
#endif
     return(-EIO);
   }
  if ((i = DIVERT_REG_NAME(&divert_if)) != DIVERT_NO_ERR)
   { divert_dev_deinit();
#ifdef CONFIG_DEBUG_PRINTK
     printk(KERN_WARNING "dss1_divert: error %d registering module, not loaded\n",i);
#else
     ;
#endif
     return(-EIO);
   } 
#ifdef CONFIG_DEBUG_PRINTK
  printk(KERN_INFO "dss1_divert module successfully installed\n");
#else
  ;
#endif
  return(0);
}

/**********************/
/* Module deinit code */
/**********************/
static void __exit divert_exit(void)
{
  unsigned long flags;
  int i;

  spin_lock_irqsave(&divert_lock, flags);
  divert_if.cmd = DIVERT_CMD_REL; /* release */
  if ((i = DIVERT_REG_NAME(&divert_if)) != DIVERT_NO_ERR)
#ifdef CONFIG_DEBUG_PRINTK
   { printk(KERN_WARNING "dss1_divert: error %d releasing module\n",i);
#else
   { ;
#endif
     spin_unlock_irqrestore(&divert_lock, flags);
     return;
   } 
  if (divert_dev_deinit()) 
#ifdef CONFIG_DEBUG_PRINTK
   { printk(KERN_WARNING "dss1_divert: device busy, remove cancelled\n");
#else
   { ;
#endif
     spin_unlock_irqrestore(&divert_lock, flags);
     return;
   }
  spin_unlock_irqrestore(&divert_lock, flags);
  deleterule(-1); /* delete all rules and free mem */
  deleteprocs();
#ifdef CONFIG_DEBUG_PRINTK
  printk(KERN_INFO "dss1_divert module successfully removed \n");
#else
  ;
#endif
}

module_init(divert_init);
module_exit(divert_exit);