diff options
author | Shaun Ruffell <sruffell@digium.com> | 2011-01-03 18:25:56 +0000 |
---|---|---|
committer | Shaun Ruffell <sruffell@digium.com> | 2011-01-03 18:25:56 +0000 |
commit | 217c8f524c98befd2b13e2f3ec7cb8cdcf5ff5ff (patch) | |
tree | 55b30899788c0ac82b63e9834838b36a012e9db0 /drivers/dahdi/dahdi_dynamic_loc.c | |
parent | d7d5fbd8c1f1b2bf8361e23d07708fb96079b353 (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_loc.c')
-rw-r--r-- | drivers/dahdi/dahdi_dynamic_loc.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/drivers/dahdi/dahdi_dynamic_loc.c b/drivers/dahdi/dahdi_dynamic_loc.c index 1f35bd1..6337780 100644 --- a/drivers/dahdi/dahdi_dynamic_loc.c +++ b/drivers/dahdi/dahdi_dynamic_loc.c @@ -76,17 +76,17 @@ static DEFINE_SPINLOCK(local_lock); static LIST_HEAD(dynamic_local_list); static void -dahdi_dynamic_local_transmit(void *pvt, unsigned char *msg, int msglen) +dahdi_dynamic_local_transmit(struct dahdi_dynamic *dyn, u8 *msg, size_t msglen) { - struct dahdi_dynamic_local *const d = pvt; + struct dahdi_dynamic_local *const d = dyn->pvt; unsigned long flags; spin_lock_irqsave(&local_lock, flags); - if (d->peer && d->peer->span) { + if (d && d->peer && d->peer->span) { if (test_bit(DAHDI_FLAGBIT_REGISTERED, &d->peer->span->flags)) dahdi_dynamic_receive(d->peer->span, msg, msglen); } - if (d->monitor_rx_peer && d->monitor_rx_peer->span) { + if (d && d->monitor_rx_peer && d->monitor_rx_peer->span) { if (test_bit(DAHDI_FLAGBIT_REGISTERED, &d->monitor_rx_peer->span->flags)) { dahdi_dynamic_receive(d->monitor_rx_peer->span, @@ -128,9 +128,9 @@ static int digit2int(char d) return -1; } -static void dahdi_dynamic_local_destroy(void *pvt) +static void dahdi_dynamic_local_destroy(struct dahdi_dynamic *dyn) { - struct dahdi_dynamic_local *d = pvt; + struct dahdi_dynamic_local *d = dyn->pvt; unsigned long flags; struct dahdi_dynamic_local *cur; @@ -142,6 +142,7 @@ static void dahdi_dynamic_local_destroy(void *pvt) cur->monitor_rx_peer = NULL; } list_del(&d->node); + dyn->pvt = NULL; spin_unlock_irqrestore(&local_lock, flags); printk(KERN_INFO "TDMoL: Removed interface for %s, key %d " @@ -149,12 +150,13 @@ static void dahdi_dynamic_local_destroy(void *pvt) kfree(d); } -static void *dahdi_dynamic_local_create(struct dahdi_span *span, - const char *address) +static int dahdi_dynamic_local_create(struct dahdi_dynamic *dyn, + const char *address) { struct dahdi_dynamic_local *d, *l; unsigned long flags; int key = -1, id = -1, monitor = -1; + struct dahdi_span *const span = &dyn->span; if (strlen(address) >= 3) { if (address[1] != ':') @@ -173,7 +175,7 @@ static void *dahdi_dynamic_local_create(struct dahdi_span *span, d = kzalloc(sizeof(*d), GFP_KERNEL); if (!d) - return NULL; + return -ENOMEM; d->key = key; d->id = id; @@ -214,11 +216,12 @@ static void *dahdi_dynamic_local_create(struct dahdi_span *span, } } list_add(&d->node, &dynamic_local_list); + dyn->pvt = d; spin_unlock_irqrestore(&local_lock, flags); printk(KERN_INFO "TDMoL: Added new interface for %s, " "key %d id %d\n", span->name, d->key, d->id); - return d; + return 0; CLEAR_AND_DEL_FROM_PEERS: list_for_each_entry(l, &dynamic_local_list, node) { @@ -229,11 +232,11 @@ CLEAR_AND_DEL_FROM_PEERS: } kfree(d); spin_unlock_irqrestore(&local_lock, flags); - return NULL; + return -EINVAL; INVALID_ADDRESS: printk (KERN_NOTICE "TDMoL: Invalid address %s\n", address); - return NULL; + return -EINVAL; } static struct dahdi_dynamic_driver dahdi_dynamic_local = { |