Skip to content

Commit 5d05416

Browse files
finikorgGustavo Padovan
authored andcommitted
Bluetooth: AMP: Check that AMP is present and active
Before starting quering remote AMP controllers make sure that there is local active AMP controller. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
1 parent ced5c33 commit 5d05416

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

‎include/net/bluetooth/hci_core.h‎

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,22 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
779779
#define lmp_host_le_capable(dev) !!((dev)->host_features[0] & LMP_HOST_LE)
780780
#define lmp_host_le_br_capable(dev) !!((dev)->host_features[0] & LMP_HOST_LE_BREDR)
781781

782+
/* returns true if at least one AMP active */
783+
static inline bool hci_amp_capable(void)
784+
{
785+
struct hci_dev *hdev;
786+
bool ret = false;
787+
788+
read_lock(&hci_dev_list_lock);
789+
list_for_each_entry(hdev, &hci_dev_list, list)
790+
if (hdev->amp_type == HCI_AMP &&
791+
test_bit(HCI_UP, &hdev->flags))
792+
ret = true;
793+
read_unlock(&hci_dev_list_lock);
794+
795+
return ret;
796+
}
797+
782798
/* ----- HCI protocols ----- */
783799
#define HCI_PROTO_DEFER 0x01
784800

‎net/bluetooth/l2cap_core.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1013,6 +1013,7 @@ static bool __amp_capable(struct l2cap_chan *chan)
10131013
struct l2cap_conn *conn = chan->conn;
10141014

10151015
if (enable_hs &&
1016+
hci_amp_capable() &&
10161017
chan->chan_policy == BT_CHANNEL_POLICY_AMP_PREFERRED &&
10171018
conn->fixed_chan_mask & L2CAP_FC_A2MP)
10181019
return true;

0 commit comments

Comments
 (0)