summaryrefslogtreecommitdiff
path: root/drivers/dahdi/dahdi_dynamic.c
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2011-01-03 18:25:56 +0000
committerShaun Ruffell <sruffell@digium.com>2011-01-03 18:25:56 +0000
commit0c409bba72005ca55ee5ed602e0f81d856bfe352 (patch)
tree55b30899788c0ac82b63e9834838b36a012e9db0 /drivers/dahdi/dahdi_dynamic.c
parent1ff6b6647aad596eb794c145e12972ba4865bdcc (diff)
dahdi_dynamic: Pass the dahdi_dynamic to create/destroy functions.
This allows the pvt member to be set under lock without holding the lock through the call to create destroy. 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@9578 a0bf4364-ded3-4de4-8d8a-66a801d63aff
Diffstat (limited to 'drivers/dahdi/dahdi_dynamic.c')
-rw-r--r--drivers/dahdi/dahdi_dynamic.c38
1 files changed, 8 insertions, 30 deletions
diff --git a/drivers/dahdi/dahdi_dynamic.c b/drivers/dahdi/dahdi_dynamic.c
index 879ce3a..1162c43 100644
--- a/drivers/dahdi/dahdi_dynamic.c
+++ b/drivers/dahdi/dahdi_dynamic.c
@@ -68,9 +68,6 @@
before moving to the next.
*/
-/* Arbitrary limit to the max # of channels in a span */
-#define DAHDI_DYNAMIC_MAX_CHANS 256
-
#define DAHDI_DYNAMIC_FLAG_YELLOW_ALARM (1 << 0)
#define DAHDI_DYNAMIC_FLAG_SIGBITS_PRESENT (1 << 1)
#define DAHDI_DYNAMIC_FLAG_LOOPBACK (1 << 2)
@@ -93,25 +90,6 @@ static struct tasklet_struct dahdi_dynamic_tlet;
static void dahdi_dynamic_tasklet(unsigned long data);
#endif
-struct dahdi_dynamic {
- char addr[40];
- char dname[20];
- int err;
- struct kref kref;
- long rxjif;
- unsigned short txcnt;
- unsigned short rxcnt;
- struct dahdi_span span;
- struct dahdi_chan *chans[DAHDI_DYNAMIC_MAX_CHANS];
- struct dahdi_dynamic_driver *driver;
- void *pvt;
- int timing;
- int master;
- unsigned char *msgbuf;
-
- struct list_head list;
-};
-
static DEFINE_SPINLOCK(dspan_lock);
static DEFINE_SPINLOCK(driver_lock);
@@ -213,7 +191,7 @@ static void dahdi_dynamic_sendmessage(struct dahdi_dynamic *d)
msglen += DAHDI_CHUNKSIZE;
}
- d->driver->transmit(d->pvt, d->msgbuf, msglen);
+ d->driver->transmit(d, d->msgbuf, msglen);
}
@@ -413,7 +391,7 @@ static void dahdi_dynamic_release(struct kref *kref)
if (d->pvt) {
if (d->driver && d->driver->destroy) {
__module_get(d->driver->owner);
- d->driver->destroy(d->pvt);
+ d->driver->destroy(d);
module_put(d->driver->owner);
} else {
WARN_ON(1);
@@ -565,6 +543,7 @@ static const struct dahdi_span_ops dynamic_ops = {
static int create_dynamic(struct dahdi_dynamic_span *dds)
{
+ int res = 0;
struct dahdi_dynamic *d;
struct dahdi_dynamic_driver *dtd;
unsigned long flags;
@@ -576,7 +555,7 @@ static int create_dynamic(struct dahdi_dynamic_span *dds)
dds->numchans);
return -EINVAL;
}
- if (dds->numchans >= DAHDI_DYNAMIC_MAX_CHANS) {
+ if (dds->numchans >= ARRAY_SIZE(d->chans)) {
printk(KERN_NOTICE "Can't create dynamic span with greater "
"than %d channels. See dahdi_dynamic.c and increase "
"DAHDI_DYNAMIC_MAX_CHANS\n", dds->numchans);
@@ -662,13 +641,13 @@ static int create_dynamic(struct dahdi_dynamic_span *dds)
d->driver = dtd;
/* Create the stuff */
- d->pvt = d->driver->create(&d->span, d->addr);
- if (!d->pvt) {
+ res = dtd->create(d, d->addr);
+ if (res) {
printk(KERN_NOTICE "Driver '%s' (%s) rejected address '%s'\n",
dtd->name, dtd->desc, d->addr);
dynamic_put(d);
module_put(dtd->owner);
- return -EINVAL;
+ return res;
}
/* Whee! We're created. Now register the span */
@@ -766,9 +745,8 @@ void dahdi_dynamic_unregister_driver(struct dahdi_dynamic_driver *dri)
if (d->pvt) {
if (d->driver && d->driver->destroy) {
__module_get(d->driver->owner);
- d->driver->destroy(d->pvt);
+ d->driver->destroy(d);
module_put(d->driver->owner);
- d->pvt = NULL;
} else {
WARN_ON(1);
}