summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--zaptel.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/zaptel.c b/zaptel.c
index df920de..3d0ae85 100644
--- a/zaptel.c
+++ b/zaptel.c
@@ -2347,8 +2347,10 @@ static int zt_specchan_open(struct inode *inode, struct file *file, int unit, in
else if ((chans[unit]->sig & __ZT_SIG_DACS) == __ZT_SIG_DACS)
res = -EBUSY;
else {
+ unsigned long flags;
/* Assume everything is going to be okay */
res = initialize_channel(chans[unit]);
+ spin_lock_irqsave(&chans[unit]->lock, flags);
if (chans[unit]->flags & ZT_FLAG_PSEUDO)
chans[unit]->flags |= ZT_FLAG_AUDIO;
if (chans[unit]->span && chans[unit]->span->open)
@@ -2360,7 +2362,9 @@ static int zt_specchan_open(struct inode *inode, struct file *file, int unit, in
MOD_INC_USE_COUNT;
#endif
chans[unit]->flags |= ZT_FLAG_OPEN;
+ spin_unlock_irqrestore(&chans[unit]->lock, flags);
} else {
+ spin_unlock_irqrestore(&chans[unit]->lock, flags);
close_channel(chans[unit]);
}
}
@@ -2373,7 +2377,10 @@ static int zt_specchan_release(struct inode *node, struct file *file, int unit)
{
int res=0;
if (chans[unit]) {
+ unsigned long flags;
+ spin_lock_irqsave(&chans[unit]->lock, flags);
chans[unit]->flags &= ~ZT_FLAG_OPEN;
+ spin_unlock_irqrestore(&chans[unit]->lock, flags);
chans[unit]->file = NULL;
close_channel(chans[unit]);
if (chans[unit]->span && chans[unit]->span->close)