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

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: af_bluetooth: Make BT_PKT_STATUS generic

This makes the handling of BT_PKT_STATUS more generic so it can be
reused by sockets other than SCO like BT_DEFER_SETUP, etc.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

+14 -28
+3 -5
include/net/bluetooth/bluetooth.h
··· 386 386 enum { 387 387 BT_SK_DEFER_SETUP, 388 388 BT_SK_SUSPEND, 389 + BT_SK_PKT_STATUS 389 390 }; 390 391 391 392 struct bt_sock_list { ··· 433 432 struct l2cap_chan *chan; 434 433 }; 435 434 436 - struct sco_ctrl { 437 - u8 pkt_status; 438 - }; 439 - 440 435 struct hci_dev; 441 436 442 437 typedef void (*hci_req_complete_t)(struct hci_dev *hdev, u8 status, u16 opcode); ··· 463 466 u8 force_active; 464 467 u16 expect; 465 468 u8 incoming:1; 469 + u8 pkt_status:2; 466 470 union { 467 471 struct l2cap_ctrl l2cap; 468 - struct sco_ctrl sco; 469 472 struct hci_ctrl hci; 470 473 struct mgmt_ctrl mgmt; 471 474 struct scm_creds creds; ··· 474 477 #define bt_cb(skb) ((struct bt_skb_cb *)((skb)->cb)) 475 478 476 479 #define hci_skb_pkt_type(skb) bt_cb((skb))->pkt_type 480 + #define hci_skb_pkt_status(skb) bt_cb((skb))->pkt_status 477 481 #define hci_skb_expect(skb) bt_cb((skb))->expect 478 482 #define hci_skb_opcode(skb) bt_cb((skb))->hci.opcode 479 483 #define hci_skb_event(skb) bt_cb((skb))->hci.req_event
-2
include/net/bluetooth/sco.h
··· 46 46 __u8 dev_class[3]; 47 47 }; 48 48 49 - #define SCO_CMSG_PKT_STATUS 0x01 50 - 51 49 #endif /* __SCO_H */
+6 -2
net/bluetooth/af_bluetooth.c
··· 333 333 bt_sk(sk)->skb_msg_name(skb, msg->msg_name, 334 334 &msg->msg_namelen); 335 335 336 - if (bt_sk(sk)->skb_put_cmsg) 337 - bt_sk(sk)->skb_put_cmsg(skb, msg, sk); 336 + if (test_bit(BT_SK_PKT_STATUS, &bt_sk(sk)->flags)) { 337 + u8 pkt_status = hci_skb_pkt_status(skb); 338 + 339 + put_cmsg(msg, SOL_BLUETOOTH, BT_SCM_PKT_STATUS, 340 + sizeof(pkt_status), &pkt_status); 341 + } 338 342 } 339 343 340 344 skb_free_datagram(sk, skb);
+1 -1
net/bluetooth/hci_core.c
··· 3895 3895 3896 3896 if (conn) { 3897 3897 /* Send to upper protocol */ 3898 - bt_cb(skb)->sco.pkt_status = flags & 0x03; 3898 + hci_skb_pkt_status(skb) = flags & 0x03; 3899 3899 sco_recv_scodata(conn, skb); 3900 3900 return; 3901 3901 } else {
+4 -18
net/bluetooth/sco.c
··· 68 68 bdaddr_t dst; 69 69 __u32 flags; 70 70 __u16 setting; 71 - __u8 cmsg_mask; 72 71 struct bt_codec codec; 73 72 struct sco_conn *conn; 74 73 }; ··· 470 471 release_sock(sk); 471 472 } 472 473 473 - static void sco_skb_put_cmsg(struct sk_buff *skb, struct msghdr *msg, 474 - struct sock *sk) 475 - { 476 - if (sco_pi(sk)->cmsg_mask & SCO_CMSG_PKT_STATUS) 477 - put_cmsg(msg, SOL_BLUETOOTH, BT_SCM_PKT_STATUS, 478 - sizeof(bt_cb(skb)->sco.pkt_status), 479 - &bt_cb(skb)->sco.pkt_status); 480 - } 481 - 482 474 static void sco_sock_init(struct sock *sk, struct sock *parent) 483 475 { 484 476 BT_DBG("sk %p", sk); ··· 478 488 sk->sk_type = parent->sk_type; 479 489 bt_sk(sk)->flags = bt_sk(parent)->flags; 480 490 security_sk_clone(parent, sk); 481 - } else { 482 - bt_sk(sk)->skb_put_cmsg = sco_skb_put_cmsg; 483 491 } 484 492 } 485 493 ··· 895 907 } 896 908 897 909 if (opt) 898 - sco_pi(sk)->cmsg_mask |= SCO_CMSG_PKT_STATUS; 910 + set_bit(BT_SK_PKT_STATUS, &bt_sk(sk)->flags); 899 911 else 900 - sco_pi(sk)->cmsg_mask &= SCO_CMSG_PKT_STATUS; 912 + clear_bit(BT_SK_PKT_STATUS, &bt_sk(sk)->flags); 901 913 break; 902 914 903 915 case BT_CODEC: ··· 1028 1040 int len, err = 0; 1029 1041 struct bt_voice voice; 1030 1042 u32 phys; 1031 - int pkt_status; 1032 1043 int buf_len; 1033 1044 struct codec_list *c; 1034 1045 u8 num_codecs, i, __user *ptr; ··· 1081 1094 break; 1082 1095 1083 1096 case BT_PKT_STATUS: 1084 - pkt_status = (sco_pi(sk)->cmsg_mask & SCO_CMSG_PKT_STATUS); 1085 - 1086 - if (put_user(pkt_status, (int __user *)optval)) 1097 + if (put_user(test_bit(BT_SK_PKT_STATUS, &bt_sk(sk)->flags), 1098 + (int __user *)optval)) 1087 1099 err = -EFAULT; 1088 1100 break; 1089 1101