Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 39753
b: refs/heads/master
c: 078d396
h: refs/heads/master
i:
  39751: db04d17
v: v3
  • Loading branch information
Amol Lad authored and Linus Torvalds committed Oct 17, 2006
1 parent c3a02da commit 7ed6527
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 41 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 0d9ba869e103d91d471146378ad85bf1fb8e74b4
refs/heads/master: 078d396598401dbaa88d5f95ec45579f9d3dce0e
70 changes: 30 additions & 40 deletions trunk/drivers/isdn/isdnloop/isdnloop.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,11 @@ isdnloop_pollbchan(unsigned long data)
isdnloop_bchan_send(card, 1);
if (card->flags & (ISDNLOOP_FLAGS_B1ACTIVE | ISDNLOOP_FLAGS_B2ACTIVE)) {
/* schedule b-channel polling again */
save_flags(flags);
cli();
spin_lock_irqsave(&card->isdnloop_lock, flags);
card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD;
add_timer(&card->rb_timer);
card->flags |= ISDNLOOP_FLAGS_RBTIMER;
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
} else
card->flags &= ~ISDNLOOP_FLAGS_RBTIMER;
}
Expand Down Expand Up @@ -281,16 +280,15 @@ isdnloop_putmsg(isdnloop_card * card, unsigned char c)
{
ulong flags;

save_flags(flags);
cli();
spin_lock_irqsave(&card->isdnloop_lock, flags);
*card->msg_buf_write++ = (c == 0xff) ? '\n' : c;
if (card->msg_buf_write == card->msg_buf_read) {
if (++card->msg_buf_read > card->msg_buf_end)
card->msg_buf_read = card->msg_buf;
}
if (card->msg_buf_write > card->msg_buf_end)
card->msg_buf_write = card->msg_buf;
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
}

/*
Expand Down Expand Up @@ -372,21 +370,19 @@ isdnloop_polldchan(unsigned long data)
if (!(card->flags & ISDNLOOP_FLAGS_RBTIMER)) {
/* schedule b-channel polling */
card->flags |= ISDNLOOP_FLAGS_RBTIMER;
save_flags(flags);
cli();
spin_lock_irqsave(&card->isdnloop_lock, flags);
del_timer(&card->rb_timer);
card->rb_timer.function = isdnloop_pollbchan;
card->rb_timer.data = (unsigned long) card;
card->rb_timer.expires = jiffies + ISDNLOOP_TIMER_BCREAD;
add_timer(&card->rb_timer);
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
}
/* schedule again */
save_flags(flags);
cli();
spin_lock_irqsave(&card->isdnloop_lock, flags);
card->st_timer.expires = jiffies + ISDNLOOP_TIMER_DCREAD;
add_timer(&card->st_timer);
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
}

/*
Expand Down Expand Up @@ -416,8 +412,7 @@ isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card * card)
return 0;
if (card->sndcount[channel] > ISDNLOOP_MAX_SQUEUE)
return 0;
save_flags(flags);
cli();
spin_lock_irqsave(&card->isdnloop_lock, flags);
nskb = dev_alloc_skb(skb->len);
if (nskb) {
memcpy(skb_put(nskb, len), skb->data, len);
Expand All @@ -426,7 +421,7 @@ isdnloop_sendbuf(int channel, struct sk_buff *skb, isdnloop_card * card)
} else
len = 0;
card->sndcount[channel] += len;
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
}
return len;
}
Expand Down Expand Up @@ -576,8 +571,7 @@ isdnloop_atimeout(isdnloop_card * card, int ch)
unsigned long flags;
char buf[60];

save_flags(flags);
cli();
spin_lock_irqsave(&card->isdnloop_lock, flags);
if (card->rcard) {
isdnloop_fake(card->rcard[ch], "DDIS_I", card->rch[ch] + 1);
card->rcard[ch]->rcard[card->rch[ch]] = NULL;
Expand All @@ -587,7 +581,7 @@ isdnloop_atimeout(isdnloop_card * card, int ch)
/* No user responding */
sprintf(buf, "CAU%s", isdnloop_unicause(card, 1, 3));
isdnloop_fake(card, buf, ch + 1);
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
}

