Bluetooth: Remove double check for BT_CONNECTED
[profile/ivi/kernel-adaptation-intel-automotive.git] / net / bluetooth / l2cap_core.c
index b70dca4..5bf8287 100644 (file)
@@ -549,9 +549,11 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err)
        if (test_bit(CONF_NOT_COMPLETE, &chan->conf_state))
                return;
 
-       skb_queue_purge(&chan->tx_q);
+       switch(chan->mode) {
+       case L2CAP_MODE_BASIC:
+               break;
 
-       if (chan->mode == L2CAP_MODE_ERTM) {
+       case L2CAP_MODE_ERTM:
                __clear_retrans_timer(chan);
                __clear_monitor_timer(chan);
                __clear_ack_timer(chan);
@@ -560,7 +562,15 @@ static void l2cap_chan_del(struct l2cap_chan *chan, int err)
 
                l2cap_seq_list_free(&chan->srej_list);
                l2cap_seq_list_free(&chan->retrans_list);
+
+               /* fall through */
+
+       case L2CAP_MODE_STREAMING:
+               skb_queue_purge(&chan->tx_q);
+               break;
        }
+
+       return;
 }
 
 static void l2cap_chan_cleanup_listen(struct sock *parent)
@@ -1649,7 +1659,7 @@ static void l2cap_monitor_timeout(struct work_struct *work)
                return;
        }
 
-       l2cap_tx(chan, 0, 0, L2CAP_EV_MONITOR_TO);
+       l2cap_tx(chan, NULL, NULL, L2CAP_EV_MONITOR_TO);
 
        l2cap_chan_unlock(chan);
        l2cap_chan_put(chan);
@@ -1670,7 +1680,7 @@ static void l2cap_retrans_timeout(struct work_struct *work)
                return;
        }
 
-       l2cap_tx(chan, 0, 0, L2CAP_EV_RETRANS_TO);
+       l2cap_tx(chan, NULL, NULL, L2CAP_EV_RETRANS_TO);
        l2cap_chan_unlock(chan);
        l2cap_chan_put(chan);
 }
@@ -1683,9 +1693,6 @@ static int l2cap_streaming_send(struct l2cap_chan *chan,
 
        BT_DBG("chan %p, skbs %p", chan, skbs);
 
-       if (chan->state != BT_CONNECTED)
-               return -ENOTCONN;
-
        skb_queue_splice_tail_init(skbs, &chan->tx_q);
 
        while (!skb_queue_empty(&chan->tx_q)) {
@@ -2247,7 +2254,7 @@ int l2cap_chan_send(struct l2cap_chan *chan, struct msghdr *msg, size_t len,
                        break;
 
                if (chan->mode == L2CAP_MODE_ERTM)
-                       err = l2cap_tx(chan, 0, &seg_queue,
+                       err = l2cap_tx(chan, NULL, &seg_queue,
                                       L2CAP_EV_DATA_REQUEST);
                else
                        err = l2cap_streaming_send(chan, &seg_queue);
@@ -2561,14 +2568,14 @@ static void l2cap_pass_to_tx(struct l2cap_chan *chan,
                             struct l2cap_ctrl *control)
 {
        BT_DBG("chan %p, control %p", chan, control);
-       l2cap_tx(chan, control, 0, L2CAP_EV_RECV_REQSEQ_AND_FBIT);
+       l2cap_tx(chan, control, NULL, L2CAP_EV_RECV_REQSEQ_AND_FBIT);
 }
 
 static void l2cap_pass_to_tx_fbit(struct l2cap_chan *chan,
                                  struct l2cap_ctrl *control)
 {
        BT_DBG("chan %p, control %p", chan, control);
-       l2cap_tx(chan, control, 0, L2CAP_EV_RECV_FBIT);
+       l2cap_tx(chan, control, NULL, L2CAP_EV_RECV_FBIT);
 }
 
 /* Copy frame to all raw sockets on that connection */
@@ -4543,7 +4550,7 @@ void l2cap_chan_busy(struct l2cap_chan *chan, int busy)
                return;
 
        event = busy ? L2CAP_EV_LOCAL_BUSY_DETECTED : L2CAP_EV_LOCAL_BUSY_CLEAR;
-       l2cap_tx(chan, 0, 0, event);
+       l2cap_tx(chan, NULL, NULL, event);
 }
 
 static int l2cap_rx_queued_iframes(struct l2cap_chan *chan)