Skip to content

Commit 709788b

Browse files
committed
Bluetooth: hci_core: Fix using {cis,bis}_capable for current settings
{cis,bis}_capable only indicates the controller supports the feature since it doesn't check that LE is enabled so it shall not be used for current setting, instead this introduces {cis,bis}_enabled macros that can be used to indicate that these features are currently enabled. Fixes: 26afbd8 ("Bluetooth: Add initial implementation of CIS connections") Fixes: eca0ae4 ("Bluetooth: Add initial implementation of BIS connections") Fixes: ae75336 ("Bluetooth: Check for ISO support in controller") Signed-off-by: Luiz Augusto von Dentz <[email protected]>
1 parent 099799f commit 709788b

File tree

5 files changed

+28
-17
lines changed

5 files changed

+28
-17
lines changed

include/net/bluetooth/bluetooth.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,7 @@ static inline void sco_exit(void)
647647
#if IS_ENABLED(CONFIG_BT_LE)
648648
int iso_init(void);
649649
int iso_exit(void);
650-
bool iso_enabled(void);
650+
bool iso_inited(void);
651651
#else
652652
static inline int iso_init(void)
653653
{
@@ -659,7 +659,7 @@ static inline int iso_exit(void)
659659
return 0;
660660
}
661661

662-
static inline bool iso_enabled(void)
662+
static inline bool iso_inited(void)
663663
{
664664
return false;
665665
}

include/net/bluetooth/hci_core.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1915,6 +1915,8 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
19151915
!hci_dev_test_flag(dev, HCI_RPA_EXPIRED))
19161916
#define adv_rpa_valid(adv) (bacmp(&adv->random_addr, BDADDR_ANY) && \
19171917
!adv->rpa_expired)
1918+
#define le_enabled(dev) (lmp_le_capable(dev) && \
1919+
hci_dev_test_flag(dev, HCI_LE_ENABLED))
19181920

19191921
#define scan_1m(dev) (((dev)->le_tx_def_phys & HCI_LE_SET_PHY_1M) || \
19201922
((dev)->le_rx_def_phys & HCI_LE_SET_PHY_1M))
@@ -1981,14 +1983,23 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
19811983

19821984
/* CIS Master/Slave and BIS support */
19831985
#define iso_capable(dev) (cis_capable(dev) || bis_capable(dev))
1986+
#define iso_enabled(dev) (le_enabled(dev) && iso_capable(dev))
19841987
#define cis_capable(dev) \
19851988
(cis_central_capable(dev) || cis_peripheral_capable(dev))
1989+
#define cis_enabled(dev) (le_enabled(dev) && cis_capable(dev))
19861990
#define cis_central_capable(dev) \
19871991
((dev)->le_features[3] & HCI_LE_CIS_CENTRAL)
1992+
#define cis_central_enabled(dev) \
1993+
(le_enabled(dev) && cis_central_capable(dev))
19881994
#define cis_peripheral_capable(dev) \
19891995
((dev)->le_features[3] & HCI_LE_CIS_PERIPHERAL)
1996+
#define cis_peripheral_enabled(dev) \
1997+
(le_enabled(dev) && cis_peripheral_capable(dev))
19901998
#define bis_capable(dev) ((dev)->le_features[3] & HCI_LE_ISO_BROADCASTER)
1991-
#define sync_recv_capable(dev) ((dev)->le_features[3] & HCI_LE_ISO_SYNC_RECEIVER)
1999+
#define bis_enabled(dev) (le_enabled(dev) && bis_capable(dev))
2000+
#define sync_recv_capable(dev) \
2001+
((dev)->le_features[3] & HCI_LE_ISO_SYNC_RECEIVER)
2002+
#define sync_recv_enabled(dev) (le_enabled(dev) && sync_recv_capable(dev))
19922003

19932004
#define mws_transport_config_capable(dev) (((dev)->commands[30] & 0x08) && \
19942005
(!hci_test_quirk((dev), HCI_QUIRK_BROKEN_MWS_TRANSPORT_CONFIG)))

