Skip to content

Commit 73d0d3c

Browse files
holtmannjhedberg
authored andcommitted
Bluetooth: Move HCI_RUNNING check into hci_send_frame
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>
1 parent 4a3f95b commit 73d0d3c

9 files changed

Lines changed: 5 additions & 31 deletions

File tree

‎drivers/bluetooth/bfusb.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -479,9 +479,6 @@ static int bfusb_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
479479

480480
BT_DBG("hdev %p skb %p type %d len %d", hdev, skb, bt_cb(skb)->pkt_type, skb->len);
481481

482-
if (!test_bit(HCI_RUNNING, &hdev->flags))
483-
return -EBUSY;
484-
485482
switch (bt_cb(skb)->pkt_type) {
486483
case HCI_COMMAND_PKT:
487484
hdev->stat.cmd_tx++;

‎drivers/bluetooth/bpa10x.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -360,9 +360,6 @@ static int bpa10x_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
360360

361361
BT_DBG("%s", hdev->name);
362362

363-
if (!test_bit(HCI_RUNNING, &hdev->flags))
364-
return -EBUSY;
365-
366363
skb->dev = (void *) hdev;
367364

368365
urb = usb_alloc_urb(0, GFP_ATOMIC);

‎drivers/bluetooth/btmrvl_main.c‎

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -436,13 +436,6 @@ static int btmrvl_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
436436

437437
BT_DBG("type=%d, len=%d", skb->pkt_type, skb->len);
438438

439-
if (!test_bit(HCI_RUNNING, &hdev->flags)) {
440-
BT_ERR("Failed testing HCI_RUNING, flags=%lx", hdev->flags);
441-
print_hex_dump_bytes("data: ", DUMP_PREFIX_OFFSET,
442-
skb->data, skb->len);
443-
return -EBUSY;
444-
}
445-
446439
switch (bt_cb(skb)->pkt_type) {
447440
case HCI_COMMAND_PKT:
448441
hdev->stat.cmd_tx++;

‎drivers/bluetooth/btsdio.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,6 @@ static int btsdio_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
261261

262262
BT_DBG("%s", hdev->name);
263263

264-
if (!test_bit(HCI_RUNNING, &hdev->flags))
265-
return -EBUSY;
266-
267264
switch (bt_cb(skb)->pkt_type) {
268265
case HCI_COMMAND_PKT:
269266
hdev->stat.cmd_tx++;

‎drivers/bluetooth/btusb.c‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1156,9 +1156,6 @@ static int btusb_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
11561156

11571157
BT_DBG("%s", hdev->name);
11581158

1159-
if (!test_bit(HCI_RUNNING, &hdev->flags))
1160-
return -EBUSY;
1161-
11621159
switch (bt_cb(skb)->pkt_type) {
11631160
case HCI_COMMAND_PKT:
11641161
urb = alloc_ctrl_urb(hdev, skb);
@@ -1843,9 +1840,6 @@ static int btusb_send_frame_intel(struct hci_dev *hdev, struct sk_buff *skb)
18431840

18441841
BT_DBG("%s", hdev->name);
18451842

1846-
if (!test_bit(HCI_RUNNING, &hdev->flags))
1847-
return -EBUSY;
1848-
18491843
switch (bt_cb(skb)->pkt_type) {
18501844
case HCI_COMMAND_PKT:
18511845
if (test_bit(BTUSB_BOOTLOADER, &data->flags)) {

‎drivers/bluetooth/btwilink.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,6 @@ static int ti_st_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
256256
struct ti_st *hst;
257257
long len;
258258

259-
if (!test_bit(HCI_RUNNING, &hdev->flags))
260-
return -EBUSY;
261-
262259
hst = hci_get_drvdata(hdev);
263260

264261
/* Prepend skb with frame type */

‎drivers/bluetooth/hci_ldisc.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,9 +254,6 @@ static int hci_uart_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
254254
{
255255
struct hci_uart *hu = hci_get_drvdata(hdev);
256256

257-
if (!test_bit(HCI_RUNNING, &hdev->flags))
258-
return -EBUSY;
259-
260257
BT_DBG("%s: type %d len %d", hdev->name, bt_cb(skb)->pkt_type, skb->len);
261258

262259
hu->proto->enqueue(hu, skb);

‎drivers/bluetooth/hci_vhci.c‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,6 @@ static int vhci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
8585
{
8686
struct vhci_data *data = hci_get_drvdata(hdev);
8787

88-
if (!test_bit(HCI_RUNNING, &hdev->flags))
89-
return -EBUSY;
90-
9188
memcpy(skb_push(skb, 1), &bt_cb(skb)->pkt_type, 1);
9289
skb_queue_tail(&data->readq, skb);
9390

‎net/bluetooth/hci_core.c‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3536,6 +3536,11 @@ static void hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
35363536
/* Get rid of skb owner, prior to sending to the driver. */
35373537
skb_orphan(skb);
35383538

3539+
if (!test_bit(HCI_RUNNING, &hdev->flags)) {
3540+
kfree_skb(skb);
3541+
return;
3542+
}
3543+
35393544
err = hdev->send(hdev, skb);
35403545
if (err < 0) {
35413546
BT_ERR("%s sending frame failed (%d)", hdev->name, err);

0 commit comments

Comments
 (0)