mISDN: Make clearing B-channel a common function
authorKarsten Keil <keil@b1-systems.de>
Thu, 9 Jul 2009 08:02:29 +0000 (10:02 +0200)
committerKarsten Keil <keil@b1-systems.de>
Sat, 25 Jul 2009 18:18:16 +0000 (20:18 +0200)
Clearing B-channel is needed in every driver, so it makes sense
to have it as common function.

Signed-off-by: Karsten Keil <keil@b1-systems.de>
drivers/isdn/hardware/mISDN/hfcmulti.c
drivers/isdn/hardware/mISDN/hfcpci.c
drivers/isdn/hardware/mISDN/hfcsusb.c
drivers/isdn/mISDN/hwchannel.c
include/linux/mISDNhw.h

index e1dab30aed30aebeef28b6b85592ac3f54a717ea..fd77bb15d790db336517d6eac6aa877f5ffd1da5 100644 (file)
@@ -3416,22 +3416,8 @@ deactivate_bchannel(struct bchannel *bch)
        u_long                  flags;
 
        spin_lock_irqsave(&hc->lock, flags);
-       if (test_and_clear_bit(FLG_TX_NEXT, &bch->Flags)) {
-               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;
-       }
+       mISDN_clear_bchannel(bch);
        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].conf = -1;
        mode_hfcmulti(hc, bch->slot, ISDN_P_NONE, -1, 0, -1, 0);
index 228ffbed1286fc850f8d5533cd5368f9c23288d2..70e6b0e0112132d3f07b6779d0b42075ef1e0cc7 100644 (file)
@@ -1522,22 +1522,8 @@ deactivate_bchannel(struct bchannel *bch)
        u_long          flags;
 
        spin_lock_irqsave(&hc->lock, flags);
-       if (test_and_clear_bit(FLG_TX_NEXT, &bch->Flags)) {
-               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;
-       }
+       mISDN_clear_bchannel(bch);
        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);
 }
 
index 6b7704c41b947e4cc23b313c65caf40b64069367..fc46a26cb14fab046d417fa35142995bcb48b3d5 100644 (file)
@@ -1809,21 +1809,7 @@ deactivate_bchannel(struct bchannel *bch)
                    hw->name, __func__, bch->nr);
 
        spin_lock_irqsave(&hw->lock, flags);
-       if (test_and_clear_bit(FLG_TX_NEXT, &bch->Flags)) {
-               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);
+       mISDN_clear_bchannel(bch);
        spin_unlock_irqrestore(&hw->lock, flags);
        hfcsusb_setup_bch(bch, ISDN_P_NONE);
        hfcsusb_stop_endpoint(hw, bch->nr);
index 0481a0cdf6db9a1915ea8423f4d389655e86c66f..e8049be552aa88800dee7d749489616628a7d20a 100644 (file)
@@ -114,13 +114,14 @@ mISDN_freedchannel(struct dchannel *ch)
 }
 EXPORT_SYMBOL(mISDN_freedchannel);
 
-int
-mISDN_freebchannel(struct bchannel *ch)
+void
+mISDN_clear_bchannel(struct bchannel *ch)
 {
        if (ch->tx_skb) {
                dev_kfree_skb(ch->tx_skb);
                ch->tx_skb = NULL;
        }
+       ch->tx_idx = 0;
        if (ch->rx_skb) {
                dev_kfree_skb(ch->rx_skb);
                ch->rx_skb = NULL;
@@ -129,6 +130,16 @@ mISDN_freebchannel(struct bchannel *ch)
                dev_kfree_skb(ch->next_skb);
                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);
        ch->rcount = 0;
        flush_scheduled_work();
index 7f9831da847f8dca1e4b3e7a4662e9119ff565eb..4af841408fb5dd2bee2026f118e4ee372bcd2f80 100644 (file)
@@ -168,6 +168,7 @@ struct bchannel {
 extern int     mISDN_initdchannel(struct dchannel *, int, void *);
 extern int     mISDN_initbchannel(struct bchannel *, int);
 extern int     mISDN_freedchannel(struct dchannel *);
+extern void    mISDN_clear_bchannel(struct bchannel *);
 extern int     mISDN_freebchannel(struct bchannel *);
 extern void    queue_ch_frame(struct mISDNchannel *, u_int,
                        int, struct sk_buff *);