aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2013-10-05 14:47:44 -0400
committerJohan Hedberg <johan.hedberg@intel.com>2013-10-06 04:23:39 -0400
commit6ed971ca4f6bd96e26b3166cb5a94f7f8158fe77 (patch)
tree77e17e15e41e9eea1167295dddd6fd3b3334506a
parentece6912648da3fcf257a40774e3aad531c3e5fac (diff)
Bluetooth: Use explicit AMP controller id value for BR/EDR
The special AMP controller id 0 is reserved for the BR/EDR controller that has the main link. It is a fixed value and so use a constant for this throughout the code to make it more visible when the handling is for the BR/EDR channel or when it is for the AMP channel. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
-rw-r--r--include/net/bluetooth/hci.h2
-rw-r--r--net/bluetooth/a2mp.c4
-rw-r--r--net/bluetooth/l2cap_core.c28
3 files changed, 17 insertions, 17 deletions
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 8e3076ebb8ad..393eabc0d21f 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -64,7 +64,7 @@
64#define HCI_AMP 0x01 64#define HCI_AMP 0x01
65 65
66/* First BR/EDR Controller shall have ID = 0 */ 66/* First BR/EDR Controller shall have ID = 0 */
67#define HCI_BREDR_ID 0 67#define AMP_ID_BREDR 0x00
68 68
69/* AMP controller types */ 69/* AMP controller types */
70#define AMP_TYPE_BREDR 0x00 70#define AMP_TYPE_BREDR 0x00
diff --git a/net/bluetooth/a2mp.c b/net/bluetooth/a2mp.c
index b2ef3d392a0e..6d62d3140cf8 100644
--- a/net/bluetooth/a2mp.c
+++ b/net/bluetooth/a2mp.c
@@ -77,7 +77,7 @@ u8 __next_ident(struct amp_mgr *mgr)
77 77
78static inline void __a2mp_cl_bredr(struct a2mp_cl *cl) 78static inline void __a2mp_cl_bredr(struct a2mp_cl *cl)
79{ 79{
80 cl->id = 0; 80 cl->id = AMP_ID_BREDR;
81 cl->type = AMP_TYPE_BREDR; 81 cl->type = AMP_TYPE_BREDR;
82 cl->status = 1; 82 cl->status = 1;
83} 83}
@@ -216,7 +216,7 @@ static int a2mp_discover_rsp(struct amp_mgr *mgr, struct sk_buff *skb,
216 BT_DBG("Remote AMP id %d type %d status %d", cl->id, cl->type, 216 BT_DBG("Remote AMP id %d type %d status %d", cl->id, cl->type,
217 cl->status); 217 cl->status);
218 218
219 if (cl->id != HCI_BREDR_ID && cl->type == HCI_AMP) { 219 if (cl->id != AMP_ID_BREDR && cl->type == HCI_AMP) {
220 struct a2mp_info_req req; 220 struct a2mp_info_req req;
221 221
222 found = true; 222 found = true;
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 02dba4e6df96..b0208e20390c 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3046,8 +3046,8 @@ int l2cap_ertm_init(struct l2cap_chan *chan)
3046 3046
3047 skb_queue_head_init(&chan->tx_q); 3047 skb_queue_head_init(&chan->tx_q);
3048 3048
3049 chan->local_amp_id = 0; 3049 chan->local_amp_id = AMP_ID_BREDR;
3050 chan->move_id = 0; 3050 chan->move_id = AMP_ID_BREDR;
3051 chan->move_state = L2CAP_MOVE_STABLE; 3051 chan->move_state = L2CAP_MOVE_STABLE;
3052 chan->move_role = L2CAP_MOVE_ROLE_NONE; 3052 chan->move_role = L2CAP_MOVE_ROLE_NONE;
3053 3053
@@ -3100,7 +3100,7 @@ static inline bool __l2cap_efs_supported(struct l2cap_conn *conn)
3100static void __l2cap_set_ertm_timeouts(struct l2cap_chan *chan, 3100static void __l2cap_set_ertm_timeouts(struct l2cap_chan *chan,
3101 struct l2cap_conf_rfc *rfc) 3101 struct l2cap_conf_rfc *rfc)
3102{ 3102{
3103 if (chan->local_amp_id && chan->hs_hcon) { 3103 if (chan->local_amp_id != AMP_ID_BREDR && chan->hs_hcon) {
3104 u64 ertm_to = chan->hs_hcon->hdev->amp_be_flush_to; 3104 u64 ertm_to = chan->hs_hcon->hdev->amp_be_flush_to;
3105 3105
3106 /* Class 1 devices have must have ERTM timeouts 3106 /* Class 1 devices have must have ERTM timeouts
@@ -3791,12 +3791,12 @@ static struct l2cap_chan *l2cap_connect(struct l2cap_conn *conn,
3791 * The connection will succeed after the 3791 * The connection will succeed after the
3792 * physical link is up. 3792 * physical link is up.
3793 */ 3793 */
3794 if (amp_id) { 3794 if (amp_id == AMP_ID_BREDR) {
3795 __l2cap_state_change(chan, BT_CONNECT2);
3796 result = L2CAP_CR_PEND;
3797 } else {
3798 __l2cap_state_change(chan, BT_CONFIG); 3795 __l2cap_state_change(chan, BT_CONFIG);
3799 result = L2CAP_CR_SUCCESS; 3796 result = L2CAP_CR_SUCCESS;
3797 } else {
3798 __l2cap_state_change(chan, BT_CONNECT2);
3799 result = L2CAP_CR_PEND;
3800 } 3800 }
3801 status = L2CAP_CS_NO_INFO; 3801 status = L2CAP_CS_NO_INFO;
3802 } 3802 }
@@ -4423,7 +4423,7 @@ static int l2cap_create_channel_req(struct l2cap_conn *conn,
4423 BT_DBG("psm 0x%2.2x, scid 0x%4.4x, amp_id %d", psm, scid, req->amp_id); 4423 BT_DBG("psm 0x%2.2x, scid 0x%4.4x, amp_id %d", psm, scid, req->amp_id);
4424 4424
4425 /* For controller id 0 make BR/EDR connection */ 4425 /* For controller id 0 make BR/EDR connection */
4426 if (req->amp_id == HCI_BREDR_ID) { 4426 if (req->amp_id == AMP_ID_BREDR) {
4427 l2cap_connect(conn, cmd, data, L2CAP_CREATE_CHAN_RSP, 4427 l2cap_connect(conn, cmd, data, L2CAP_CREATE_CHAN_RSP,
4428 req->amp_id); 4428 req->amp_id);
4429 return 0; 4429 return 0;
@@ -4658,7 +4658,7 @@ void l2cap_logical_cfm(struct l2cap_chan *chan, struct hci_chan *hchan,
4658 4658
4659 if (chan->state != BT_CONNECTED) { 4659 if (chan->state != BT_CONNECTED) {
4660 /* Ignore logical link if channel is on BR/EDR */ 4660 /* Ignore logical link if channel is on BR/EDR */
4661 if (chan->local_amp_id) 4661 if (chan->local_amp_id != AMP_ID_BREDR)
4662 l2cap_logical_finish_create(chan, hchan); 4662 l2cap_logical_finish_create(chan, hchan);
4663 } else { 4663 } else {
4664 l2cap_logical_finish_move(chan, hchan); 4664 l2cap_logical_finish_move(chan, hchan);
@@ -4669,7 +4669,7 @@ void l2cap_move_start(struct l2cap_chan *chan)
4669{ 4669{
4670 BT_DBG("chan %p", chan); 4670 BT_DBG("chan %p", chan);
4671 4671
4672 if (chan->local_amp_id == HCI_BREDR_ID) { 4672 if (chan->local_amp_id == AMP_ID_BREDR) {
4673 if (chan->chan_policy != BT_CHANNEL_POLICY_AMP_PREFERRED) 4673 if (chan->chan_policy != BT_CHANNEL_POLICY_AMP_PREFERRED)
4674 return; 4674 return;
4675 chan->move_role = L2CAP_MOVE_ROLE_INITIATOR; 4675 chan->move_role = L2CAP_MOVE_ROLE_INITIATOR;
@@ -4868,7 +4868,7 @@ static inline int l2cap_move_channel_req(struct l2cap_conn *conn,
4868 goto send_move_response; 4868 goto send_move_response;
4869 } 4869 }
4870 4870
4871 if (req->dest_amp_id) { 4871 if (req->dest_amp_id != AMP_ID_BREDR) {
4872 struct hci_dev *hdev; 4872 struct hci_dev *hdev;
4873 hdev = hci_dev_get(req->dest_amp_id); 4873 hdev = hci_dev_get(req->dest_amp_id);
4874 if (!hdev || hdev->dev_type != HCI_AMP || 4874 if (!hdev || hdev->dev_type != HCI_AMP ||
@@ -4898,7 +4898,7 @@ static inline int l2cap_move_channel_req(struct l2cap_conn *conn,
4898 chan->move_id = req->dest_amp_id; 4898 chan->move_id = req->dest_amp_id;
4899 icid = chan->dcid; 4899 icid = chan->dcid;
4900 4900
4901 if (!req->dest_amp_id) { 4901 if (req->dest_amp_id == AMP_ID_BREDR) {
4902 /* Moving to BR/EDR */ 4902 /* Moving to BR/EDR */
4903 if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) { 4903 if (test_bit(CONN_LOCAL_BUSY, &chan->conn_state)) {
4904 chan->move_state = L2CAP_MOVE_WAIT_LOCAL_BUSY; 4904 chan->move_state = L2CAP_MOVE_WAIT_LOCAL_BUSY;
@@ -5090,7 +5090,7 @@ static int l2cap_move_channel_confirm(struct l2cap_conn *conn,
5090 if (chan->move_state == L2CAP_MOVE_WAIT_CONFIRM) { 5090 if (chan->move_state == L2CAP_MOVE_WAIT_CONFIRM) {
5091 if (result == L2CAP_MC_CONFIRMED) { 5091 if (result == L2CAP_MC_CONFIRMED) {
5092 chan->local_amp_id = chan->move_id; 5092 chan->local_amp_id = chan->move_id;
5093 if (!chan->local_amp_id) 5093 if (chan->local_amp_id == AMP_ID_BREDR)
5094 __release_logical_link(chan); 5094 __release_logical_link(chan);
5095 } else { 5095 } else {
5096 chan->move_id = chan->local_amp_id; 5096 chan->move_id = chan->local_amp_id;
@@ -5130,7 +5130,7 @@ static inline int l2cap_move_channel_confirm_rsp(struct l2cap_conn *conn,
5130 if (chan->move_state == L2CAP_MOVE_WAIT_CONFIRM_RSP) { 5130 if (chan->move_state == L2CAP_MOVE_WAIT_CONFIRM_RSP) {
5131 chan->local_amp_id = chan->move_id; 5131 chan->local_amp_id = chan->move_id;
5132 5132
5133 if (!chan->local_amp_id && chan->hs_hchan) 5133 if (chan->local_amp_id == AMP_ID_BREDR && chan->hs_hchan)
5134 __release_logical_link(chan); 5134 __release_logical_link(chan);
5135 5135
5136 l2cap_move_done(chan); 5136 l2cap_move_done(chan);