Bluetooth: Use hci dev number as AMP controller ID
Previously an offset was added to the hci dev number to generate the
AMP controller ID, because it was possible for the PAL to register
as hci0, and 0 is invalid for an AMP controller ID. Since this commit
462bf76d294a480c775a040476bd7eb81f718ec2 it is not possible for
the PAL to register as hci0, so this offset is no longer necessary.
Change-Id: I4b01ddca5fad3aebeb4c138b5aee8819bb146f3d
Signed-off-by: Peter Krystad <pkrystad@codeaurora.org>
diff --git a/include/net/bluetooth/amp.h b/include/net/bluetooth/amp.h
index 53fea37..0a2849a 100644
--- a/include/net/bluetooth/amp.h
+++ b/include/net/bluetooth/amp.h
@@ -45,9 +45,6 @@
__le16 reason;
} __packed;
-#define HCI_A2MP_ID(id) ((id)+0x10) /* convert HCI dev index to AMP ID */
-#define A2MP_HCI_ID(id) ((id)-0x10) /* convert AMP ID to HCI dev index */
-
struct a2mp_discover_req {
__le16 mtu;
__le16 ext_feat;
diff --git a/net/bluetooth/amp.c b/net/bluetooth/amp.c
index b018a88..4918caa 100644
--- a/net/bluetooth/amp.c
+++ b/net/bluetooth/amp.c
@@ -255,7 +255,7 @@
read_lock(&mgr->ctx_list_lock);
list_for_each_entry(ctx, &mgr->ctx_list, list) {
struct hci_dev *ctx_hdev;
- ctx_hdev = hci_dev_get(A2MP_HCI_ID(ctx->id));
+ ctx_hdev = hci_dev_get(ctx->id);
if ((ctx_hdev == hdev) && (ctx->evt_type & evt_type)) {
switch (evt_type) {
case AMP_HCI_CMD_STATUS:
@@ -356,7 +356,7 @@
if (hdev) {
if ((hdev->amp_type != HCI_BREDR) &&
test_bit(HCI_UP, &hdev->flags)) {
- (cl + num_ctrls)->id = HCI_A2MP_ID(hdev->id);
+ (cl + num_ctrls)->id = hdev->id;
(cl + num_ctrls)->type = hdev->amp_type;
(cl + num_ctrls)->status = hdev->amp_status;
++num_ctrls;
@@ -459,7 +459,7 @@
rsp.status = 1;
BT_DBG("id %d", id);
- hdev = hci_dev_get(A2MP_HCI_ID(id));
+ hdev = hci_dev_get(id);
if (hdev && hdev->amp_type != HCI_BREDR) {
rsp.status = 0;
@@ -510,7 +510,7 @@
int result = -EINVAL;
BT_DBG("lcon %p", lcon);
- hdev = hci_dev_get(A2MP_HCI_ID(id));
+ hdev = hci_dev_get(id);
if (!hdev)
goto ap_finished;
BT_DBG("hdev %p", hdev);
@@ -555,7 +555,7 @@
return -ENOMEM;
ctx->id = req->id;
ctx->d.gaa.req_ident = hdr->ident;
- ctx->hdev = hci_dev_get(A2MP_HCI_ID(ctx->id));
+ ctx->hdev = hci_dev_get(ctx->id);
if (ctx->hdev)
ctx->d.gaa.assoc = kmalloc(ctx->hdev->amp_assoc_size,
GFP_ATOMIC);
@@ -828,7 +828,7 @@
ctx->d.apl.len_so_far = 0;
ctx->d.apl.rem_len = skb->len;
skb_pull(skb, skb->len);
- ctx->hdev = hci_dev_get(A2MP_HCI_ID(ctx->id));
+ ctx->hdev = hci_dev_get(ctx->id);
start_ctx(mgr, ctx);
return 0;
}
@@ -1124,7 +1124,7 @@
if (hdev) {
struct hci_conn *conn;
ctx->hdev = hdev;
- ctx->id = HCI_A2MP_ID(hdev->id);
+ ctx->id = hdev->id;
ctx->d.cpl.remote_id = cl->id;
conn = hci_conn_hash_lookup_ba(hdev,
ACL_LINK,
@@ -1427,7 +1427,7 @@
rsp.status = 0;
BT_DBG("local_id %d remote_id %d",
(int) rsp.local_id, (int) rsp.remote_id);
- hdev = hci_dev_get(A2MP_HCI_ID(rsp.local_id));
+ hdev = hci_dev_get(rsp.local_id);
if (!hdev) {
rsp.status = 1; /* Invalid Controller ID */
goto dpl_finished;
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index 84bb9ef..c986ac4 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -3158,7 +3158,7 @@
struct hci_conn *hcon;
struct hci_chan *chan;
- hdev = hci_dev_get(A2MP_HCI_ID(amp_id));
+ hdev = hci_dev_get(amp_id);
if (!hdev)
return NULL;
@@ -4731,7 +4731,7 @@
struct hci_dev *hdev;
/* Validate AMP controller id */
- hdev = hci_dev_get(A2MP_HCI_ID(req->amp_id));
+ hdev = hci_dev_get(req->amp_id);
if (!hdev || !test_bit(HCI_UP, &hdev->flags)) {
struct l2cap_create_chan_rsp rsp;
@@ -4809,7 +4809,7 @@
if (req->dest_amp_id) {
struct hci_dev *hdev;
- hdev = hci_dev_get(A2MP_HCI_ID(req->dest_amp_id));
+ hdev = hci_dev_get(req->dest_amp_id);
if (!hdev || !test_bit(HCI_UP, &hdev->flags)) {
if (hdev)
hci_dev_put(hdev);