Commit aec459cb authored by Kai Germaschewski's avatar Kai Germaschewski

ISDN/HiSax: Shared PH_PULL handling for B-Channel

More obviously duplicated code moved into just one place.
parent 55953e4c
...@@ -501,21 +501,10 @@ hdlc_l2l1(struct PStack *st, int pr, void *arg) ...@@ -501,21 +501,10 @@ hdlc_l2l1(struct PStack *st, int pr, void *arg)
xmit_data_req_b(st->l1.bcs, skb); xmit_data_req_b(st->l1.bcs, skb);
break; break;
case (PH_PULL | INDICATION): case (PH_PULL | INDICATION):
if (st->l1.bcs->tx_skb) { xmit_pull_ind_b(st->l1.bcs, skb);
printk(KERN_WARNING "hdlc_l2l1: this shouldn't happen\n");
break;
}
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->tx_skb = skb;
st->l1.bcs->count = 0;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
break; break;
case (PH_PULL | REQUEST): case (PH_PULL | REQUEST):
if (!st->l1.bcs->tx_skb) { xmit_pull_req_b(st, skb);
test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
L1L2(st, PH_PULL | CONFIRM, NULL);
} else
test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
break; break;
case (PH_ACTIVATE | REQUEST): case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag); test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
...@@ -106,15 +106,11 @@ WaitForBusy(struct IsdnCardState *cs) ...@@ -106,15 +106,11 @@ WaitForBusy(struct IsdnCardState *cs)
static inline int static inline int
WaitNoBusy(struct IsdnCardState *cs) WaitNoBusy(struct IsdnCardState *cs)
{ {
long flags;
int to = 130; int to = 130;
while ((ReadReg(cs, HFCD_STATUS, HFCD_STATUS) & HFCD_BUSY) && to) { while ((ReadReg(cs, HFCD_STATUS, HFCD_STATUS) & HFCD_BUSY) && to) {
save_flags(flags);
sti();
udelay(1); udelay(1);
to--; to--;
restore_flags(flags);
} }
if (!to) if (!to)
printk(KERN_WARNING "HiSax: WaitNoBusy timeout\n"); printk(KERN_WARNING "HiSax: WaitNoBusy timeout\n");
...@@ -501,30 +497,16 @@ static void ...@@ -501,30 +497,16 @@ static void
hfc_l2l1(struct PStack *st, int pr, void *arg) hfc_l2l1(struct PStack *st, int pr, void *arg)
{ {
struct sk_buff *skb = arg; struct sk_buff *skb = arg;
long flags;
switch (pr) { switch (pr) {
case (PH_DATA | REQUEST): case (PH_DATA | REQUEST):
xmit_data_req(st->l1.bcs, skb); xmit_data_req(st->l1.bcs, skb);
break; break;
case (PH_PULL | INDICATION): case (PH_PULL | INDICATION):
if (st->l1.bcs->tx_skb) { xmit_pull_ind_b(st->l1.bcs, skb);
printk(KERN_WARNING "hfc_l2l1: this shouldn't happen\n");
break;
}
save_flags(flags);
cli();
/* test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
*/ st->l1.bcs->tx_skb = skb;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
restore_flags(flags);
break; break;
case (PH_PULL | REQUEST): case (PH_PULL | REQUEST):
if (!st->l1.bcs->tx_skb) { xmit_pull_req_b(st, skb);
test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
L1L2(st, PH_PULL | CONFIRM, NULL);
} else
test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
break; break;
case (PH_ACTIVATE | REQUEST): case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag); test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
...@@ -465,30 +465,16 @@ static void ...@@ -465,30 +465,16 @@ static void
hfc_l2l1(struct PStack *st, int pr, void *arg) hfc_l2l1(struct PStack *st, int pr, void *arg)
{ {
struct sk_buff *skb = arg; struct sk_buff *skb = arg;
long flags;
switch (pr) { switch (pr) {
case (PH_DATA | REQUEST): case (PH_DATA | REQUEST):
xmit_data_req_b(st->l1.bcs, skb); xmit_data_req_b(st->l1.bcs, skb);
break; break;
case (PH_PULL | INDICATION): case (PH_PULL | INDICATION):
if (st->l1.bcs->tx_skb) { xmit_pull_ind_b(st->l1.bcs, skb);
printk(KERN_WARNING "hfc_l2l1: this shouldn't happen\n");
break;
}
save_flags(flags);
cli();
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->tx_skb = skb;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
restore_flags(flags);
break; break;
case (PH_PULL | REQUEST): case (PH_PULL | REQUEST):
if (!st->l1.bcs->tx_skb) { xmit_pull_req_b(st, skb);
test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
L1L2(st, PH_PULL | CONFIRM, NULL);
} else
test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
break; break;
case (PH_ACTIVATE | REQUEST): case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag); test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
...@@ -1397,30 +1397,16 @@ static void ...@@ -1397,30 +1397,16 @@ static void
hfcpci_l2l1(struct PStack *st, int pr, void *arg) hfcpci_l2l1(struct PStack *st, int pr, void *arg)
{ {
struct sk_buff *skb = arg; struct sk_buff *skb = arg;
long flags;
switch (pr) { switch (pr) {
case (PH_DATA | REQUEST): case (PH_DATA | REQUEST):
xmit_data_req(st->l1.bcs, skb); xmit_data_req(st->l1.bcs, skb);
break; break;
case (PH_PULL | INDICATION): case (PH_PULL | INDICATION):
if (st->l1.bcs->tx_skb) { xmit_pull_ind_b(st->l1.bcs, skb);
printk(KERN_WARNING "hfc_l2l1: this shouldn't happen\n");
break;
}
save_flags(flags);
cli();
/* test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
*/ st->l1.bcs->tx_skb = skb;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
restore_flags(flags);
break; break;
case (PH_PULL | REQUEST): case (PH_PULL | REQUEST):
if (!st->l1.bcs->tx_skb) { xmit_pull_req_b(st, skb);
test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
L1L2(st, PH_PULL | CONFIRM, NULL);
} else
test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
break; break;
case (PH_ACTIVATE | REQUEST): case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag); test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
...@@ -1185,30 +1185,16 @@ static void ...@@ -1185,30 +1185,16 @@ static void
hfcsx_l2l1(struct PStack *st, int pr, void *arg) hfcsx_l2l1(struct PStack *st, int pr, void *arg)
{ {
struct sk_buff *skb = arg; struct sk_buff *skb = arg;
long flags;
switch (pr) { switch (pr) {
case (PH_DATA | REQUEST): case (PH_DATA | REQUEST):
xmit_data_req(st->l1.bcs, skb); xmit_data_req(st->l1.bcs, skb);
break; break;
case (PH_PULL | INDICATION): case (PH_PULL | INDICATION):
if (st->l1.bcs->tx_skb) { xmit_pull_ind_b(st->l1.bcs, skb);
printk(KERN_WARNING "hfc_l2l1: this shouldn't happen\n");
break;
}
save_flags(flags);
cli();
/* test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
*/ st->l1.bcs->tx_skb = skb;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
restore_flags(flags);
break; break;
case (PH_PULL | REQUEST): case (PH_PULL | REQUEST):
if (!st->l1.bcs->tx_skb) { xmit_pull_req_b(st, skb);
test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
L1L2(st, PH_PULL | CONFIRM, NULL);
} else
test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
break; break;
case (PH_ACTIVATE | REQUEST): case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag); test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
...@@ -95,31 +95,16 @@ void ...@@ -95,31 +95,16 @@ void
hscx_l2l1(struct PStack *st, int pr, void *arg) hscx_l2l1(struct PStack *st, int pr, void *arg)
{ {
struct sk_buff *skb = arg; struct sk_buff *skb = arg;
struct IsdnCardState *cs = st->l1.bcs->cs;
unsigned long flags;
switch (pr) { switch (pr) {
case (PH_DATA | REQUEST): case (PH_DATA | REQUEST):
xmit_data_req_b(st->l1.bcs, skb); xmit_data_req_b(st->l1.bcs, skb);
break; break;
case (PH_PULL | INDICATION): case (PH_PULL | INDICATION):
spin_lock_irqsave(&cs->lock, flags); xmit_pull_ind_b(st->l1.bcs, skb);
if (st->l1.bcs->tx_skb) {
printk(KERN_WARNING "hscx_l2l1: this shouldn't happen\n");
} else {
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->tx_skb = skb;
st->l1.bcs->count = 0;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
}
spin_unlock_irqrestore(&cs->lock, flags);
break; break;
case (PH_PULL | REQUEST): case (PH_PULL | REQUEST):
if (!st->l1.bcs->tx_skb) { xmit_pull_req_b(st, skb);
test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
L1L2(st, PH_PULL | CONFIRM, NULL);
} else
test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
break; break;
case (PH_ACTIVATE | REQUEST): case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag); test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
...@@ -527,21 +527,10 @@ bch_l2l1(struct PStack *st, int pr, void *arg) ...@@ -527,21 +527,10 @@ bch_l2l1(struct PStack *st, int pr, void *arg)
xmit_data_req_b(st->l1.bcs, skb); xmit_data_req_b(st->l1.bcs, skb);
break; break;
case (PH_PULL | INDICATION): case (PH_PULL | INDICATION):
if (st->l1.bcs->tx_skb) { xmit_pull_ind_b(st->l1.bcs, skb);
printk(KERN_WARNING "HiSax bch_l2l1(): this shouldn't happen\n");
break;
}
set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->tx_skb = skb;
st->l1.bcs->count = 0;
ipacx_fill_fifo(st->l1.bcs);
break; break;
case (PH_PULL | REQUEST): case (PH_PULL | REQUEST):
if (!st->l1.bcs->tx_skb) { xmit_pull_req_b(st, skb);
clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
st->l2.l1l2(st, PH_PULL | CONFIRM, NULL);
} else
set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
break; break;
case (PH_ACTIVATE | REQUEST): case (PH_ACTIVATE | REQUEST):
set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag); set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
...@@ -1549,23 +1549,10 @@ isar_l2l1(struct PStack *st, int pr, void *arg) ...@@ -1549,23 +1549,10 @@ isar_l2l1(struct PStack *st, int pr, void *arg)
xmit_data_req_b(st->l1.bcs, skb); xmit_data_req_b(st->l1.bcs, skb);
break; break;
case (PH_PULL | INDICATION): case (PH_PULL | INDICATION):
if (st->l1.bcs->tx_skb) { xmit_pull_ind_b(st->l1.bcs, skb);
printk(KERN_WARNING "isar_l2l1: this shouldn't happen\n");
break;
}
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
if (st->l1.bcs->cs->debug & L1_DEB_HSCX)
debugl1(st->l1.bcs->cs, "PUI set BC_FLG_BUSY");
st->l1.bcs->tx_skb = skb;
st->l1.bcs->count = 0;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
break; break;
case (PH_PULL | REQUEST): case (PH_PULL | REQUEST):
if (!st->l1.bcs->tx_skb) { xmit_pull_req_b(st, skb);
test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
L1L2(st, PH_PULL | CONFIRM, NULL);
} else
test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
break; break;
case (PH_ACTIVATE | REQUEST): case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag); test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
...@@ -76,10 +76,48 @@ xmit_data_req_b(struct BCState *bcs, struct sk_buff *skb) ...@@ -76,10 +76,48 @@ xmit_data_req_b(struct BCState *bcs, struct sk_buff *skb)
if (bcs->tx_skb) { if (bcs->tx_skb) {
skb_queue_tail(&bcs->squeue, skb); skb_queue_tail(&bcs->squeue, skb);
} else { } else {
set_bit(BC_FLG_BUSY, &bcs->Flag);
bcs->tx_skb = skb; bcs->tx_skb = skb;
bcs->count = 0;
bcs->cs->BC_Send_Data(bcs);
}
spin_unlock_irqrestore(&cs->lock, flags);
}
static inline void
xmit_pull_ind_b(struct BCState *bcs, struct sk_buff *skb)
{
struct IsdnCardState *cs = bcs->cs;
unsigned long flags;
spin_lock_irqsave(&cs->lock, flags);
if (bcs->tx_skb) {
WARN_ON(1);
} else {
set_bit(BC_FLG_BUSY, &bcs->Flag); set_bit(BC_FLG_BUSY, &bcs->Flag);
bcs->tx_skb = skb;
bcs->count = 0; bcs->count = 0;
bcs->cs->BC_Send_Data(bcs); bcs->cs->BC_Send_Data(bcs);
} }
spin_unlock_irqrestore(&cs->lock, flags); spin_unlock_irqrestore(&cs->lock, flags);
} }
/* If busy, the PH_PULL | CONFIRM scheduling is handled under
* the card lock by xmit_ready_b() above, so no race */
static inline void
xmit_pull_req_b(struct PStack *st, struct sk_buff *skb)
{
struct BCState *bcs = st->l1.bcs;
struct IsdnCardState *cs = bcs->cs;
unsigned long flags;
int busy = 0;
spin_lock_irqsave(&cs->lock, flags);
if (bcs->tx_skb) {
set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
busy = 1;
}
spin_unlock_irqrestore(&cs->lock, flags);
if (!busy)
L1L2(st, PH_PULL | CONFIRM, NULL);
}
...@@ -151,21 +151,10 @@ jade_l2l1(struct PStack *st, int pr, void *arg) ...@@ -151,21 +151,10 @@ jade_l2l1(struct PStack *st, int pr, void *arg)
xmit_data_req_b(st->l1.bcs, skb); xmit_data_req_b(st->l1.bcs, skb);
break; break;
case (PH_PULL | INDICATION): case (PH_PULL | INDICATION):
if (st->l1.bcs->tx_skb) { xmit_pull_ind_b(st->l1.bcs, skb);
printk(KERN_WARNING "jade_l2l1: this shouldn't happen\n");
break;
}
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->tx_skb = skb;
st->l1.bcs->count = 0;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
break; break;
case (PH_PULL | REQUEST): case (PH_PULL | REQUEST):
if (!st->l1.bcs->tx_skb) { xmit_pull_req_b(st, skb);
test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
L1L2(st, PH_PULL | CONFIRM, NULL);
} else
test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
break; break;
case (PH_ACTIVATE | REQUEST): case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag); test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
...@@ -832,28 +832,16 @@ static void ...@@ -832,28 +832,16 @@ static void
tiger_l2l1(struct PStack *st, int pr, void *arg) tiger_l2l1(struct PStack *st, int pr, void *arg)
{ {
struct sk_buff *skb = arg; struct sk_buff *skb = arg;
unsigned long flags;
switch (pr) { switch (pr) {
case (PH_DATA | REQUEST): case (PH_DATA | REQUEST):
xmit_data_req_b(st->l1.bcs, skb); xmit_data_req_b(st->l1.bcs, skb);
break; break;
case (PH_PULL | INDICATION): case (PH_PULL | INDICATION):
if (st->l1.bcs->tx_skb) { xmit_pull_ind_b(st->l1.bcs, skb);
printk(KERN_WARNING "tiger_l2l1: this shouldn't happen\n");
break;
}
spin_lock_irqsave(&netjet_lock, flags);
st->l1.bcs->tx_skb = skb;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
spin_unlock_irqrestore(&netjet_lock, flags);
break; break;
case (PH_PULL | REQUEST): case (PH_PULL | REQUEST):
if (!st->l1.bcs->tx_skb) { xmit_pull_req_b(st, skb);
test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
L1L2(st, PH_PULL | CONFIRM, NULL);
} else
test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
break; break;
case (PH_ACTIVATE | REQUEST): case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag); test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
...@@ -711,21 +711,10 @@ W6692_l2l1(struct PStack *st, int pr, void *arg) ...@@ -711,21 +711,10 @@ W6692_l2l1(struct PStack *st, int pr, void *arg)
xmit_data_req_b(st->l1.bcs, skb); xmit_data_req_b(st->l1.bcs, skb);
break; break;
case (PH_PULL | INDICATION): case (PH_PULL | INDICATION):
if (st->l1.bcs->tx_skb) { xmit_pull_ind_b(st->l1.bcs, skb);
printk(KERN_WARNING "W6692_l2l1: this shouldn't happen\n");
break;
}
test_and_set_bit(BC_FLG_BUSY, &st->l1.bcs->Flag);
st->l1.bcs->tx_skb = skb;
st->l1.bcs->count = 0;
st->l1.bcs->cs->BC_Send_Data(st->l1.bcs);
break; break;
case (PH_PULL | REQUEST): case (PH_PULL | REQUEST):
if (!st->l1.bcs->tx_skb) { xmit_pull_req_b(st, skb);
test_and_clear_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
L1L2(st, PH_PULL | CONFIRM, NULL);
} else
test_and_set_bit(FLG_L1_PULL_REQ, &st->l1.Flags);
break; break;
case (PH_ACTIVATE | REQUEST): case (PH_ACTIVATE | REQUEST):
test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag); test_and_set_bit(BC_FLG_ACTIV, &st->l1.bcs->Flag);
......
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