Merge branch 'master' of git://git.kernel.org/pub/scm/linux/kernel/git/linville/wirel...
[firefly-linux-kernel-4.4.55.git] / net / bluetooth / hci_sock.c
index f6afe3d76a668154a3131fe55f78bf3de34ed636..6d94616af3129b3519c914c3458eb30cad40de05 100644 (file)
@@ -49,7 +49,7 @@
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
 
-static int enable_mgmt;
+static bool enable_mgmt;
 
 /* ----- HCI socket interface ----- */
 
@@ -188,11 +188,11 @@ static int hci_sock_blacklist_add(struct hci_dev *hdev, void __user *arg)
        if (copy_from_user(&bdaddr, arg, sizeof(bdaddr)))
                return -EFAULT;
 
-       hci_dev_lock_bh(hdev);
+       hci_dev_lock(hdev);
 
        err = hci_blacklist_add(hdev, &bdaddr);
 
-       hci_dev_unlock_bh(hdev);
+       hci_dev_unlock(hdev);
 
        return err;
 }
@@ -205,11 +205,11 @@ static int hci_sock_blacklist_del(struct hci_dev *hdev, void __user *arg)
        if (copy_from_user(&bdaddr, arg, sizeof(bdaddr)))
                return -EFAULT;
 
-       hci_dev_lock_bh(hdev);
+       hci_dev_lock(hdev);
 
        err = hci_blacklist_del(hdev, &bdaddr);
 
-       hci_dev_unlock_bh(hdev);
+       hci_dev_unlock(hdev);
 
        return err;
 }
@@ -343,8 +343,11 @@ static int hci_sock_bind(struct socket *sock, struct sockaddr *addr, int addr_le
        if (haddr.hci_channel > HCI_CHANNEL_CONTROL)
                return -EINVAL;
 
-       if (haddr.hci_channel == HCI_CHANNEL_CONTROL && !enable_mgmt)
-               return -EINVAL;
+       if (haddr.hci_channel == HCI_CHANNEL_CONTROL) {
+               if (!enable_mgmt)
+                       return -EINVAL;
+               set_bit(HCI_PI_MGMT_INIT, &hci_pi(sk)->flags);
+       }
 
        lock_sock(sk);
 
@@ -535,10 +538,10 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
 
                if (test_bit(HCI_RAW, &hdev->flags) || (ogf == 0x3f)) {
                        skb_queue_tail(&hdev->raw_q, skb);
-                       tasklet_schedule(&hdev->tx_task);
+                       queue_work(hdev->workqueue, &hdev->tx_work);
                } else {
                        skb_queue_tail(&hdev->cmd_q, skb);
-                       tasklet_schedule(&hdev->cmd_task);
+                       queue_work(hdev->workqueue, &hdev->cmd_work);
                }
        } else {
                if (!capable(CAP_NET_RAW)) {
@@ -547,7 +550,7 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
                }
 
                skb_queue_tail(&hdev->raw_q, skb);
-               tasklet_schedule(&hdev->tx_task);
+               queue_work(hdev->workqueue, &hdev->tx_work);
        }
 
        err = len;