Skip to content

Commit

Permalink
Bluetooth: Move HCI_RUNNING check into hci_send_frame
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Johan Hedberg <[email protected]>
  • Loading branch information
holtmann authored and Johan Hedberg committed Oct 5, 2015
1 parent 4a3f95b commit 73d0d3c
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 31 deletions.
3 changes: 0 additions & 3 deletions drivers/bluetooth/bfusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
3 changes: 0 additions & 3 deletions drivers/bluetooth/bpa10x.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
7 changes: 0 additions & 7 deletions drivers/bluetooth/btmrvl_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
3 changes: 0 additions & 3 deletions drivers/bluetooth/btsdio.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++;
Expand Down
6 changes: 0 additions & 6 deletions drivers/bluetooth/btusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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)) {
Expand Down
3 changes: 0 additions & 3 deletions drivers/bluetooth/btwilink.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
3 changes: 0 additions & 3 deletions drivers/bluetooth/hci_ldisc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
3 changes: 0 additions & 3 deletions drivers/bluetooth/hci_vhci.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
5 changes: 5 additions & 0 deletions net/bluetooth/hci_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 73d0d3c

Please sign in to comment.