/*
Expand Down Expand Up @@ -622,8 +616,7 @@ isdnloop_start_ctimer(isdnloop_card * card, int ch)
{
unsigned long flags;

save_flags(flags);
cli();
spin_lock_irqsave(&card->isdnloop_lock, flags);
init_timer(&card->c_timer[ch]);
card->c_timer[ch].expires = jiffies + ISDNLOOP_TIMER_ALERTWAIT;
if (ch)
Expand All @@ -632,7 +625,7 @@ isdnloop_start_ctimer(isdnloop_card * card, int ch)
card->c_timer[ch].function = isdnloop_atimeout0;
card->c_timer[ch].data = (unsigned long) card;
add_timer(&card->c_timer[ch]);
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
}

/*
Expand All @@ -647,10 +640,9 @@ isdnloop_kill_ctimer(isdnloop_card * card, int ch)
{
unsigned long flags;

save_flags(flags);
cli();
spin_lock_irqsave(&card->isdnloop_lock, flags);
del_timer(&card->c_timer[ch]);
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
}

static u_char si2bit[] =
Expand Down Expand Up @@ -706,24 +698,23 @@ isdnloop_try_call(isdnloop_card * card, char *p, int lch, isdn_ctrl * cmd)
}
}
if (num_match) {
save_flags(flags);
cli();
spin_lock_irqsave(&card->isdnloop_lock, flags);
/* channel idle? */
if (!(cc->rcard[ch])) {
/* Check SI */
if (!(si2bit[cmd->parm.setup.si1] & cc->sil[ch])) {
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
return 3;
}
/* ch is idle, si and number matches */
cc->rcard[ch] = card;
cc->rch[ch] = lch;
card->rcard[lch] = cc;
card->rch[lch] = ch;
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
return 0;
} else {
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
/* num matches, but busy */
if (ch == 1)
return 1;
Expand Down Expand Up @@ -1027,8 +1018,7 @@ isdnloop_stopcard(isdnloop_card * card)
unsigned long flags;
isdn_ctrl cmd;

save_flags(flags);
cli();
spin_lock_irqsave(&card->isdnloop_lock, flags);
if (card->flags & ISDNLOOP_FLAGS_RUNNING) {
card->flags &= ~ISDNLOOP_FLAGS_RUNNING;
del_timer(&card->st_timer);
Expand All @@ -1039,7 +1029,7 @@ isdnloop_stopcard(isdnloop_card * card)
cmd.driver = card->myid;
card->interface.statcallb(&cmd);
}
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
}

/*
Expand Down Expand Up @@ -1078,18 +1068,17 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
return -EBUSY;
if (copy_from_user((char *) &sdef, (char *) sdefp, sizeof(sdef)))
return -EFAULT;
save_flags(flags);
cli();
spin_lock_irqsave(&card->isdnloop_lock, flags);
switch (sdef.ptype) {
case ISDN_PTYPE_EURO:
if (isdnloop_fake(card, "DRV1.23EC-Q.931-CAPI-CNS-BASIS-20.02.96",
-1)) {
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
return -ENOMEM;
}
card->sil[0] = card->sil[1] = 4;
if (isdnloop_fake(card, "TEI OK", 0)) {
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
return -ENOMEM;
}
for (i = 0; i < 3; i++)
Expand All @@ -1098,20 +1087,20 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
case ISDN_PTYPE_1TR6:
if (isdnloop_fake(card, "DRV1.04TC-1TR6-CAPI-CNS-BASIS-29.11.95",
-1)) {
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
return -ENOMEM;
}
card->sil[0] = card->sil[1] = 4;
if (isdnloop_fake(card, "TEI OK", 0)) {
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
return -ENOMEM;
}
strcpy(card->s0num[0], sdef.num[0]);
card->s0num[1][0] = '\0';
card->s0num[2][0] = '\0';
break;
default:
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
printk(KERN_WARNING "isdnloop: Illegal D-channel protocol %d\n",
sdef.ptype);
return -EINVAL;
Expand All @@ -1122,7 +1111,7 @@ isdnloop_start(isdnloop_card * card, isdnloop_sdef * sdefp)
card->st_timer.data = (unsigned long) card;
add_timer(&card->st_timer);
card->flags |= ISDNLOOP_FLAGS_RUNNING;
restore_flags(flags);
spin_unlock_irqrestore(&card->isdnloop_lock, flags);
return 0;
}

Expand Down Expand Up @@ -1472,6 +1461,7 @@ isdnloop_initcard(char *id)
skb_queue_head_init(&card->bqueue[i]);
}
skb_queue_head_init(&card->dqueue);
card->isdnloop_lock = SPIN_LOCK_UNLOCKED;
card->next = cards;
cards = card;
if (!register_isdn(&card->interface)) {
Expand Down
1 change: 1 addition & 0 deletions trunk/drivers/isdn/isdnloop/isdnloop.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ typedef struct isdnloop_card {
struct sk_buff_head
bqueue[ISDNLOOP_BCH]; /* B-Channel queues */
struct sk_buff_head dqueue; /* D-Channel queue */
spinlock_t isdnloop_lock;
} isdnloop_card;

/*
Expand Down

0 comments on commit 7ed6527

Please sign in to comment.