dahdi_dynamic_loc: Remove references to 'zaptel'
Hopefully will eliminate any questions about what the 'z's are supposed to represent. 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@9562 a0bf4364-ded3-4de4-8d8a-66a801d63aff
This commit is contained in:
parent
cf2c6ce98b
commit
29b0b48096
@ -57,31 +57,36 @@
|
|||||||
|
|
||||||
#include <dahdi/kernel.h>
|
#include <dahdi/kernel.h>
|
||||||
|
|
||||||
static DEFINE_SPINLOCK(zlock);
|
static DEFINE_SPINLOCK(local_lock);
|
||||||
|
|
||||||
static struct ztdlocal {
|
/**
|
||||||
|
* struct dahdi_dynamic_loc - For local dynamic spans
|
||||||
|
* @monitor_rx_peer: Indicates the peer span that monitors this span.
|
||||||
|
* @peer: Indicates the rw peer for this span.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
static struct dahdi_dynamic_local {
|
||||||
unsigned short key;
|
unsigned short key;
|
||||||
unsigned short id;
|
unsigned short id;
|
||||||
struct ztdlocal *monitor_rx_peer; /* Indicates the peer span that monitors this span */
|
struct dahdi_dynamic_local *monitor_rx_peer;
|
||||||
struct ztdlocal *peer; /* Indicates the rw peer for this span */
|
struct dahdi_dynamic_local *peer;
|
||||||
struct dahdi_span *span;
|
struct dahdi_span *span;
|
||||||
struct ztdlocal *next;
|
struct dahdi_dynamic_local *next;
|
||||||
} *zdevs = NULL;
|
} *ddevs = NULL;
|
||||||
|
|
||||||
static int ztdlocal_transmit(void *pvt, unsigned char *msg, int msglen)
|
static int
|
||||||
|
dahdi_dynamic_local_transmit(void *pvt, unsigned char *msg, int msglen)
|
||||||
{
|
{
|
||||||
struct ztdlocal *z;
|
struct dahdi_dynamic_local *d;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
spin_lock_irqsave(&zlock, flags);
|
spin_lock_irqsave(&local_lock, flags);
|
||||||
z = pvt;
|
d = pvt;
|
||||||
if (z->peer && z->peer->span) {
|
if (d->peer && d->peer->span)
|
||||||
dahdi_dynamic_receive(z->peer->span, msg, msglen);
|
dahdi_dynamic_receive(d->peer->span, msg, msglen);
|
||||||
}
|
if (d->monitor_rx_peer && d->monitor_rx_peer->span)
|
||||||
if (z->monitor_rx_peer && z->monitor_rx_peer->span) {
|
dahdi_dynamic_receive(d->monitor_rx_peer->span, msg, msglen);
|
||||||
dahdi_dynamic_receive(z->monitor_rx_peer->span, msg, msglen);
|
spin_unlock_irqrestore(&local_lock, flags);
|
||||||
}
|
|
||||||
spin_unlock_irqrestore(&zlock, flags);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,44 +122,45 @@ static int digit2int(char d)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void ztdlocal_destroy(void *pvt)
|
static void dahdi_dynamic_local_destroy(void *pvt)
|
||||||
{
|
{
|
||||||
struct ztdlocal *z = pvt;
|
struct dahdi_dynamic_local *d = pvt;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
struct ztdlocal *prev=NULL, *cur;
|
struct dahdi_dynamic_local *prev = NULL, *cur;
|
||||||
|
|
||||||
spin_lock_irqsave(&zlock, flags);
|
spin_lock_irqsave(&local_lock, flags);
|
||||||
cur = zdevs;
|
cur = ddevs;
|
||||||
while(cur) {
|
while(cur) {
|
||||||
if (cur->peer == z)
|
if (cur->peer == d)
|
||||||
cur->peer = NULL;
|
cur->peer = NULL;
|
||||||
if (cur->monitor_rx_peer == z)
|
if (cur->monitor_rx_peer == d)
|
||||||
cur->monitor_rx_peer = NULL;
|
cur->monitor_rx_peer = NULL;
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
cur = zdevs;
|
cur = ddevs;
|
||||||
while(cur) {
|
while(cur) {
|
||||||
if (cur == z) {
|
if (cur == d) {
|
||||||
if (prev)
|
if (prev)
|
||||||
prev->next = cur->next;
|
prev->next = cur->next;
|
||||||
else
|
else
|
||||||
zdevs = cur->next;
|
ddevs = cur->next;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
prev = cur;
|
prev = cur;
|
||||||
cur = cur->next;
|
cur = cur->next;
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&zlock, flags);
|
spin_unlock_irqrestore(&local_lock, flags);
|
||||||
if (cur == z) {
|
if (cur == d) {
|
||||||
printk(KERN_INFO "TDMoL: Removed interface for %s, key %d id %d\n", z->span->name, z->key, z->id);
|
printk(KERN_INFO "TDMoL: Removed interface for %s, key %d "
|
||||||
|
"id %d\n", d->span->name, d->key, d->id);
|
||||||
module_put(THIS_MODULE);
|
module_put(THIS_MODULE);
|
||||||
kfree(z);
|
kfree(d);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *ztdlocal_create(struct dahdi_span *span, char *address)
|
static void *dahdi_dynamic_local_create(struct dahdi_span *span, char *address)
|
||||||
{
|
{
|
||||||
struct ztdlocal *z, *l;
|
struct dahdi_dynamic_local *d, *l;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int key = -1, id = -1, monitor = -1;
|
int key = -1, id = -1, monitor = -1;
|
||||||
|
|
||||||
@ -173,61 +179,62 @@ static void *ztdlocal_create(struct dahdi_span *span, char *address)
|
|||||||
if (key == -1 || id == -1)
|
if (key == -1 || id == -1)
|
||||||
goto INVALID_ADDRESS;
|
goto INVALID_ADDRESS;
|
||||||
|
|
||||||
z = kmalloc(sizeof(struct ztdlocal), GFP_KERNEL);
|
d = kmalloc(sizeof(struct dahdi_dynamic_local), GFP_KERNEL);
|
||||||
if (z) {
|
if (d) {
|
||||||
/* Zero it out */
|
/* Zero it out */
|
||||||
memset(z, 0, sizeof(struct ztdlocal));
|
memset(d, 0, sizeof(struct dahdi_dynamic_local));
|
||||||
|
|
||||||
z->key = key;
|
d->key = key;
|
||||||
z->id = id;
|
d->id = id;
|
||||||
z->span = span;
|
d->span = span;
|
||||||
|
|
||||||
spin_lock_irqsave(&zlock, flags);
|
spin_lock_irqsave(&local_lock, flags);
|
||||||
/* Add this peer to any existing spans with same key
|
/* Add this peer to any existing spans with same key
|
||||||
And add them as peers to this one */
|
And add them as peers to this one */
|
||||||
for (l = zdevs; l; l = l->next)
|
for (l = ddevs; l; l = l->next)
|
||||||
if (l->key == z->key) {
|
if (l->key == d->key) {
|
||||||
if (l->id == z->id) {
|
if (l->id == d->id) {
|
||||||
printk(KERN_DEBUG "TDMoL: Duplicate id (%d) for key %d\n", z->id, z->key);
|
printk(KERN_DEBUG "TDMoL: Duplicate id (%d) for key %d\n", d->id, d->key);
|
||||||
goto CLEAR_AND_DEL_FROM_PEERS;
|
goto CLEAR_AND_DEL_FROM_PEERS;
|
||||||
}
|
}
|
||||||
if (monitor == -1) {
|
if (monitor == -1) {
|
||||||
if (l->peer) {
|
if (l->peer) {
|
||||||
printk(KERN_DEBUG "TDMoL: Span with key %d and id %d already has a R/W peer\n", z->key, z->id);
|
printk(KERN_DEBUG "TDMoL: Span with key %d and id %d already has a R/W peer\n", d->key, d->id);
|
||||||
goto CLEAR_AND_DEL_FROM_PEERS;
|
goto CLEAR_AND_DEL_FROM_PEERS;
|
||||||
} else {
|
} else {
|
||||||
l->peer = z;
|
l->peer = d;
|
||||||
z->peer = l;
|
d->peer = l;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (monitor == l->id) {
|
if (monitor == l->id) {
|
||||||
if (l->monitor_rx_peer) {
|
if (l->monitor_rx_peer) {
|
||||||
printk(KERN_DEBUG "TDMoL: Span with key %d and id %d already has a monitoring peer\n", z->key, z->id);
|
printk(KERN_DEBUG "TDMoL: Span with key %d and id %d already has a monitoring peer\n", d->key, d->id);
|
||||||
goto CLEAR_AND_DEL_FROM_PEERS;
|
goto CLEAR_AND_DEL_FROM_PEERS;
|
||||||
} else {
|
} else {
|
||||||
l->monitor_rx_peer = z;
|
l->monitor_rx_peer = d;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
z->next = zdevs;
|
d->next = ddevs;
|
||||||
zdevs = z;
|
ddevs = d;
|
||||||
spin_unlock_irqrestore(&zlock, flags);
|
spin_unlock_irqrestore(&local_lock, flags);
|
||||||
if(!try_module_get(THIS_MODULE))
|
if(!try_module_get(THIS_MODULE))
|
||||||
printk(KERN_DEBUG "TDMoL: Unable to increment module use count\n");
|
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, z->key, z->id);
|
printk(KERN_INFO "TDMoL: Added new interface for %s, "
|
||||||
|
"key %d id %d\n", span->name, d->key, d->id);
|
||||||
}
|
}
|
||||||
return z;
|
return d;
|
||||||
|
|
||||||
CLEAR_AND_DEL_FROM_PEERS:
|
CLEAR_AND_DEL_FROM_PEERS:
|
||||||
for (l = zdevs; l; l = l->next) {
|
for (l = ddevs; l; l = l->next) {
|
||||||
if (l->peer == z)
|
if (l->peer == d)
|
||||||
l->peer = NULL;
|
l->peer = NULL;
|
||||||
if (l->monitor_rx_peer == z)
|
if (l->monitor_rx_peer == d)
|
||||||
l->monitor_rx_peer = NULL;
|
l->monitor_rx_peer = NULL;
|
||||||
}
|
}
|
||||||
kfree (z);
|
kfree(d);
|
||||||
spin_unlock_irqrestore(&zlock, flags);
|
spin_unlock_irqrestore(&local_lock, flags);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
INVALID_ADDRESS:
|
INVALID_ADDRESS:
|
||||||
@ -235,27 +242,27 @@ INVALID_ADDRESS:
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dahdi_dynamic_driver ztd_local = {
|
static struct dahdi_dynamic_driver dahdi_dynamic_local = {
|
||||||
"loc",
|
"loc",
|
||||||
"Local",
|
"Local",
|
||||||
ztdlocal_create,
|
dahdi_dynamic_local_create,
|
||||||
ztdlocal_destroy,
|
dahdi_dynamic_local_destroy,
|
||||||
ztdlocal_transmit,
|
dahdi_dynamic_local_transmit,
|
||||||
NULL /* flush */
|
NULL /* flush */
|
||||||
};
|
};
|
||||||
|
|
||||||
static int __init ztdlocal_init(void)
|
static int __init dahdi_dynamic_local_init(void)
|
||||||
{
|
{
|
||||||
dahdi_dynamic_register(&ztd_local);
|
dahdi_dynamic_register(&dahdi_dynamic_local);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void __exit ztdlocal_exit(void)
|
static void __exit dahdi_dynamic_local_exit(void)
|
||||||
{
|
{
|
||||||
dahdi_dynamic_unregister(&ztd_local);
|
dahdi_dynamic_unregister(&dahdi_dynamic_local);
|
||||||
}
|
}
|
||||||
|
|
||||||
module_init(ztdlocal_init);
|
module_init(dahdi_dynamic_local_init);
|
||||||
module_exit(ztdlocal_exit);
|
module_exit(dahdi_dynamic_local_exit);
|
||||||
|
|
||||||
MODULE_LICENSE("GPL v2");
|
MODULE_LICENSE("GPL v2");
|
||||||
|
Loading…
Reference in New Issue
Block a user