aboutsummaryrefslogtreecommitdiffstats
path: root/net/bluetooth
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2013-10-10 17:54:17 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2013-10-10 18:10:09 -0400
commit57d17d70dfa4345fbe3e0d049504aa20626ed0e1 (patch)
tree530a58c1407249364b99f2cf48b722ecfa91795f /net/bluetooth
parentac4b7236610cef99821f40f44a74030b85d85270 (diff)
Bluetooth: Move skb->dev assignment for hdev->send into central place
The assignement of skb->dev is done all over the place. So it makes it hard to eventually get rid of it. Move it all in one central place so it gets assigned right before calling hdev->send driver callback. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth')
-rw-r--r--net/bluetooth/hci_core.c25
-rw-r--r--net/bluetooth/hci_sock.c2
2 files changed, 10 insertions, 17 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 593b4efb1d7f..925bd47c4a3c 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -2697,10 +2697,8 @@ int hci_unregister_cb(struct hci_cb *cb)
2697} 2697}
2698EXPORT_SYMBOL(hci_unregister_cb); 2698EXPORT_SYMBOL(hci_unregister_cb);
2699 2699
2700static int hci_send_frame(struct sk_buff *skb) 2700static int hci_send_frame(struct hci_dev *hdev, struct sk_buff *skb)
2701{ 2701{
2702 struct hci_dev *hdev = (struct hci_dev *) skb->dev;
2703
2704 if (!hdev) { 2702 if (!hdev) {
2705 kfree_skb(skb); 2703 kfree_skb(skb);
2706 return -ENODEV; 2704 return -ENODEV;
@@ -2722,6 +2720,8 @@ static int hci_send_frame(struct sk_buff *skb)
2722 /* Get rid of skb owner, prior to sending to the driver. */ 2720 /* Get rid of skb owner, prior to sending to the driver. */
2723 skb_orphan(skb); 2721 skb_orphan(skb);
2724 2722
2723 skb->dev = (void *) hdev;
2724
2725 return hdev->send(skb); 2725 return hdev->send(skb);
2726} 2726}
2727 2727
@@ -2785,7 +2785,6 @@ static struct sk_buff *hci_prepare_cmd(struct hci_dev *hdev, u16 opcode,
2785 BT_DBG("skb len %d", skb->len); 2785 BT_DBG("skb len %d", skb->len);
2786 2786
2787 bt_cb(skb)->pkt_type = HCI_COMMAND_PKT; 2787 bt_cb(skb)->pkt_type = HCI_COMMAND_PKT;
2788 skb->dev = (void *) hdev;
2789 2788
2790 return skb; 2789 return skb;
2791} 2790}
@@ -2929,7 +2928,6 @@ static void hci_queue_acl(struct hci_chan *chan, struct sk_buff_head *queue,
2929 do { 2928 do {
2930 skb = list; list = list->next; 2929 skb = list; list = list->next;
2931 2930
2932 skb->dev = (void *) hdev;
2933 bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT; 2931 bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT;
2934 hci_add_acl_hdr(skb, conn->handle, flags); 2932 hci_add_acl_hdr(skb, conn->handle, flags);
2935 2933
@@ -2948,8 +2946,6 @@ void hci_send_acl(struct hci_chan *chan, struct sk_buff *skb, __u16 flags)
2948 2946
2949 BT_DBG("%s chan %p flags 0x%4.4x", hdev->name, chan, flags); 2947 BT_DBG("%s chan %p flags 0x%4.4x", hdev->name, chan, flags);
2950 2948
2951 skb->dev = (void *) hdev;
2952
2953 hci_queue_acl(chan, &chan->data_q, skb, flags); 2949 hci_queue_acl(chan, &chan->data_q, skb, flags);
2954 2950
2955 queue_work(hdev->workqueue, &hdev->tx_work); 2951 queue_work(hdev->workqueue, &hdev->tx_work);
@@ -2970,7 +2966,6 @@ void hci_send_sco(struct hci_conn *conn, struct sk_buff *skb)
2970 skb_reset_transport_header(skb); 2966 skb_reset_transport_header(skb);
2971 memcpy(skb_transport_header(skb), &hdr, HCI_SCO_HDR_SIZE); 2967 memcpy(skb_transport_header(skb), &hdr, HCI_SCO_HDR_SIZE);
2972 2968
2973 skb->dev = (void *) hdev;
2974 bt_cb(skb)->pkt_type = HCI_SCODATA_PKT; 2969 bt_cb(skb)->pkt_type = HCI_SCODATA_PKT;
2975 2970
2976 skb_queue_tail(&conn->data_q, skb); 2971 skb_queue_tail(&conn->data_q, skb);
@@ -3235,7 +3230,7 @@ static void hci_sched_acl_pkt(struct hci_dev *hdev)
3235 hci_conn_enter_active_mode(chan->conn, 3230 hci_conn_enter_active_mode(chan->conn,
3236 bt_cb(skb)->force_active); 3231 bt_cb(skb)->force_active);
3237 3232
3238 hci_send_frame(skb); 3233 hci_send_frame(hdev, skb);
3239 hdev->acl_last_tx = jiffies; 3234 hdev->acl_last_tx = jiffies;
3240 3235
3241 hdev->acl_cnt--; 3236 hdev->acl_cnt--;
@@ -3287,7 +3282,7 @@ static void hci_sched_acl_blk(struct hci_dev *hdev)
3287 hci_conn_enter_active_mode(chan->conn, 3282 hci_conn_enter_active_mode(chan->conn,
3288 bt_cb(skb)->force_active); 3283 bt_cb(skb)->force_active);
3289 3284
3290 hci_send_frame(skb); 3285 hci_send_frame(hdev, skb);
3291 hdev->acl_last_tx = jiffies; 3286 hdev->acl_last_tx = jiffies;
3292 3287
3293 hdev->block_cnt -= blocks; 3288 hdev->block_cnt -= blocks;
@@ -3340,7 +3335,7 @@ static void hci_sched_sco(struct hci_dev *hdev)
3340 while (hdev->sco_cnt && (conn = hci_low_sent(hdev, SCO_LINK, &quote))) { 3335 while (hdev->sco_cnt && (conn = hci_low_sent(hdev, SCO_LINK, &quote))) {
3341 while (quote-- && (skb = skb_dequeue(&conn->data_q))) { 3336 while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
3342 BT_DBG("skb %p len %d", skb, skb->len); 3337 BT_DBG("skb %p len %d", skb, skb->len);
3343 hci_send_frame(skb); 3338 hci_send_frame(hdev, skb);
3344 3339
3345 conn->sent++; 3340 conn->sent++;
3346 if (conn->sent == ~0) 3341 if (conn->sent == ~0)
@@ -3364,7 +3359,7 @@ static void hci_sched_esco(struct hci_dev *hdev)
3364 &quote))) { 3359 &quote))) {
3365 while (quote-- && (skb = skb_dequeue(&conn->data_q))) { 3360 while (quote-- && (skb = skb_dequeue(&conn->data_q))) {
3366 BT_DBG("skb %p len %d", skb, skb->len); 3361 BT_DBG("skb %p len %d", skb, skb->len);
3367 hci_send_frame(skb); 3362 hci_send_frame(hdev, skb);
3368 3363
3369 conn->sent++; 3364 conn->sent++;
3370 if (conn->sent == ~0) 3365 if (conn->sent == ~0)
@@ -3406,7 +3401,7 @@ static void hci_sched_le(struct hci_dev *hdev)
3406 3401
3407 skb = skb_dequeue(&chan->data_q); 3402 skb = skb_dequeue(&chan->data_q);
3408 3403
3409 hci_send_frame(skb); 3404 hci_send_frame(hdev, skb);
3410 hdev->le_last_tx = jiffies; 3405 hdev->le_last_tx = jiffies;
3411 3406
3412 cnt--; 3407 cnt--;
@@ -3442,7 +3437,7 @@ static void hci_tx_work(struct work_struct *work)
3442 3437
3443 /* Send next queued raw (unknown type) packet */ 3438 /* Send next queued raw (unknown type) packet */
3444 while ((skb = skb_dequeue(&hdev->raw_q))) 3439 while ((skb = skb_dequeue(&hdev->raw_q)))
3445 hci_send_frame(skb); 3440 hci_send_frame(hdev, skb);
3446} 3441}
3447 3442
3448/* ----- HCI RX task (incoming data processing) ----- */ 3443/* ----- HCI RX task (incoming data processing) ----- */
@@ -3688,7 +3683,7 @@ static void hci_cmd_work(struct work_struct *work)
3688 hdev->sent_cmd = skb_clone(skb, GFP_KERNEL); 3683 hdev->sent_cmd = skb_clone(skb, GFP_KERNEL);
3689 if (hdev->sent_cmd) { 3684 if (hdev->sent_cmd) {
3690 atomic_dec(&hdev->cmd_cnt); 3685 atomic_dec(&hdev->cmd_cnt);
3691 hci_send_frame(skb); 3686 hci_send_frame(hdev, skb);
3692 if (test_bit(HCI_RESET, &hdev->flags)) 3687 if (test_bit(HCI_RESET, &hdev->flags))
3693 del_timer(&hdev->cmd_timer); 3688 del_timer(&hdev->cmd_timer);
3694 else 3689 else
diff --git a/net/bluetooth/hci_sock.c b/net/bluetooth/hci_sock.c
index 3beaa0594009..97f96ebdd56d 100644
--- a/net/bluetooth/hci_sock.c
+++ b/net/bluetooth/hci_sock.c
@@ -387,7 +387,6 @@ static void hci_si_event(struct hci_dev *hdev, int type, int dlen, void *data)
387 __net_timestamp(skb); 387 __net_timestamp(skb);
388 388
389 bt_cb(skb)->pkt_type = HCI_EVENT_PKT; 389 bt_cb(skb)->pkt_type = HCI_EVENT_PKT;
390 skb->dev = (void *) hdev;
391 hci_send_to_sock(hdev, skb); 390 hci_send_to_sock(hdev, skb);
392 kfree_skb(skb); 391 kfree_skb(skb);
393} 392}
@@ -942,7 +941,6 @@ static int hci_sock_sendmsg(struct kiocb *iocb, struct socket *sock,
942 941
943 bt_cb(skb)->pkt_type = *((unsigned char *) skb->data); 942 bt_cb(skb)->pkt_type = *((unsigned char *) skb->data);
944 skb_pull(skb, 1); 943 skb_pull(skb, 1);
945 skb->dev = (void *) hdev;
946 944
947 if (hci_pi(sk)->channel == HCI_CHANNEL_RAW && 945 if (hci_pi(sk)->channel == HCI_CHANNEL_RAW &&
948 bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) { 946 bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) {