linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC 1/5] Bluetooth: AMP: Check that AMP is present and active
@ 2012-11-28 15:59 Andrei Emeltchenko
  2012-11-28 15:59 ` [RFC 2/5] Bluetooth: Refactor l2cap_send_disconn_req Andrei Emeltchenko
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Andrei Emeltchenko @ 2012-11-28 15:59 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

Before starting quering remote AMP controllers make sure
that there is local active AMP controller.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 include/net/bluetooth/hci_core.h |   16 ++++++++++++++++
 net/bluetooth/l2cap_core.c       |    1 +
 2 files changed, 17 insertions(+)

diff --git a/include/net/bluetooth/hci_core.h b/include/net/bluetooth/hci_core.h
index 2f2b743..014a2ea 100644
--- a/include/net/bluetooth/hci_core.h
+++ b/include/net/bluetooth/hci_core.h
@@ -779,6 +779,22 @@ void hci_conn_del_sysfs(struct hci_conn *conn);
 #define lmp_host_le_capable(dev)   !!((dev)->host_features[0] & LMP_HOST_LE)
 #define lmp_host_le_br_capable(dev) !!((dev)->host_features[0] & LMP_HOST_LE_BREDR)
 
+/* returns true if at least one AMP active */
+static inline bool hci_amp_capable(void)
+{
+	struct hci_dev *hdev;
+	bool ret = false;
+
+	read_lock(&hci_dev_list_lock);
+	list_for_each_entry(hdev, &hci_dev_list, list)
+		if (hdev->amp_type == HCI_AMP &&
+		    test_bit(HCI_UP, &hdev->flags))
+			ret = true;
+	read_unlock(&hci_dev_list_lock);
+
+	return ret;
+}
+
 /* ----- HCI protocols ----- */
 #define HCI_PROTO_DEFER             0x01
 
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index b52f66d..39e144f 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -1014,6 +1014,7 @@ static bool __amp_capable(struct l2cap_chan *chan)
 	struct l2cap_conn *conn = chan->conn;
 
 	if (enable_hs &&
+	    hci_amp_capable() &&
 	    chan->chan_policy == BT_CHANNEL_POLICY_AMP_PREFERRED &&
 	    conn->fixed_chan_mask & L2CAP_FC_A2MP)
 		return true;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-11-30 17:50 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-28 15:59 [RFC 1/5] Bluetooth: AMP: Check that AMP is present and active Andrei Emeltchenko
2012-11-28 15:59 ` [RFC 2/5] Bluetooth: Refactor l2cap_send_disconn_req Andrei Emeltchenko
2012-11-28 15:59 ` [RFC 3/5] Bluetooth: Fix missing L2CAP EWS Conf parameter Andrei Emeltchenko
2012-11-29 10:25   ` Gustavo Padovan
2012-11-29 10:38     ` Andrei Emeltchenko
2012-11-28 15:59 ` [RFC 4/5] Bluetooth: Process receiving FCS_NONE in L2CAP Conf Rsp Andrei Emeltchenko
2012-11-29 10:27   ` Gustavo Padovan
2012-11-28 15:59 ` [RFC 5/5] Bluetooth: AMP: Mark controller radio powered down after HCIDEVDOWN Andrei Emeltchenko
2012-11-29 10:34   ` Gustavo Padovan
2012-11-29 15:46     ` [PATCHv2 1/4] Bluetooth: AMP: Check that AMP is present and active Andrei Emeltchenko
2012-11-29 15:46       ` [PATCHv2 2/4] Bluetooth: Fix missing L2CAP EWS Conf parameter Andrei Emeltchenko
2012-11-29 15:46       ` [PATCHv2 3/4] Bluetooth: Process receiving FCS_NONE in L2CAP Conf Rsp Andrei Emeltchenko
2012-11-29 15:46       ` [PATCHv2 4/4] Bluetooth: trivial: Change NO_FCS_RECV to RECV_NO_FCS Andrei Emeltchenko
2012-11-30 17:50         ` Gustavo Padovan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).