Bluetooth: Move HCI_RUNNING check into hci_send_frame
authorMarcel Holtmann <marcel@holtmann.org>
Sun, 4 Oct 2015 21:34:01 +0000 (23:34 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Mon, 5 Oct 2015 07:30:10 +0000 (10:30 +0300)
In all callbacks for hdev->send the status of HCI_RUNNING is checked. So
instead of repeating that code in every driver, move the check into the
hci_send_frame function before calling hdev->send.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
drivers/bluetooth/bfusb.c
drivers/bluetooth/bpa10x.c
drivers/bluetooth/btmrvl_main.c
drivers/bluetooth/btsdio.c
drivers/bluetooth/btusb.c
drivers/bluetooth/btwilink.c
drivers/bluetooth/hci_ldisc.c
drivers/bluetooth/hci_vhci.c
net/bluetooth/hci_core.c

index a5c4d0584389713522652c472cfd5c7b5e75dbab..3ba8170d08d33ffe08a1fb2cb5a0b9d1b5912d90 100644 (file)
@@ -479,9 +479,6 @@ static int bfusb_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
 
        BT_DBG("hdev %p skb %p type %d len %d", hdev, skb, bt_cb(skb)->pkt_type, skb->len);
 
-       if (!test_bit(HCI_RUNNING, &hdev->flags))
-               return -EBUSY;
-
        switch (bt_cb(skb)->pkt_type) {
        case HCI_COMMAND_PKT:
                hdev->stat.cmd_tx++;
index 8a319913c9a96fd60c6d021c5edd055b83ef0aad..59b892464be5760c31f8deba81c26a1c32e4958f 100644 (file)
@@ -360,9 +360,6 @@ static int bpa10x_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
 
        BT_DBG("%s", hdev->name);
 
-       if (!test_bit(HCI_RUNNING, &hdev->flags))
-               return -EBUSY;
-
        skb->dev = (void *) hdev;
 
        urb = usb_alloc_urb(0, GFP_ATOMIC);
index 050ad6ba1981317929fcf287dd5bb7c098b982d6..39552a8e9cc78ac45a953ef47081b22e2dea0140 100644 (file)
@@ -436,13 +436,6 @@ static int btmrvl_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
 
        BT_DBG("type=%d, len=%d", skb->pkt_type, skb->len);
 
-       if (!test_bit(HCI_RUNNING, &hdev->flags)) {
-               BT_ERR("Failed testing HCI_RUNING, flags=%lx", hdev->flags);
-               print_hex_dump_bytes("data: ", DUMP_PREFIX_OFFSET,
-                                                       skb->data, skb->len);
-               return -EBUSY;
-       }
-
        switch (bt_cb(skb)->pkt_type) {
        case HCI_COMMAND_PKT:
                hdev->stat.cmd_tx++;
index 83f6437dd91df4014e27084f53ac6b02be5ed68a..21f99cc8c6692440a73c200600312756926c5884 100644 (file)
@@ -261,9 +261,6 @@ static int btsdio_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
 
        BT_DBG("%s", hdev->name);
 
-       if (!test_bit(HCI_RUNNING, &hdev->flags))
-               return -EBUSY;
-
        switch (bt_cb(skb)->pkt_type) {
        case HCI_COMMAND_PKT:
                hdev->stat.cmd_tx++;
index dfaaea2efecb3fcf8806233ba40a6f03ff27a25c..9cf3796f92aacbf55a438248f966d84d9476709b 100644 (file)
@@ -1156,9 +1156,6 @@ static int btusb_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
 
        BT_DBG("%s", hdev->name);
 
-       if (!test_bit(HCI_RUNNING, &hdev->flags))
-               return -EBUSY;
-
        switch (bt_cb(skb)->pkt_type) {
        case HCI_COMMAND_PKT:
                urb = alloc_ctrl_urb(hdev, skb);
@@ -1843,9 +1840,6 @@ static int btusb_send_frame_intel(struct hci_dev *hdev, struct sk_buff *skb)
 
        BT_DBG("%s", hdev->name);
 
-       if (!test_bit(HCI_RUNNING, &hdev->flags))
-               return -EBUSY;
-
        switch (bt_cb(skb)->pkt_type) {
        case HCI_COMMAND_PKT:
                if (test_bit(BTUSB_BOOTLOADER, &data->flags)) {
index 7a722df97343ee6f25fb4c02959b8d64bacc4449..4db99a44f6710c93868b2d967f4e6baf6ae72851 100644 (file)
@@ -256,9 +256,6 @@ static int ti_st_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
        struct ti_st *hst;
        long len;
 
-       if (!test_bit(HCI_RUNNING, &hdev->flags))
-               return -EBUSY;
-
        hst = hci_get_drvdata(hdev);
 
        /* Prepend skb with frame type */
index ad66c690d27252a2ac5e03ab58b04cce2b836bca..443feaebe27507b1d6788e3b10a2f144a429d316 100644 (file)
@@ -254,9 +254,6 @@ static int hci_uart_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
 {
        struct hci_uart *hu = hci_get_drvdata(hdev);
 
-       if (!test_bit(HCI_RUNNING, &hdev->flags))
-               return -EBUSY;
-
        BT_DBG("%s: type %d len %d", hdev->name, bt_cb(skb)->pkt_type, skb->len);
 
        hu->proto->enqueue(hu, skb);
index 78653db2ef2bca6d6ea085b8aa9054ce74d05e17..15c344c9a00de0bc48f8ee7f61fb4923ede316c6 100644 (file)
@@ -85,9 +85,6 @@ static int vhci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
 {
        struct vhci_data *data = hci_get_drvdata(hdev);
 
-       if (!test_bit(HCI_RUNNING, &hdev->flags))
-               return -EBUSY;
-
        memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
        skb_queue_tail(&data->readq, skb);
 
index 5af33c87cbbadfe5d80cd6241eb607acb16bc224..b955f71926519def011a041434fc667b3da29ae9 100644 (file)
@@ -3536,6 +3536,11 @@ static void hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
        /* Get rid of skb owner, prior to sending to the driver. */
        skb_orphan(skb);
 
+       if (!test_bit(HCI_RUNNING, &hdev->flags)) {
+               kfree_skb(skb);
+               return;
+       }
+
        err = hdev->send(hdev, skb);
        if (err < 0) {
                BT_ERR("%s sending frame failed (%d)", hdev->name, err);