summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaun Ruffell <sruffell@digium.com>2011-01-03 18:26:43 +0000
committerShaun Ruffell <sruffell@digium.com>2011-01-03 18:26:43 +0000
commit08f331c798d22f964ee6c4699015499fdd361b96 (patch)
tree798585b0e806a928d059cbd421e67d3b6d5fee77
parent2a951fd6a326df6058940cddc82f72435bfd7b2a (diff)
dahdi: Use a spinlock instead of a rwlock for 'zone_lock'
rwlocks are deprecated and there aren't that many places where read_lock was called on the lock anyway. 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@9588 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r--drivers/dahdi/dahdi-base.c28
1 files changed, 12 insertions, 16 deletions
diff --git a/drivers/dahdi/dahdi-base.c b/drivers/dahdi/dahdi-base.c
index f1b6ff2..9de65fe 100644
--- a/drivers/dahdi/dahdi-base.c
+++ b/drivers/dahdi/dahdi-base.c
@@ -375,11 +375,7 @@ struct dahdi_zone {
struct dahdi_tone mfr2_rev_continuous[16]; /* MFR2 REV tones for this zone, continuous play */
};
-#ifdef DEFINE_RWLOCK
-static DEFINE_RWLOCK(zone_lock);
-#else
-static rwlock_t zone_lock = RW_LOCK_UNLOCKED;
-#endif
+static DEFINE_SPINLOCK(zone_lock);
static DEFINE_SPINLOCK(chan_lock);
@@ -1384,7 +1380,7 @@ static int free_tone_zone(int num)
if ((num >= DAHDI_TONE_ZONE_MAX) || (num < 0))
return -EINVAL;
- write_lock(&zone_lock);
+ spin_lock(&zone_lock);
if (tone_zones[num]) {
if (!atomic_read(&tone_zones[num]->refcount)) {
z = tone_zones[num];
@@ -1393,7 +1389,7 @@ static int free_tone_zone(int num)
res = -EBUSY;
}
}
- write_unlock(&zone_lock);
+ spin_unlock(&zone_lock);
if (z)
kfree(z);
@@ -1408,14 +1404,14 @@ static int dahdi_register_tone_zone(int num, struct dahdi_zone *zone)
if ((num >= DAHDI_TONE_ZONE_MAX) || (num < 0))
return -EINVAL;
- write_lock(&zone_lock);
+ spin_lock(&zone_lock);
if (tone_zones[num]) {
res = -EINVAL;
} else {
res = 0;
tone_zones[num] = zone;
}
- write_unlock(&zone_lock);
+ spin_unlock(&zone_lock);
if (!res)
module_printk(KERN_INFO, "Registered tone zone %d (%s)\n", num, zone->name);
@@ -1532,7 +1528,7 @@ static int set_tone_zone(struct dahdi_chan *chan, int zone)
if ((zone >= DAHDI_TONE_ZONE_MAX) || (zone < 0))
return -EINVAL;
- read_lock(&zone_lock);
+ spin_lock(&zone_lock);
if ((z = tone_zones[zone])) {
unsigned long flags;
@@ -1552,7 +1548,7 @@ static int set_tone_zone(struct dahdi_chan *chan, int zone)
res = -ENODATA;
}
- read_unlock(&zone_lock);
+ spin_unlock(&zone_lock);
return res;
}
@@ -2963,16 +2959,16 @@ static int dahdi_set_default_zone(int defzone)
{
if ((defzone < 0) || (defzone >= DAHDI_TONE_ZONE_MAX))
return -EINVAL;
- write_lock(&zone_lock);
+ spin_lock(&zone_lock);
if (!tone_zones[defzone]) {
- write_unlock(&zone_lock);
+ spin_unlock(&zone_lock);
return -EINVAL;
}
if ((default_zone != -1) && tone_zones[default_zone])
atomic_dec(&tone_zones[default_zone]->refcount);
atomic_inc(&tone_zones[defzone]->refcount);
default_zone = defzone;
- write_unlock(&zone_lock);
+ spin_unlock(&zone_lock);
return 0;
}
@@ -4596,7 +4592,7 @@ static int dahdi_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long da
}
/* update the lengths in all currently loaded zones */
- write_lock(&zone_lock);
+ spin_lock(&zone_lock);
for (j = 0; j < ARRAY_SIZE(tone_zones); j++) {
struct dahdi_zone *z = tone_zones[j];
@@ -4620,7 +4616,7 @@ static int dahdi_ctl_ioctl(struct file *file, unsigned int cmd, unsigned long da
z->mfr2_rev[i].tonesamples = global_dialparams.mfr2_tonelen * DAHDI_CHUNKSIZE;
}
}
- write_unlock(&zone_lock);
+ spin_unlock(&zone_lock);
dtmf_silence.tonesamples = global_dialparams.dtmf_tonelen * DAHDI_CHUNKSIZE;
mfr1_silence.tonesamples = global_dialparams.mfv1_tonelen * DAHDI_CHUNKSIZE;