net/bluetooth/hci_sync.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4531,14 +4531,14 @@ static int hci_le_set_host_feature_sync(struct hci_dev *hdev)
45314531
{
45324532
struct hci_cp_le_set_host_feature cp;
45334533

4534-
if (!cis_capable(hdev))
4534+
if (!iso_capable(hdev))
45354535
return 0;
45364536

45374537
memset(&cp, 0, sizeof(cp));
45384538

45394539
/* Connected Isochronous Channels (Host Support) */
45404540
cp.bit_number = 32;
4541-
cp.bit_value = 1;
4541+
cp.bit_value = iso_enabled(hdev) ? 0x01 : 0x00;
45424542

45434543
return __hci_cmd_sync_status(hdev, HCI_OP_LE_SET_HOST_FEATURE,
45444544
sizeof(cp), &cp, HCI_CMD_TIMEOUT);

net/bluetooth/iso.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2483,11 +2483,11 @@ static const struct net_proto_family iso_sock_family_ops = {
24832483
.create = iso_sock_create,
24842484
};
24852485

2486-
static bool iso_inited;
2486+
static bool inited;
24872487

2488-
bool iso_enabled(void)
2488+
bool iso_inited(void)
24892489
{
2490-
return iso_inited;
2490+
return inited;
24912491
}
24922492

24932493
int iso_init(void)
@@ -2496,7 +2496,7 @@ int iso_init(void)
24962496

24972497
BUILD_BUG_ON(sizeof(struct sockaddr_iso) > sizeof(struct sockaddr));
24982498

2499-
if (iso_inited)
2499+
if (inited)
25002500
return -EALREADY;
25012501

25022502
err = proto_register(&iso_proto, 0);
@@ -2524,7 +2524,7 @@ int iso_init(void)
25242524
iso_debugfs = debugfs_create_file("iso", 0444, bt_debugfs,
25252525
NULL, &iso_debugfs_fops);
25262526

2527-
iso_inited = true;
2527+
inited = true;
25282528

25292529
return 0;
25302530

@@ -2535,7 +2535,7 @@ int iso_init(void)
25352535

25362536
int iso_exit(void)
25372537
{
2538-
if (!iso_inited)
2538+
if (!inited)
25392539
return -EALREADY;
25402540

25412541
bt_procfs_cleanup(&init_net, "iso");
@@ -2549,7 +2549,7 @@ int iso_exit(void)
25492549

25502550
proto_unregister(&iso_proto);
25512551

2552-
iso_inited = false;
2552+
inited = false;
25532553

25542554
return 0;
25552555
}

net/bluetooth/mgmt.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -922,16 +922,16 @@ static u32 get_current_settings(struct hci_dev *hdev)
922922
if (hci_dev_test_flag(hdev, HCI_WIDEBAND_SPEECH_ENABLED))
923923
settings |= MGMT_SETTING_WIDEBAND_SPEECH;
924924

925-
if (cis_central_capable(hdev))
925+
if (cis_central_enabled(hdev))
926926
settings |= MGMT_SETTING_CIS_CENTRAL;
927927

928-
if (cis_peripheral_capable(hdev))
928+
if (cis_peripheral_enabled(hdev))
929929
settings |= MGMT_SETTING_CIS_PERIPHERAL;
930930

931-
if (bis_capable(hdev))
931+
if (bis_enabled(hdev))
932932
settings |= MGMT_SETTING_ISO_BROADCASTER;
933933

934-
if (sync_recv_capable(hdev))
934+
if (sync_recv_enabled(hdev))
935935
settings |= MGMT_SETTING_ISO_SYNC_RECEIVER;
936936

937937
if (ll_privacy_capable(hdev))
@@ -4513,7 +4513,7 @@ static int read_exp_features_info(struct sock *sk, struct hci_dev *hdev,
45134513
}
45144514

45154515
if (IS_ENABLED(CONFIG_BT_LE)) {
4516-
flags = iso_enabled() ? BIT(0) : 0;
4516+
flags = iso_inited() ? BIT(0) : 0;
45174517
memcpy(rp->features[idx].uuid, iso_socket_uuid, 16);
45184518
rp->features[idx].flags = cpu_to_le32(flags);
45194519
idx++;

0 commit comments

Comments
 (0)