summaryrefslogtreecommitdiff
path: root/drivers/dahdi/dahdi_dynamic_loc.c
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2011-01-03 18:25:32 +0000
committerShaun Ruffell <sruffell@digium.com>2011-01-03 18:25:32 +0000
commitd185d797c99be49d5c4228359c7e8a724f506048 (patch)
treec22f90f94aed8df0133bdafcbf1e3d051bc27490 /drivers/dahdi/dahdi_dynamic_loc.c
parent44213fdd12da2e4ae406a26562b26d6e8d8e8d00 (diff)
dahdi_dynamic: dynamic drivers should not reference count themselves.
Move the try_module_get/module_put calls from the various dynamic drivers into the "core" dahdi_dynamic.c file itself. This way, a reference count can always be held while calling through the function pointers. This is enabled by adding an .owner field to 'struct dahdi_dynamic_driver'. Dynamic spans are also unique in dahdi in that they require a "dahdi_cfg -s" to stop them and release the references on the modules. This is counterintuitive. This change makes sure they are reference counted just like other spans and on driver unload, if there aren't any open handles from userspace, they will take care of unwinding themselves. Signed-off-by: Shaun Ruffell <sruffell@digium.com> Acked-by: Kinsey Moore <kmoore@digium.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/linux/trunk@9573 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/dahdi_dynamic_loc.c')
-rw-r--r--drivers/dahdi/dahdi_dynamic_loc.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/dahdi/dahdi_dynamic_loc.c b/drivers/dahdi/dahdi_dynamic_loc.c
index 72c8162..91d0289 100644
--- a/drivers/dahdi/dahdi_dynamic_loc.c
+++ b/drivers/dahdi/dahdi_dynamic_loc.c
@@ -146,7 +146,6 @@ static void dahdi_dynamic_local_destroy(void *pvt)
printk(KERN_INFO "TDMoL: Removed interface for %s, key %d "
"id %d\n", d->span->name, d->key, d->id);
- module_put(THIS_MODULE);
kfree(d);
}
@@ -216,9 +215,6 @@ static void *dahdi_dynamic_local_create(struct dahdi_span *span, char *address)
list_add(&d->node, &dynamic_local_list);
spin_unlock_irqrestore(&local_lock, flags);
- if (!try_module_get(THIS_MODULE))
- printk(KERN_DEBUG "TDMoL: Unable to increment module use count\n");
-
printk(KERN_INFO "TDMoL: Added new interface for %s, "
"key %d id %d\n", span->name, d->key, d->id);
return d;
@@ -240,12 +236,12 @@ INVALID_ADDRESS:
}
static struct dahdi_dynamic_driver dahdi_dynamic_local = {
- "loc",
- "Local",
- dahdi_dynamic_local_create,
- dahdi_dynamic_local_destroy,
- dahdi_dynamic_local_transmit,
- NULL /* flush */
+ .owner = THIS_MODULE,
+ .name = "loc",
+ .desc = "Local",
+ .create = dahdi_dynamic_local_create,
+ .destroy = dahdi_dynamic_local_destroy,
+ .transmit = dahdi_dynamic_local_transmit,
};
static int __init dahdi_dynamic_local_init(void)