Commit 078d3965 authored by Amol Lad's avatar Amol Lad Committed by Linus Torvalds

[PATCH] drivers/isdn/isdnloop: save_flags()/cli(), restore_flags() replaced appropriately

Signed-off-by: default avatarAmol Lad <amol@verismonetworks.com>
Acked-by: default avatarKarsten Keil <kkeil@suse.de>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 0d9ba869
...@@ -100,12 +100,11 @@ isdnloop_pollbchan(unsigned long data) ...@@ -100,12 +100,11 @@ isdnloop_pollbchan(unsigned long data)
isdnloop_bchan_send(card, 1); isdnloop_bchan_send(card, 1);
if (card->flags & (ISDNLOOP_FLAGS_B1ACTIVE | ISDNLOOP_FLAGS_B2ACTIVE)) { if (card->flags & (ISDNLOOP_FLAGS_B1ACTIVE | ISDNLOOP_FLAGS_B2ACTIVE)) {
/* schedule b-channel polling again */ /* schedule b-channel polling again */
save_flags(flags); spin_lock_irqsave(&card->isdnloop_lock, flags);
cli();
card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD; card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD;
add_timer(&card->rb_timer); add_timer(&card->rb_timer);
card->flags |= ISDNLOOP_FLAGS_RBTIMER; card->flags |= ISDNLOOP_FLAGS_RBTIMER;
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
} else } else
card->flags &= ~ISDNLOOP_FLAGS_RBTIMER; card->flags &= ~ISDNLOOP_FLAGS_RBTIMER;
} }
...@@ -281,8 +280,7 @@ isdnloop_putmsg(isdnloop_card * card, unsigned char c) ...@@ -281,8 +280,7 @@ isdnloop_putmsg(isdnloop_card * card, unsigned char c)
{ {
ulong flags; ulong flags;
save_flags(flags); spin_lock_irqsave(&card->isdnloop_lock, flags);
cli();
*card->msg_buf_write++ = (c == 0xff) ? '\n' : c; *card->msg_buf_write++ = (c == 0xff) ? '\n' : c;
if (card->msg_buf_write == card->msg_buf_read) { if (card->msg_buf_write == card->msg_buf_read) {
if (++card->msg_buf_read > card->msg_buf_end) if (++card->msg_buf_read > card->msg_buf_end)
...@@ -290,7 +288,7 @@ isdnloop_putmsg(isdnloop_card * card, unsigned char c) ...@@ -290,7 +288,7 @@ isdnloop_putmsg(isdnloop_card * card, unsigned char c)
} }
if (card->msg_buf_write > card->msg_buf_end) if (card->msg_buf_write > card->msg_buf_end)
card->msg_buf_write = card->msg_buf; card->msg_buf_write = card->msg_buf;
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
} }
/* /*
...@@ -372,21 +370,19 @@ isdnloop_polldchan(unsigned long data) ...@@ -372,21 +370,19 @@ isdnloop_polldchan(unsigned long data)
if (!(card->flags & ISDNLOOP_FLAGS_RBTIMER)) { if (!(card->flags & ISDNLOOP_FLAGS_RBTIMER)) {
/* schedule b-channel polling */ /* schedule b-channel polling */
card->flags |= ISDNLOOP_FLAGS_RBTIMER; card->flags |= ISDNLOOP_FLAGS_RBTIMER;
save_flags(flags); spin_lock_irqsave(&card->isdnloop_lock, flags);
cli();
del_timer(&card->rb_timer); del_timer(&card->rb_timer);
card->rb_timer.function = isdnloop_pollbchan; card->rb_timer.function = isdnloop_pollbchan;
card->rb_timer.data = (unsigned long) card; card->rb_timer.data = (unsigned long) card;
card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD; card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD;
add_timer(&card->rb_timer); add_timer(&card->rb_timer);
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
} }
/* schedule again */ /* schedule again */
save_flags(flags); spin_lock_irqsave(&card->isdnloop_lock, flags);
cli();
card->st_timer.expires = jiffies + ISDNLOOP_TIMER_DCREAD; card->st_timer.expires = jiffies + ISDNLOOP_TIMER_DCREAD;
add_timer(&card->st_timer); add_timer(&card->st_timer);
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
} }
/* /*
...@@ -416,8 +412,7 @@ isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card * card) ...@@ -416,8 +412,7 @@ isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card * card)
return 0; return 0;
if (card->sndcount[channel] > ISDNLOOP_MAX_SQUEUE) if (card->sndcount[channel] > ISDNLOOP_MAX_SQUEUE)
return 0; return 0;
save_flags(flags); spin_lock_irqsave(&card->isdnloop_lock, flags);
cli();
nskb = dev_alloc_skb(skb->len); nskb = dev_alloc_skb(skb->len);
if (nskb) { if (nskb) {
memcpy(skb_put(nskb, len), skb->data, len); memcpy(skb_put(nskb, len), skb->data, len);
...@@ -426,7 +421,7 @@ isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card * card) ...@@ -426,7 +421,7 @@ isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card * card)
} else } else
len = 0; len = 0;
card->sndcount[channel] += len; card->sndcount[channel] += len;
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
} }
return len; return len;
} }
...@@ -576,8 +571,7 @@ isdnloop_atimeout(isdnloop_card * card, int ch) ...@@ -576,8 +571,7 @@ isdnloop_atimeout(isdnloop_card * card, int ch)
unsigned long flags; unsigned long flags;
char buf[60]; char buf[60];
save_flags(flags); spin_lock_irqsave(&card->isdnloop_lock, flags);
cli();
if (card->rcard) { if (card->rcard) {
isdnloop_fake(card->rcard[ch], "DDIS_I", card->rch[ch] + 1); isdnloop_fake(card->rcard[ch], "DDIS_I", card->rch[ch] + 1);
card->rcard[ch]->rcard[card->rch[ch]] = NULL; card->rcard[ch]->rcard[card->rch[ch]] = NULL;
...@@ -587,7 +581,7 @@ isdnloop_atimeout(isdnloop_card * card, int ch) ...@@ -587,7 +581,7 @@ isdnloop_atimeout(isdnloop_card * card, int ch)
/* No user responding */ /* No user responding */
sprintf(buf, "CAU%s", isdnloop_unicause(card, 1, 3)); sprintf(buf, "CAU%s", isdnloop_unicause(card, 1, 3));
isdnloop_fake(card, buf, ch + 1); isdnloop_fake(card, buf, ch + 1);
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
} }
/* /*
...@@ -622,8 +616,7 @@ isdnloop_start_ctimer(isdnloop_card * card, int ch) ...@@ -622,8 +616,7 @@ isdnloop_start_ctimer(isdnloop_card * card, int ch)
{ {
unsigned long flags; unsigned long flags;
save_flags(flags); spin_lock_irqsave(&card->isdnloop_lock, flags);
cli();
init_timer(&card->c_timer[ch]); init_timer(&card->c_timer[ch]);
card->c_timer[ch].expires = jiffies + ISDNLOOP_TIMER_ALERTWAIT; card->c_timer[ch].expires = jiffies + ISDNLOOP_TIMER_ALERTWAIT;
if (ch) if (ch)
...@@ -632,7 +625,7 @@ isdnloop_start_ctimer(isdnloop_card * card, int ch) ...@@ -632,7 +625,7 @@ isdnloop_start_ctimer(isdnloop_card * card, int ch)
card->c_timer[ch].function = isdnloop_atimeout0; card->c_timer[ch].function = isdnloop_atimeout0;
card->c_timer[ch].data = (unsigned long) card; card->c_timer[ch].data = (unsigned long) card;
add_timer(&card->c_timer[ch]); add_timer(&card->c_timer[ch]);
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
} }
/* /*
...@@ -647,10 +640,9 @@ isdnloop_kill_ctimer(isdnloop_card * card, int ch) ...@@ -647,10 +640,9 @@ isdnloop_kill_ctimer(isdnloop_card * card, int ch)
{ {
unsigned long flags; unsigned long flags;
save_flags(flags); spin_lock_irqsave(&card->isdnloop_lock, flags);
cli();
del_timer(&card->c_timer[ch]); del_timer(&card->c_timer[ch]);
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
} }
static u_char si2bit[] = static u_char si2bit[] =
...@@ -706,13 +698,12 @@ isdnloop_try_call(isdnloop_card * card, char *p, int lch, isdn_ctrl * cmd) ...@@ -706,13 +698,12 @@ isdnloop_try_call(isdnloop_card * card, char *p, int lch, isdn_ctrl * cmd)
} }
} }
if (num_match) { if (num_match) {
save_flags(flags); spin_lock_irqsave(&card->isdnloop_lock, flags);
cli();
/* channel idle? */ /* channel idle? */
if (!(cc->rcard[ch])) { if (!(cc->rcard[ch])) {
/* Check SI */ /* Check SI */
if (!(si2bit[cmd->parm.setup.si1] & cc->sil[ch])) { if (!(si2bit[cmd->parm.setup.si1] & cc->sil[ch])) {
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
return 3; return 3;
} }
/* ch is idle, si and number matches */ /* ch is idle, si and number matches */
...@@ -720,10 +711,10 @@ isdnloop_try_call(isdnloop_card * card, char *p, int lch, isdn_ctrl * cmd) ...@@ -720,10 +711,10 @@ isdnloop_try_call(isdnloop_card * card, char *p, int lch, isdn_ctrl * cmd)
cc->rch[ch] = lch; cc->rch[ch] = lch;
card->rcard[lch] = cc; card->rcard[lch] = cc;
card->rch[lch] = ch; card->rch[lch] = ch;
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
return 0; return 0;
} else { } else {
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
/* num matches, but busy */ /* num matches, but busy */
if (ch == 1) if (ch == 1)
return 1; return 1;
...@@ -1027,8 +1018,7 @@ isdnloop_stopcard(isdnloop_card * card) ...@@ -1027,8 +1018,7 @@ isdnloop_stopcard(isdnloop_card * card)
unsigned long flags; unsigned long flags;
isdn_ctrl cmd; isdn_ctrl cmd;
save_flags(flags); spin_lock_irqsave(&card->isdnloop_lock, flags);
cli();
if (card->flags & ISDNLOOP_FLAGS_RUNNING) { if (card->flags & ISDNLOOP_FLAGS_RUNNING) {
card->flags &= ~ISDNLOOP_FLAGS_RUNNING; card->flags &= ~ISDNLOOP_FLAGS_RUNNING;
del_timer(&card->st_timer); del_timer(&card->st_timer);
...@@ -1039,7 +1029,7 @@ isdnloop_stopcard(isdnloop_card * card) ...@@ -1039,7 +1029,7 @@ isdnloop_stopcard(isdnloop_card * card)
cmd.driver = card->myid; cmd.driver = card->myid;
card->interface.statcallb(&cmd); card->interface.statcallb(&cmd);
} }
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
} }
/* /*
...@@ -1078,18 +1068,17 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp) ...@@ -1078,18 +1068,17 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
return -EBUSY; return -EBUSY;
if (copy_from_user((char *) &sdef, (char *) sdefp, sizeof(sdef))) if (copy_from_user((char *) &sdef, (char *) sdefp, sizeof(sdef)))
return -EFAULT; return -EFAULT;
save_flags(flags); spin_lock_irqsave(&card->isdnloop_lock, flags);
cli();
switch (sdef.ptype) { switch (sdef.ptype) {
case ISDN_PTYPE_EURO: case ISDN_PTYPE_EURO:
if (isdnloop_fake(card, "DRV1.23EC-Q.931-CAPI-CNS-BASIS-20.02.96", if (isdnloop_fake(card, "DRV1.23EC-Q.931-CAPI-CNS-BASIS-20.02.96",
-1)) { -1)) {
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
return -ENOMEM; return -ENOMEM;
} }
card->sil[0] = card->sil[1] = 4; card->sil[0] = card->sil[1] = 4;
if (isdnloop_fake(card, "TEI OK", 0)) { if (isdnloop_fake(card, "TEI OK", 0)) {
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
return -ENOMEM; return -ENOMEM;
} }
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
...@@ -1098,12 +1087,12 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp) ...@@ -1098,12 +1087,12 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
case ISDN_PTYPE_1TR6: case ISDN_PTYPE_1TR6:
if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95", if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95",
-1)) { -1)) {
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
return -ENOMEM; return -ENOMEM;
} }
card->sil[0] = card->sil[1] = 4; card->sil[0] = card->sil[1] = 4;
if (isdnloop_fake(card, "TEI OK", 0)) { if (isdnloop_fake(card, "TEI OK", 0)) {
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
return -ENOMEM; return -ENOMEM;
} }
strcpy(card->s0num[0], sdef.num[0]); strcpy(card->s0num[0], sdef.num[0]);
...@@ -1111,7 +1100,7 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp) ...@@ -1111,7 +1100,7 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
card->s0num[2][0] = '\0'; card->s0num[2][0] = '\0';
break; break;
default: default:
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
printk(KERN_WARNING "isdnloop: Illegal D-channel protocol %d\n", printk(KERN_WARNING "isdnloop: Illegal D-channel protocol %d\n",
sdef.ptype); sdef.ptype);
return -EINVAL; return -EINVAL;
...@@ -1122,7 +1111,7 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp) ...@@ -1122,7 +1111,7 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
card->st_timer.data = (unsigned long) card; card->st_timer.data = (unsigned long) card;
add_timer(&card->st_timer); add_timer(&card->st_timer);
card->flags |= ISDNLOOP_FLAGS_RUNNING; card->flags |= ISDNLOOP_FLAGS_RUNNING;
restore_flags(flags); spin_unlock_irqrestore(&card->isdnloop_lock, flags);
return 0; return 0;
} }
...@@ -1472,6 +1461,7 @@ isdnloop_initcard(char *id) ...@@ -1472,6 +1461,7 @@ isdnloop_initcard(char *id)
skb_queue_head_init(&card->bqueue[i]); skb_queue_head_init(&card->bqueue[i]);
} }
skb_queue_head_init(&card->dqueue); skb_queue_head_init(&card->dqueue);
card->isdnloop_lock = SPIN_LOCK_UNLOCKED;
card->next = cards; card->next = cards;
cards = card; cards = card;
if (!register_isdn(&card->interface)) { if (!register_isdn(&card->interface)) {
......
...@@ -94,6 +94,7 @@ typedef struct isdnloop_card { ...@@ -94,6 +94,7 @@ typedef struct isdnloop_card {
struct sk_buff_head struct sk_buff_head
bqueue[ISDNLOOP_BCH]; /* B-Channel queues */ bqueue[ISDNLOOP_BCH]; /* B-Channel queues */
struct sk_buff_head dqueue; /* D-Channel queue */ struct sk_buff_head dqueue; /* D-Channel queue */
spinlock_t isdnloop_lock;
} isdnloop_card; } isdnloop_card;
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment