Commit fb286f04 authored by Karsten Keil's avatar Karsten Keil

mISDN: Make clearing B-channel a common function

Clearing B-channel is needed in every driver, so it makes sense
to have it as common function.
Signed-off-by: default avatarKarsten Keil <keil@b1-systems.de>
parent f3fad223
...@@ -3416,22 +3416,8 @@ deactivate_bchannel(struct bchannel *bch) ...@@ -3416,22 +3416,8 @@ deactivate_bchannel(struct bchannel *bch)
u_long flags; u_long flags;
spin_lock_irqsave(&hc->lock, flags); spin_lock_irqsave(&hc->lock, flags);
if (test_and_clear_bit(FLG_TX_NEXT, &bch->Flags)) { mISDN_clear_bchannel(bch);
dev_kfree_skb(bch->next_skb);
bch->next_skb = NULL;
}
if (bch->tx_skb) {
dev_kfree_skb(bch->tx_skb);
bch->tx_skb = NULL;
}
bch->tx_idx = 0;
if (bch->rx_skb) {
dev_kfree_skb(bch->rx_skb);
bch->rx_skb = NULL;
}
hc->chan[bch->slot].coeff_count = 0; hc->chan[bch->slot].coeff_count = 0;
test_and_clear_bit(FLG_ACTIVE, &bch->Flags);
test_and_clear_bit(FLG_TX_BUSY, &bch->Flags);
hc->chan[bch->slot].rx_off = 0; hc->chan[bch->slot].rx_off = 0;
hc->chan[bch->slot].conf = -1; hc->chan[bch->slot].conf = -1;
mode_hfcmulti(hc, bch->slot, ISDN_P_NONE, -1, 0, -1, 0); mode_hfcmulti(hc, bch->slot, ISDN_P_NONE, -1, 0, -1, 0);
......
...@@ -1522,22 +1522,8 @@ deactivate_bchannel(struct bchannel *bch) ...@@ -1522,22 +1522,8 @@ deactivate_bchannel(struct bchannel *bch)
u_long flags; u_long flags;
spin_lock_irqsave(&hc->lock, flags); spin_lock_irqsave(&hc->lock, flags);
if (test_and_clear_bit(FLG_TX_NEXT, &bch->Flags)) { mISDN_clear_bchannel(bch);
dev_kfree_skb(bch->next_skb);
bch->next_skb = NULL;
}
if (bch->tx_skb) {
dev_kfree_skb(bch->tx_skb);
bch->tx_skb = NULL;
}
bch->tx_idx = 0;
if (bch->rx_skb) {
dev_kfree_skb(bch->rx_skb);
bch->rx_skb = NULL;
}
mode_hfcpci(bch, bch->nr, ISDN_P_NONE); mode_hfcpci(bch, bch->nr, ISDN_P_NONE);
test_and_clear_bit(FLG_ACTIVE, &bch->Flags);
test_and_clear_bit(FLG_TX_BUSY, &bch->Flags);
spin_unlock_irqrestore(&hc->lock, flags); spin_unlock_irqrestore(&hc->lock, flags);
} }
......
...@@ -1809,21 +1809,7 @@ deactivate_bchannel(struct bchannel *bch) ...@@ -1809,21 +1809,7 @@ deactivate_bchannel(struct bchannel *bch)
hw->name, __func__, bch->nr); hw->name, __func__, bch->nr);
spin_lock_irqsave(&hw->lock, flags); spin_lock_irqsave(&hw->lock, flags);
if (test_and_clear_bit(FLG_TX_NEXT, &bch->Flags)) { mISDN_clear_bchannel(bch);
dev_kfree_skb(bch->next_skb);
bch->next_skb = NULL;
}
if (bch->tx_skb) {
dev_kfree_skb(bch->tx_skb);
bch->tx_skb = NULL;
}
bch->tx_idx = 0;
if (bch->rx_skb) {
dev_kfree_skb(bch->rx_skb);
bch->rx_skb = NULL;
}
clear_bit(FLG_ACTIVE, &bch->Flags);
clear_bit(FLG_TX_BUSY, &bch->Flags);
spin_unlock_irqrestore(&hw->lock, flags); spin_unlock_irqrestore(&hw->lock, flags);
hfcsusb_setup_bch(bch, ISDN_P_NONE); hfcsusb_setup_bch(bch, ISDN_P_NONE);
hfcsusb_stop_endpoint(hw, bch->nr); hfcsusb_stop_endpoint(hw, bch->nr);
......
...@@ -114,13 +114,14 @@ mISDN_freedchannel(struct dchannel *ch) ...@@ -114,13 +114,14 @@ mISDN_freedchannel(struct dchannel *ch)
} }
EXPORT_SYMBOL(mISDN_freedchannel); EXPORT_SYMBOL(mISDN_freedchannel);
int void
mISDN_freebchannel(struct bchannel *ch) mISDN_clear_bchannel(struct bchannel *ch)
{ {
if (ch->tx_skb) { if (ch->tx_skb) {
dev_kfree_skb(ch->tx_skb); dev_kfree_skb(ch->tx_skb);
ch->tx_skb = NULL; ch->tx_skb = NULL;
} }
ch->tx_idx = 0;
if (ch->rx_skb) { if (ch->rx_skb) {
dev_kfree_skb(ch->rx_skb); dev_kfree_skb(ch->rx_skb);
ch->rx_skb = NULL; ch->rx_skb = NULL;
...@@ -129,6 +130,16 @@ mISDN_freebchannel(struct bchannel *ch) ...@@ -129,6 +130,16 @@ mISDN_freebchannel(struct bchannel *ch)
dev_kfree_skb(ch->next_skb); dev_kfree_skb(ch->next_skb);
ch->next_skb = NULL; ch->next_skb = NULL;
} }
test_and_clear_bit(FLG_TX_BUSY, &ch->Flags);
test_and_clear_bit(FLG_TX_NEXT, &ch->Flags);
test_and_clear_bit(FLG_ACTIVE, &ch->Flags);
}
EXPORT_SYMBOL(mISDN_clear_bchannel);
int
mISDN_freebchannel(struct bchannel *ch)
{
mISDN_clear_bchannel(ch);
skb_queue_purge(&ch->rqueue); skb_queue_purge(&ch->rqueue);
ch->rcount = 0; ch->rcount = 0;
flush_scheduled_work(); flush_scheduled_work();
......
...@@ -168,6 +168,7 @@ struct bchannel { ...@@ -168,6 +168,7 @@ struct bchannel {
extern int mISDN_initdchannel(struct dchannel *, int, void *); extern int mISDN_initdchannel(struct dchannel *, int, void *);
extern int mISDN_initbchannel(struct bchannel *, int); extern int mISDN_initbchannel(struct bchannel *, int);
extern int mISDN_freedchannel(struct dchannel *); extern int mISDN_freedchannel(struct dchannel *);
extern void mISDN_clear_bchannel(struct bchannel *);
extern int mISDN_freebchannel(struct bchannel *); extern int mISDN_freebchannel(struct bchannel *);
extern void queue_ch_frame(struct mISDNchannel *, u_int, extern void queue_ch_frame(struct mISDNchannel *, u_int,
int, struct sk_buff *); int, struct sk_buff *);
......
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