Bluetooth: Remove useless rx_lock spinlock
authorFrederic Danis <frederic.danis@linux.intel.com>
Wed, 23 Sep 2015 16:18:10 +0000 (18:18 +0200)
committerMarcel Holtmann <marcel@holtmann.org>
Thu, 24 Sep 2015 14:25:44 +0000 (16:25 +0200)
rx_lock spinlock is only used in hci_uart_tty_receive() which is the
receive_buf ldisc callback.

hci_uart_tty_receive() is protected from re-entrance by its only
caller (flush_to_ldisc() in drivers/tty/tty_buffer.c) which held a
mutex (buf->lock) for this section.
This lock allows "safe use of the line discipline's receive_buf()
method by excluding the buffer work and any pending flush from using
the flip buffer." (comments from tty_buffer_lock_exclusive() in
drivers/tty/tty_buffer.c)

So, no need to double protect this resource with rx_lock.

Signed-off-by: Frederic Danis <frederic.danis@linux.intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
drivers/bluetooth/hci_ldisc.c
drivers/bluetooth/hci_uart.h

index 0d5a05a7c1fd1d46a8b77d71b94f97a9df4190b3..ad66c690d27252a2ac5e03ab58b04cce2b836bca 100644 (file)
@@ -470,8 +470,6 @@ static int hci_uart_tty_open(struct tty_struct *tty)
        INIT_WORK(&hu->init_ready, hci_uart_init_work);
        INIT_WORK(&hu->write_work, hci_uart_write_work);
 
-       spin_lock_init(&hu->rx_lock);
-
        /* Flush any pending characters in the driver and line discipline. */
 
        /* FIXME: why is this needed. Note don't use ldisc_ref here as the
@@ -569,14 +567,14 @@ static void hci_uart_tty_receive(struct tty_struct *tty, const u8 *data,
        if (!test_bit(HCI_UART_PROTO_SET, &hu->flags))
                return;
 
-       spin_lock(&hu->rx_lock);
+       /* It does not need a lock here as it is already protected by a mutex in
+        * tty caller
+        */
        hu->proto->recv(hu, data, count);
 
        if (hu->hdev)
                hu->hdev->stat.byte_rx += count;
 
-       spin_unlock(&hu->rx_lock);
-
        tty_unthrottle(tty);
 }
 
index 495b9ef52bb0fd608519fda39c0b4726c95f3c7f..2f7bb35a890efc287d85e3fd9d46d022c19fc300 100644 (file)
@@ -85,7 +85,6 @@ struct hci_uart {
 
        struct sk_buff          *tx_skb;
        unsigned long           tx_state;
-       spinlock_t              rx_lock;
 
        unsigned int init_speed;
        unsigned int oper_speed;