mark mISDN modules as used (don't allow to remove them), if userspace software opens /dev/mISDN.
This commit is contained in:
parent
1c919ae75b
commit
d1e673c815
|
@ -17,6 +17,7 @@
|
|||
#include <linux/isapnp.h>
|
||||
#endif
|
||||
#include <linux/delay.h>
|
||||
#include "core.h"
|
||||
#include "channel.h"
|
||||
#include "isac.h"
|
||||
#include "layer1.h"
|
||||
|
@ -1440,6 +1441,9 @@ static int __init Fritz_init(void)
|
|||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
mISDN_module_register(THIS_MODULE);
|
||||
|
||||
return 0;
|
||||
|
||||
#if !defined(CONFIG_HOTPLUG) || defined(MODULE)
|
||||
|
@ -1463,6 +1467,8 @@ static void __exit Fritz_cleanup(void)
|
|||
fritzpnppci *card, *next;
|
||||
int err;
|
||||
|
||||
mISDN_module_unregister(THIS_MODULE);
|
||||
|
||||
if ((err = mISDN_unregister(&fritz))) {
|
||||
printk(KERN_ERR "Can't unregister Fritz PCI error(%d)\n", err);
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include "core.h"
|
||||
#include "m_capi.h"
|
||||
#include "helper.h"
|
||||
#include "debug.h"
|
||||
|
@ -423,7 +424,8 @@ int Capi20Init(void)
|
|||
free_AppPlci();
|
||||
free_ncci();
|
||||
free_Application();
|
||||
}
|
||||
} else
|
||||
mISDN_module_register(THIS_MODULE);
|
||||
return(err);
|
||||
}
|
||||
|
||||
|
@ -433,6 +435,8 @@ static void Capi20cleanup(void)
|
|||
int err;
|
||||
Controller_t *contr, *next;
|
||||
|
||||
mISDN_module_unregister(THIS_MODULE);
|
||||
|
||||
if ((err = mISDN_unregister(&capi_obj))) {
|
||||
printk(KERN_ERR "Can't unregister CAPI20 error(%d)\n", err);
|
||||
}
|
||||
|
|
|
@ -24,6 +24,13 @@ static char *mISDN_core_revision = "$Revision$";
|
|||
LIST_HEAD(mISDN_objectlist);
|
||||
static rwlock_t mISDN_objects_lock = RW_LOCK_UNLOCKED;
|
||||
|
||||
LIST_HEAD(mISDN_modulelist);
|
||||
static rwlock_t mISDN_modules_lock = RW_LOCK_UNLOCKED;
|
||||
struct modulelist {
|
||||
struct list_head list;
|
||||
struct module *module;
|
||||
};
|
||||
|
||||
int core_debug;
|
||||
|
||||
static u_char entityarray[MISDN_MAX_ENTITY/8];
|
||||
|
@ -605,6 +612,62 @@ mISDN_ctrl(void *data, u_int prim, void *arg) {
|
|||
return(-EINVAL);
|
||||
}
|
||||
|
||||
void
|
||||
mISDN_module_register(struct module *module)
|
||||
{
|
||||
struct modulelist *ml = kmalloc(sizeof(struct modulelist), GFP_KERNEL);
|
||||
|
||||
if (!ml) {
|
||||
printk(KERN_DEBUG "mISDN_register_module: kmalloc failed!\n");
|
||||
return;
|
||||
}
|
||||
ml->module = module;
|
||||
write_lock(&mISDN_modules_lock);
|
||||
list_add(&ml->list, &mISDN_modulelist);
|
||||
write_unlock(&mISDN_modules_lock);
|
||||
|
||||
printk(KERN_DEBUG "mISDN_register_module(%p)\n", module);
|
||||
}
|
||||
|
||||
void
|
||||
mISDN_module_unregister(struct module *module)
|
||||
{
|
||||
struct modulelist *ml, *mi;
|
||||
|
||||
write_lock(&mISDN_modules_lock);
|
||||
list_for_each_entry_safe(ml, mi, &mISDN_modulelist, list)
|
||||
if (ml->module == module) {
|
||||
list_del(&ml->list);
|
||||
kfree(ml);
|
||||
write_unlock(&mISDN_modules_lock);
|
||||
printk(KERN_DEBUG "mISDN_unregister_module(%p)\n", module);
|
||||
return;
|
||||
}
|
||||
write_unlock(&mISDN_modules_lock);
|
||||
}
|
||||
|
||||
void
|
||||
mISDN_inc_usage(void)
|
||||
{
|
||||
struct modulelist *ml;
|
||||
|
||||
read_lock(&mISDN_modules_lock);
|
||||
list_for_each_entry(ml, &mISDN_modulelist, list)
|
||||
try_module_get(ml->module);
|
||||
read_unlock(&mISDN_modules_lock);
|
||||
}
|
||||
|
||||
void
|
||||
mISDN_dec_usage(void)
|
||||
{
|
||||
struct modulelist *ml;
|
||||
|
||||
read_lock(&mISDN_modules_lock);
|
||||
list_for_each_entry(ml, &mISDN_modulelist, list)
|
||||
module_put(ml->module);
|
||||
read_unlock(&mISDN_modules_lock);
|
||||
}
|
||||
|
||||
int mISDN_register(mISDNobject_t *obj) {
|
||||
u_long flags;
|
||||
int retval;
|
||||
|
@ -730,6 +793,10 @@ void mISDN_cleanup(void) {
|
|||
module_init(mISDNInit);
|
||||
module_exit(mISDN_cleanup);
|
||||
|
||||
EXPORT_SYMBOL(mISDN_module_register);
|
||||
EXPORT_SYMBOL(mISDN_module_unregister);
|
||||
EXPORT_SYMBOL(mISDN_inc_usage);
|
||||
EXPORT_SYMBOL(mISDN_dec_usage);
|
||||
EXPORT_SYMBOL(mISDN_ctrl);
|
||||
EXPORT_SYMBOL(mISDN_register);
|
||||
EXPORT_SYMBOL(mISDN_unregister);
|
||||
|
|
|
@ -85,6 +85,10 @@ extern mISDNobject_t *get_object(int);
|
|||
extern mISDNinstance_t *get_instance4id(u_int);
|
||||
extern int mISDN_alloc_entity(int *);
|
||||
extern int mISDN_delete_entity(int);
|
||||
extern void mISDN_module_register(struct module *);
|
||||
extern void mISDN_module_unregister(struct module *);
|
||||
extern void mISDN_inc_usage(void);
|
||||
extern void mISDN_dec_usage(void);
|
||||
|
||||
|
||||
#ifdef CONFIG_MISDN_NETDEV
|
||||
|
|
|
@ -175,6 +175,7 @@ const char *dsp_revision = "$Revision$";
|
|||
#include <linux/config.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/vmalloc.h>
|
||||
#include "core.h"
|
||||
#include "layer1.h"
|
||||
#include "helper.h"
|
||||
#include "debug.h"
|
||||
|
@ -1031,6 +1032,8 @@ static int dsp_init(void)
|
|||
dsp_spl_jiffies = dsp_spl_tl.expires;
|
||||
add_timer(&dsp_spl_tl);
|
||||
|
||||
mISDN_module_register(THIS_MODULE);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@ -1043,6 +1046,8 @@ static void dsp_cleanup(void)
|
|||
dsp_t *dspl, *nd;
|
||||
int err;
|
||||
|
||||
mISDN_module_unregister(THIS_MODULE);
|
||||
|
||||
if (timer_pending(&dsp_spl_tl))
|
||||
del_timer(&dsp_spl_tl);
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
#include <linux/config.h>
|
||||
#include <linux/module.h>
|
||||
#include "core.h"
|
||||
#include "layer1.h"
|
||||
#include "helper.h"
|
||||
#include "debug.h"
|
||||
|
@ -641,7 +642,8 @@ static int dtmf_init(void)
|
|||
INIT_LIST_HEAD(&dtmf_obj.ilist);
|
||||
if ((err = mISDN_register(&dtmf_obj))) {
|
||||
printk(KERN_ERR "Can't register %s error(%d)\n", MName, err);
|
||||
}
|
||||
} else
|
||||
mISDN_module_register(THIS_MODULE);
|
||||
return(err);
|
||||
}
|
||||
|
||||
|
@ -650,6 +652,8 @@ static void dtmf_cleanup(void)
|
|||
int err;
|
||||
dtmf_t *dtmf, *nd;
|
||||
|
||||
mISDN_module_unregister(THIS_MODULE);
|
||||
|
||||
if ((err = mISDN_unregister(&dtmf_obj))) {
|
||||
printk(KERN_ERR "Can't unregister DTMF error(%d)\n", err);
|
||||
}
|
||||
|
|
|
@ -98,6 +98,7 @@
|
|||
#include <linux/pci.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#include "core.h"
|
||||
#include "channel.h"
|
||||
#include "layer1.h"
|
||||
#include "dsp.h"
|
||||
|
@ -4341,6 +4342,8 @@ HFCmulti_cleanup(void)
|
|||
hfc_multi_t *hc,*next;
|
||||
int err;
|
||||
|
||||
mISDN_module_unregister(THIS_MODULE);
|
||||
|
||||
/* unregister mISDN object */
|
||||
if (debug & DEBUG_HFCMULTI_INIT)
|
||||
printk(KERN_DEBUG "%s: entered (refcnt = %d HFC_cnt = %d)\n", __FUNCTION__, HFCM_obj.refcnt, HFC_cnt);
|
||||
|
@ -4460,6 +4463,8 @@ HFCmulti_init(void)
|
|||
#endif
|
||||
printk(KERN_INFO "%d devices registered\n", HFC_cnt);
|
||||
|
||||
mISDN_module_register(THIS_MODULE);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <linux/pci.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#include "core.h"
|
||||
#include "channel.h"
|
||||
#include "hfc_pci.h"
|
||||
#include "layer1.h"
|
||||
|
@ -2267,6 +2268,7 @@ static int __init HFC_init(void)
|
|||
mISDN_ctrl(dst, MGR_STARTSTACK | REQUEST, NULL);
|
||||
mISDN_ctrl(dst, MGR_CTRLREADY | INDICATION, NULL);
|
||||
}
|
||||
mISDN_module_register(THIS_MODULE);
|
||||
printk(KERN_INFO "HFC %d cards installed\n", HFC_cnt);
|
||||
return(0);
|
||||
}
|
||||
|
@ -2277,6 +2279,8 @@ static void __exit HFC_cleanup(void)
|
|||
hfc_pci_t *card, *next;
|
||||
int err;
|
||||
|
||||
mISDN_module_unregister(THIS_MODULE);
|
||||
|
||||
if ((err = mISDN_unregister(&HFC_obj))) {
|
||||
printk(KERN_ERR "Can't unregister HFC PCI error(%d)\n", err);
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
#include <linux/module.h>
|
||||
#include <linux/delay.h>
|
||||
#include <asm/timex.h>
|
||||
#include "core.h"
|
||||
#include "layer1.h"
|
||||
#include "debug.h"
|
||||
#include "hfcs_mini.h"
|
||||
|
@ -1847,6 +1848,7 @@ hfcsmini_init(void)
|
|||
#endif
|
||||
#endif
|
||||
|
||||
mISDN_module_register(THIS_MODULE);
|
||||
printk(KERN_INFO "HFC-S mini: %d cards installed\n", card_cnt);
|
||||
return 0;
|
||||
|
||||
|
@ -1860,6 +1862,8 @@ hfcsmini_cleanup(void)
|
|||
{
|
||||
int err;
|
||||
|
||||
mISDN_module_unregister(THIS_MODULE);
|
||||
|
||||
#if HFCBRIDGE == BRIDGE_HFCPCI
|
||||
pci_unregister_driver(&hfcsmini_driver);
|
||||
#endif
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include <linux/module.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/usb.h>
|
||||
#include "core.h"
|
||||
#include "channel.h"
|
||||
#include "layer1.h"
|
||||
#include "debug.h"
|
||||
|
@ -2163,6 +2164,9 @@ hfcsusb_init(void)
|
|||
"hfcsusb: Unable to register hfcsusb module at usb stack\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
mISDN_module_register(THIS_MODULE);
|
||||
|
||||
return 0;
|
||||
|
||||
out:
|
||||
|
@ -2176,6 +2180,8 @@ hfcsusb_cleanup(void)
|
|||
int err;
|
||||
hfcsusb_t *card, *next;
|
||||
|
||||
mISDN_module_unregister(THIS_MODULE);
|
||||
|
||||
if (debug & 0x10000)
|
||||
printk(KERN_DEBUG "%s\n", __FUNCTION__);
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include "core.h"
|
||||
#include "channel.h"
|
||||
#include "isac.h"
|
||||
#include "arcofi.h"
|
||||
|
@ -823,11 +824,13 @@ mISDN_clear_isac(channel_t *dch)
|
|||
static int isac_mod_init(void)
|
||||
{
|
||||
printk(KERN_INFO "ISAC module %s\n", isac_revision);
|
||||
mISDN_module_register(THIS_MODULE);
|
||||
return(0);
|
||||
}
|
||||
|
||||
static void isac_mod_cleanup(void)
|
||||
{
|
||||
mISDN_module_unregister(THIS_MODULE);
|
||||
printk(KERN_INFO "ISAC module unloaded\n");
|
||||
}
|
||||
module_init(isac_mod_init);
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
|
||||
#include <linux/module.h>
|
||||
|
||||
#include "core.h"
|
||||
#include "layer3.h"
|
||||
#include "helper.h"
|
||||
#include "debug.h"
|
||||
|
@ -3111,7 +3112,8 @@ int UDSS1Init(void)
|
|||
if ((err = mISDN_register(&u_dss1))) {
|
||||
printk(KERN_ERR "Can't register %s error(%d)\n", MName, err);
|
||||
mISDNl3Free();
|
||||
}
|
||||
} else
|
||||
mISDN_module_register(THIS_MODULE);
|
||||
return(err);
|
||||
}
|
||||
|
||||
|
@ -3121,6 +3123,8 @@ void UDSS1_cleanup(void)
|
|||
int err;
|
||||
layer3_t *l3, *next;
|
||||
|
||||
mISDN_module_unregister(THIS_MODULE);
|
||||
|
||||
if ((err = mISDN_unregister(&u_dss1))) {
|
||||
printk(KERN_ERR "Can't unregister User DSS1 error(%d)\n", err);
|
||||
}
|
||||
|
|
|
@ -12,6 +12,7 @@ static char *l1_revision = "$Revision$";
|
|||
|
||||
#include <linux/config.h>
|
||||
#include <linux/module.h>
|
||||
#include "core.h"
|
||||
#include "layer1.h"
|
||||
#include "helper.h"
|
||||
#include "debug.h"
|
||||
|
@ -852,7 +853,8 @@ int Isdnl1Init(void)
|
|||
#ifdef OBSOLETE
|
||||
mISDN_FsmFree(&l1fsm_b);
|
||||
#endif
|
||||
}
|
||||
} else
|
||||
mISDN_module_register(THIS_MODULE);
|
||||
return(err);
|
||||
}
|
||||
|
||||
|
@ -862,6 +864,8 @@ void cleanup_module(void)
|
|||
int err;
|
||||
layer1_t *l1, *nl1;
|
||||
|
||||
mISDN_module_unregister(THIS_MODULE);
|
||||
|
||||
if ((err = mISDN_unregister(&isdnl1))) {
|
||||
printk(KERN_ERR "Can't unregister ISDN layer 1 error(%d)\n", err);
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*
|
||||
*/
|
||||
#include <linux/module.h>
|
||||
#include "core.h"
|
||||
#include "layer2.h"
|
||||
#include "helper.h"
|
||||
#include "debug.h"
|
||||
|
@ -2529,7 +2530,8 @@ int Isdnl2_Init(void)
|
|||
if ((err = mISDN_register(&isdnl2))) {
|
||||
printk(KERN_ERR "Can't register %s error(%d)\n", MName, err);
|
||||
mISDN_FsmFree(&l2fsm);
|
||||
}
|
||||
} else
|
||||
mISDN_module_register(THIS_MODULE);
|
||||
return(err);
|
||||
}
|
||||
|
||||
|
@ -2538,6 +2540,8 @@ void Isdnl2_cleanup(void)
|
|||
int err;
|
||||
layer2_t *l2, *nl2;
|
||||
|
||||
mISDN_module_unregister(THIS_MODULE);
|
||||
|
||||
if ((err = mISDN_unregister(&isdnl2))) {
|
||||
printk(KERN_ERR "Can't unregister ISDN layer 2 error(%d)\n", err);
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include <linux/module.h>
|
||||
#include <linux/pci.h>
|
||||
#include <linux/delay.h>
|
||||
#include "core.h"
|
||||
#include "channel.h"
|
||||
#include "isac.h"
|
||||
#include "layer1.h"
|
||||
|
@ -1801,6 +1802,8 @@ static int __init nj_init (void)
|
|||
err = pci_register_driver (&nj_pci_driver);
|
||||
if (err < 0)
|
||||
return err;
|
||||
|
||||
mISDN_module_register(THIS_MODULE);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -1811,6 +1814,8 @@ static void __exit nj_cleanup (void)
|
|||
int err;
|
||||
netjet_t *card, *next;
|
||||
|
||||
mISDN_module_unregister(THIS_MODULE);
|
||||
|
||||
if ((err = mISDN_unregister (&netjet_mISDN))) {
|
||||
printk(KERN_ERR "Can't unregister NETJet PCI error(%d)\n", err);
|
||||
}
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#else
|
||||
#include <linux/isapnp.h>
|
||||
#endif
|
||||
#include "core.h"
|
||||
#include "channel.h"
|
||||
#include "isac.h"
|
||||
#include "isar.h"
|
||||
|
@ -929,6 +930,9 @@ static int __init Speedfax_init(void)
|
|||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
mISDN_module_register(THIS_MODULE);
|
||||
|
||||
return 0;
|
||||
|
||||
#ifdef OLD_PCI_REGISTER_DRIVER
|
||||
|
@ -952,6 +956,8 @@ static void __exit Speedfax_cleanup(void)
|
|||
int err;
|
||||
sedl_fax *card, *next;
|
||||
|
||||
mISDN_module_unregister(THIS_MODULE);
|
||||
|
||||
if ((err = mISDN_unregister(&speedfax))) {
|
||||
printk(KERN_ERR "Can't unregister Speedfax PCI error(%d)\n", err);
|
||||
}
|
||||
|
|
|
@ -1556,6 +1556,9 @@ mISDN_open(struct inode *ino, struct file *filep)
|
|||
filep->private_data = dev;
|
||||
if (device_debug & DEBUG_DEV_OP)
|
||||
printk(KERN_DEBUG "mISDN_open out: %p %p\n", filep, filep->private_data);
|
||||
|
||||
mISDN_inc_usage();
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
@ -1585,10 +1588,12 @@ mISDN_close(struct inode *ino, struct file *filep)
|
|||
filep->private_data = NULL;
|
||||
if (!dev->minor)
|
||||
free_device(dev);
|
||||
mISDN_dec_usage();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
read_unlock(&mISDN_device_lock);
|
||||
mISDN_dec_usage();
|
||||
printk(KERN_WARNING "mISDN: No private data while closing device\n");
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include <linux/pci.h>
|
||||
#include <linux/delay.h>
|
||||
|
||||
#include "core.h"
|
||||
#include "channel.h"
|
||||
#include "layer1.h"
|
||||
#include "helper.h"
|
||||
|
@ -1589,6 +1590,9 @@ static int __init w6692_init(void)
|
|||
goto out;
|
||||
}
|
||||
#endif
|
||||
|
||||
mISDN_module_register(THIS_MODULE);
|
||||
|
||||
return 0;
|
||||
|
||||
out:
|
||||
|
@ -1601,6 +1605,8 @@ static void __exit w6692_cleanup(void)
|
|||
int err;
|
||||
w6692pci *card, *next;
|
||||
|
||||
mISDN_module_unregister(THIS_MODULE);
|
||||
|
||||
if ((err = mISDN_unregister(&w6692))) {
|
||||
printk(KERN_ERR "Can't unregister Winbond W6692 PCI error(%d)\n", err);
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include <linux/config.h>
|
||||
#include <linux/module.h>
|
||||
#include "core.h"
|
||||
#include "x25_l3.h"
|
||||
#include "helper.h"
|
||||
#include "debug.h"
|
||||
|
@ -1369,6 +1370,7 @@ x25_dte_init(void)
|
|||
dte_dfsm.strEvent = X25strDEvent;
|
||||
dte_dfsm.strState = X25strDState;
|
||||
mISDN_FsmNew(&dte_dfsm, DFnList, D_FN_COUNT);
|
||||
mISDN_module_register(THIS_MODULE);
|
||||
}
|
||||
return(err);
|
||||
}
|
||||
|
@ -1379,6 +1381,8 @@ x25_dte_cleanup(void)
|
|||
x25_l3_t *l3, *nl3;
|
||||
int err;
|
||||
|
||||
mISDN_module_unregister(THIS_MODULE);
|
||||
|
||||
if ((err = mISDN_unregister(&x25dte_obj))) {
|
||||
printk(KERN_ERR "Can't unregister l3x25 error(%d)\n", err);
|
||||
}
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
#include <linux/delay.h>
|
||||
#include <linux/pci.h>
|
||||
#include <asm/timex.h>
|
||||
#include "core.h"
|
||||
#include "helper.h"
|
||||
#include "debug.h"
|
||||
#include "xhfc_su.h"
|
||||
|
@ -2153,6 +2154,8 @@ xhfc_init(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
mISDN_module_register(THIS_MODULE);
|
||||
|
||||
return 0;
|
||||
|
||||
out:
|
||||
|
@ -2164,6 +2167,8 @@ xhfc_cleanup(void)
|
|||
{
|
||||
int err;
|
||||
|
||||
mISDN_module_unregister(THIS_MODULE);
|
||||
|
||||
#if BRIDGE == BRIDGE_PCI2PI
|
||||
pci_unregister_driver(&xhfc_driver);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue