Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Bluetooth: Use new hci_skb_pkt_* wrappers for core packet handling

The new hci_skb_pkt_* wrappers only help if they are used consistently
in the Bluetooth subsystem. So first convert the core packet handling.

Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>

+33 -32
+12 -11
net/bluetooth/hci_core.c
··· 3566 3566 if (!skb) 3567 3567 return -ENOMEM; 3568 3568 3569 - bt_cb(skb)->pkt_type = HCI_EVENT_PKT; 3569 + hci_skb_pkt_type(skb) = HCI_EVENT_PKT; 3570 3570 memcpy(skb_put(skb, 3), hw_err, 3); 3571 3571 3572 3572 /* Send Hardware Error to upper stack */ ··· 3583 3583 return -ENXIO; 3584 3584 } 3585 3585 3586 - if (bt_cb(skb)->pkt_type != HCI_EVENT_PKT && 3587 - bt_cb(skb)->pkt_type != HCI_ACLDATA_PKT && 3588 - bt_cb(skb)->pkt_type != HCI_SCODATA_PKT) { 3586 + if (hci_skb_pkt_type(skb) != HCI_EVENT_PKT && 3587 + hci_skb_pkt_type(skb) != HCI_ACLDATA_PKT && 3588 + hci_skb_pkt_type(skb) != HCI_SCODATA_PKT) { 3589 3589 kfree_skb(skb); 3590 3590 return -EINVAL; 3591 3591 } ··· 3607 3607 int hci_recv_diag(struct hci_dev *hdev, struct sk_buff *skb) 3608 3608 { 3609 3609 /* Mark as diagnostic packet */ 3610 - bt_cb(skb)->pkt_type = HCI_DIAG_PKT; 3610 + hci_skb_pkt_type(skb) = HCI_DIAG_PKT; 3611 3611 3612 3612 /* Time stamp */ 3613 3613 __net_timestamp(skb); ··· 3649 3649 { 3650 3650 int err; 3651 3651 3652 - BT_DBG("%s type %d len %d", hdev->name, bt_cb(skb)->pkt_type, skb->len); 3652 + BT_DBG("%s type %d len %d", hdev->name, hci_skb_pkt_type(skb), 3653 + skb->len); 3653 3654 3654 3655 /* Time stamp */ 3655 3656 __net_timestamp(skb); ··· 3763 3762 skb->len = skb_headlen(skb); 3764 3763 skb->data_len = 0; 3765 3764 3766 - bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT; 3765 + hci_skb_pkt_type(skb) = HCI_ACLDATA_PKT; 3767 3766 3768 3767 switch (hdev->dev_type) { 3769 3768 case HCI_BREDR: ··· 3803 3802 do { 3804 3803 skb = list; list = list->next; 3805 3804 3806 - bt_cb(skb)->pkt_type = HCI_ACLDATA_PKT; 3805 + hci_skb_pkt_type(skb) = HCI_ACLDATA_PKT; 3807 3806 hci_add_acl_hdr(skb, conn->handle, flags); 3808 3807 3809 3808 BT_DBG("%s frag %p len %d", hdev->name, skb, skb->len); ··· 3841 3840 skb_reset_transport_header(skb); 3842 3841 memcpy(skb_transport_header(skb), &hdr, HCI_SCO_HDR_SIZE); 3843 3842 3844 - bt_cb(skb)->pkt_type = HCI_SCODATA_PKT; 3843 + hci_skb_pkt_type(skb) = HCI_SCODATA_PKT; 3845 3844 3846 3845 skb_queue_tail(&conn->data_q, skb); 3847 3846 queue_work(hdev->workqueue, &hdev->tx_work); ··· 4500 4499 4501 4500 if (test_bit(HCI_INIT, &hdev->flags)) { 4502 4501 /* Don't process data packets in this states. */ 4503 - switch (bt_cb(skb)->pkt_type) { 4502 + switch (hci_skb_pkt_type(skb)) { 4504 4503 case HCI_ACLDATA_PKT: 4505 4504 case HCI_SCODATA_PKT: 4506 4505 kfree_skb(skb); ··· 4509 4508 } 4510 4509 4511 4510 /* Process frame */ 4512 - switch (bt_cb(skb)->pkt_type) { 4511 + switch (hci_skb_pkt_type(skb)) { 4513 4512 case HCI_EVENT_PKT: 4514 4513 BT_DBG("%s Event packet", hdev->name); 4515 4514 hci_event_packet(hdev, skb);
+2 -2
net/bluetooth/hci_request.c
··· 98 98 99 99 BT_DBG("skb len %d", skb->len); 100 100 101 - bt_cb(skb)->pkt_type = HCI_COMMAND_PKT; 102 - bt_cb(skb)->hci.opcode = opcode; 101 + hci_skb_pkt_type(skb) = HCI_COMMAND_PKT; 102 + hci_skb_opcode(skb) = opcode; 103 103 104 104 return skb; 105 105 }
+19 -19
net/bluetooth/hci_sock.c
··· 120 120 /* Apply filter */ 121 121 flt = &hci_pi(sk)->filter; 122 122 123 - flt_type = bt_cb(skb)->pkt_type & HCI_FLT_TYPE_BITS; 123 + flt_type = hci_skb_pkt_type(skb) & HCI_FLT_TYPE_BITS; 124 124 125 125 if (!test_bit(flt_type, &flt->type_mask)) 126 126 return true; 127 127 128 128 /* Extra filter for event packets only */ 129 - if (bt_cb(skb)->pkt_type != HCI_EVENT_PKT) 129 + if (hci_skb_pkt_type(skb) != HCI_EVENT_PKT) 130 130 return false; 131 131 132 132 flt_event = (*(__u8 *)skb->data & HCI_FLT_EVENT_BITS); ··· 170 170 continue; 171 171 172 172 if (hci_pi(sk)->channel == HCI_CHANNEL_RAW) { 173 - if (bt_cb(skb)->pkt_type != HCI_COMMAND_PKT && 174 - bt_cb(skb)->pkt_type != HCI_EVENT_PKT && 175 - bt_cb(skb)->pkt_type != HCI_ACLDATA_PKT && 176 - bt_cb(skb)->pkt_type != HCI_SCODATA_PKT) 173 + if (hci_skb_pkt_type(skb) != HCI_COMMAND_PKT && 174 + hci_skb_pkt_type(skb) != HCI_EVENT_PKT && 175 + hci_skb_pkt_type(skb) != HCI_ACLDATA_PKT && 176 + hci_skb_pkt_type(skb) != HCI_SCODATA_PKT) 177 177 continue; 178 178 if (is_filtered_packet(sk, skb)) 179 179 continue; 180 180 } else if (hci_pi(sk)->channel == HCI_CHANNEL_USER) { 181 181 if (!bt_cb(skb)->incoming) 182 182 continue; 183 - if (bt_cb(skb)->pkt_type != HCI_EVENT_PKT && 184 - bt_cb(skb)->pkt_type != HCI_ACLDATA_PKT && 185 - bt_cb(skb)->pkt_type != HCI_SCODATA_PKT) 183 + if (hci_skb_pkt_type(skb) != HCI_EVENT_PKT && 184 + hci_skb_pkt_type(skb) != HCI_ACLDATA_PKT && 185 + hci_skb_pkt_type(skb) != HCI_SCODATA_PKT) 186 186 continue; 187 187 } else { 188 188 /* Don't send frame to other channel types */ ··· 196 196 continue; 197 197 198 198 /* Put type byte before the data */ 199 - memcpy(skb_push(skb_copy, 1), &bt_cb(skb)->pkt_type, 1); 199 + memcpy(skb_push(skb_copy, 1), &hci_skb_pkt_type(skb), 1); 200 200 } 201 201 202 202 nskb = skb_clone(skb_copy, GFP_ATOMIC); ··· 262 262 263 263 BT_DBG("hdev %p len %d", hdev, skb->len); 264 264 265 - switch (bt_cb(skb)->pkt_type) { 265 + switch (hci_skb_pkt_type(skb)) { 266 266 case HCI_COMMAND_PKT: 267 267 opcode = cpu_to_le16(HCI_MON_COMMAND_PKT); 268 268 break; ··· 447 447 bt_cb(skb)->incoming = 1; 448 448 __net_timestamp(skb); 449 449 450 - bt_cb(skb)->pkt_type = HCI_EVENT_PKT; 450 + hci_skb_pkt_type(skb) = HCI_EVENT_PKT; 451 451 hci_send_to_sock(hdev, skb); 452 452 kfree_skb(skb); 453 453 } ··· 1211 1211 goto drop; 1212 1212 } 1213 1213 1214 - bt_cb(skb)->pkt_type = *((unsigned char *) skb->data); 1214 + hci_skb_pkt_type(skb) = *((unsigned char *) skb->data); 1215 1215 skb_pull(skb, 1); 1216 1216 1217 1217 if (hci_pi(sk)->channel == HCI_CHANNEL_USER) { ··· 1220 1220 * 1221 1221 * However check that the packet type is valid. 1222 1222 */ 1223 - if (bt_cb(skb)->pkt_type != HCI_COMMAND_PKT && 1224 - bt_cb(skb)->pkt_type != HCI_ACLDATA_PKT && 1225 - bt_cb(skb)->pkt_type != HCI_SCODATA_PKT) { 1223 + if (hci_skb_pkt_type(skb) != HCI_COMMAND_PKT && 1224 + hci_skb_pkt_type(skb) != HCI_ACLDATA_PKT && 1225 + hci_skb_pkt_type(skb) != HCI_SCODATA_PKT) { 1226 1226 err = -EINVAL; 1227 1227 goto drop; 1228 1228 } 1229 1229 1230 1230 skb_queue_tail(&hdev->raw_q, skb); 1231 1231 queue_work(hdev->workqueue, &hdev->tx_work); 1232 - } else if (bt_cb(skb)->pkt_type == HCI_COMMAND_PKT) { 1232 + } else if (hci_skb_pkt_type(skb) == HCI_COMMAND_PKT) { 1233 1233 u16 opcode = get_unaligned_le16(skb->data); 1234 1234 u16 ogf = hci_opcode_ogf(opcode); 1235 1235 u16 ocf = hci_opcode_ocf(opcode); ··· 1260 1260 goto drop; 1261 1261 } 1262 1262 1263 - if (bt_cb(skb)->pkt_type != HCI_ACLDATA_PKT && 1264 - bt_cb(skb)->pkt_type != HCI_SCODATA_PKT) { 1263 + if (hci_skb_pkt_type(skb) != HCI_ACLDATA_PKT && 1264 + hci_skb_pkt_type(skb) != HCI_SCODATA_PKT) { 1265 1265 err = -EINVAL; 1266 1266 goto drop; 1267 1267 }