Bluetooth: Convert L2CAP ident spinlock into a mutex
authorMarcel Holtmann <marcel@holtmann.org>
Sun, 13 Jul 2014 18:50:15 +0000 (20:50 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Sun, 13 Jul 2014 19:32:45 +0000 (22:32 +0300)
The spinlock protecting the L2CAP ident number can be converted into
a mutex since the whole processing is run in a workqueue. So instead
of using a spinlock, just use a mutex here.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
include/net/bluetooth/l2cap.h
net/bluetooth/l2cap_core.c

index d8e7b9330ab8a93d598eb82249f29f01eb526926..1fffd92808b0bbdbeb4c65615de7521fec410f60 100644 (file)
@@ -625,11 +625,10 @@ struct l2cap_conn {
 
        struct delayed_work     info_timer;
 
-       spinlock_t              lock;
-
        struct sk_buff          *rx_skb;
        __u32                   rx_len;
        __u8                    tx_ident;
+       struct mutex            ident_lock;
 
        struct sk_buff_head     pending_rx;
        struct work_struct      pending_rx_work;
index 0c3c4935f635f9c2624bebb805cd02b035ae0de1..8538cb07b0c03d7be00398c08b3011d8ac94ad9a 100644 (file)
@@ -798,14 +798,14 @@ static u8 l2cap_get_ident(struct l2cap_conn *conn)
         *  200 - 254 are used by utilities like l2ping, etc.
         */
 
-       spin_lock(&conn->lock);
+       mutex_lock(&conn->ident_lock);
 
        if (++conn->tx_ident > 128)
                conn->tx_ident = 1;
 
        id = conn->tx_ident;
 
-       spin_unlock(&conn->lock);
+       mutex_unlock(&conn->ident_lock);
 
        return id;
 }
@@ -7016,7 +7016,7 @@ static struct l2cap_conn *l2cap_conn_add(struct hci_conn *hcon)
                conn->hs_enabled = test_bit(HCI_HS_ENABLED,
                                            &hcon->hdev->dev_flags);
 
-       spin_lock_init(&conn->lock);
+       mutex_init(&conn->ident_lock);
        mutex_init(&conn->chan_lock);
 
        INIT_LIST_HEAD(&conn->chan_l);