Merge changes I4b01ddca,I15b9ab7d into msm-3.0
* changes: Bluetooth: Use hci dev number as AMP controller ID Bluetooth: Release module reference counts
This commit is contained in:
committed by
QuIC Gerrit Code Review
commit
e7f5fcd146
@@ -45,9 +45,6 @@ struct a2mp_cmd_rej {
|
|||||||
__le16 reason;
|
__le16 reason;
|
||||||
} __packed;
|
} __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 {
|
struct a2mp_discover_req {
|
||||||
__le16 mtu;
|
__le16 mtu;
|
||||||
__le16 ext_feat;
|
__le16 ext_feat;
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ static struct amp_ctx *get_ctx_hdev(struct hci_dev *hdev, u8 evt_type,
|
|||||||
read_lock(&mgr->ctx_list_lock);
|
read_lock(&mgr->ctx_list_lock);
|
||||||
list_for_each_entry(ctx, &mgr->ctx_list, list) {
|
list_for_each_entry(ctx, &mgr->ctx_list, list) {
|
||||||
struct hci_dev *ctx_hdev;
|
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)) {
|
if ((ctx_hdev == hdev) && (ctx->evt_type & evt_type)) {
|
||||||
switch (evt_type) {
|
switch (evt_type) {
|
||||||
case AMP_HCI_CMD_STATUS:
|
case AMP_HCI_CMD_STATUS:
|
||||||
@@ -356,7 +356,7 @@ static int send_a2mp_cl(struct amp_mgr *mgr, u8 ident, u8 code, u16 len,
|
|||||||
if (hdev) {
|
if (hdev) {
|
||||||
if ((hdev->amp_type != HCI_BREDR) &&
|
if ((hdev->amp_type != HCI_BREDR) &&
|
||||||
test_bit(HCI_UP, &hdev->flags)) {
|
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)->type = hdev->amp_type;
|
||||||
(cl + num_ctrls)->status = hdev->amp_status;
|
(cl + num_ctrls)->status = hdev->amp_status;
|
||||||
++num_ctrls;
|
++num_ctrls;
|
||||||
@@ -459,7 +459,7 @@ static inline int getinfo_req(struct amp_mgr *mgr, struct sk_buff *skb)
|
|||||||
rsp.status = 1;
|
rsp.status = 1;
|
||||||
|
|
||||||
BT_DBG("id %d", id);
|
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) {
|
if (hdev && hdev->amp_type != HCI_BREDR) {
|
||||||
rsp.status = 0;
|
rsp.status = 0;
|
||||||
@@ -510,14 +510,14 @@ static void accept_physical(struct l2cap_conn *lcon, u8 id, struct sock *sk)
|
|||||||
int result = -EINVAL;
|
int result = -EINVAL;
|
||||||
|
|
||||||
BT_DBG("lcon %p", lcon);
|
BT_DBG("lcon %p", lcon);
|
||||||
|
hdev = hci_dev_get(id);
|
||||||
|
if (!hdev)
|
||||||
|
goto ap_finished;
|
||||||
|
BT_DBG("hdev %p", hdev);
|
||||||
mgr = get_create_amp_mgr(lcon, NULL);
|
mgr = get_create_amp_mgr(lcon, NULL);
|
||||||
if (!mgr)
|
if (!mgr)
|
||||||
goto ap_finished;
|
goto ap_finished;
|
||||||
BT_DBG("mgr %p", mgr);
|
BT_DBG("mgr %p", mgr);
|
||||||
hdev = hci_dev_get(A2MP_HCI_ID(id));
|
|
||||||
if (!hdev)
|
|
||||||
goto ap_finished;
|
|
||||||
BT_DBG("hdev %p", hdev);
|
|
||||||
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK,
|
conn = hci_conn_hash_lookup_ba(hdev, ACL_LINK,
|
||||||
&mgr->l2cap_conn->hcon->dst);
|
&mgr->l2cap_conn->hcon->dst);
|
||||||
if (conn) {
|
if (conn) {
|
||||||
@@ -534,6 +534,8 @@ static void accept_physical(struct l2cap_conn *lcon, u8 id, struct sock *sk)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
ap_finished:
|
ap_finished:
|
||||||
|
if (hdev)
|
||||||
|
hci_dev_put(hdev);
|
||||||
l2cap_amp_physical_complete(result, id, remote_id, sk);
|
l2cap_amp_physical_complete(result, id, remote_id, sk);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -553,7 +555,7 @@ static int getampassoc_req(struct amp_mgr *mgr, struct sk_buff *skb)
|
|||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
ctx->id = req->id;
|
ctx->id = req->id;
|
||||||
ctx->d.gaa.req_ident = hdr->ident;
|
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)
|
if (ctx->hdev)
|
||||||
ctx->d.gaa.assoc = kmalloc(ctx->hdev->amp_assoc_size,
|
ctx->d.gaa.assoc = kmalloc(ctx->hdev->amp_assoc_size,
|
||||||
GFP_ATOMIC);
|
GFP_ATOMIC);
|
||||||
@@ -826,7 +828,7 @@ static int createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb)
|
|||||||
ctx->d.apl.len_so_far = 0;
|
ctx->d.apl.len_so_far = 0;
|
||||||
ctx->d.apl.rem_len = skb->len;
|
ctx->d.apl.rem_len = skb->len;
|
||||||
skb_pull(skb, 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);
|
start_ctx(mgr, ctx);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -1122,7 +1124,7 @@ static u8 createphyslink_handler(struct amp_ctx *ctx, u8 evt_type, void *data)
|
|||||||
if (hdev) {
|
if (hdev) {
|
||||||
struct hci_conn *conn;
|
struct hci_conn *conn;
|
||||||
ctx->hdev = hdev;
|
ctx->hdev = hdev;
|
||||||
ctx->id = HCI_A2MP_ID(hdev->id);
|
ctx->id = hdev->id;
|
||||||
ctx->d.cpl.remote_id = cl->id;
|
ctx->d.cpl.remote_id = cl->id;
|
||||||
conn = hci_conn_hash_lookup_ba(hdev,
|
conn = hci_conn_hash_lookup_ba(hdev,
|
||||||
ACL_LINK,
|
ACL_LINK,
|
||||||
@@ -1425,7 +1427,7 @@ static int disconnphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb)
|
|||||||
rsp.status = 0;
|
rsp.status = 0;
|
||||||
BT_DBG("local_id %d remote_id %d",
|
BT_DBG("local_id %d remote_id %d",
|
||||||
(int) rsp.local_id, (int) rsp.remote_id);
|
(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) {
|
if (!hdev) {
|
||||||
rsp.status = 1; /* Invalid Controller ID */
|
rsp.status = 1; /* Invalid Controller ID */
|
||||||
goto dpl_finished;
|
goto dpl_finished;
|
||||||
|
|||||||
@@ -3158,21 +3158,23 @@ static struct hci_chan *l2cap_chan_admit(u8 amp_id, struct l2cap_pinfo *pi)
|
|||||||
struct hci_conn *hcon;
|
struct hci_conn *hcon;
|
||||||
struct hci_chan *chan;
|
struct hci_chan *chan;
|
||||||
|
|
||||||
hdev = hci_dev_get(A2MP_HCI_ID(amp_id));
|
hdev = hci_dev_get(amp_id);
|
||||||
if (!hdev)
|
if (!hdev)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
BT_DBG("hdev %s", hdev->name);
|
BT_DBG("hdev %s", hdev->name);
|
||||||
|
|
||||||
hcon = hci_conn_hash_lookup_ba(hdev, ACL_LINK, pi->conn->dst);
|
hcon = hci_conn_hash_lookup_ba(hdev, ACL_LINK, pi->conn->dst);
|
||||||
if (!hcon)
|
if (!hcon) {
|
||||||
return NULL;
|
chan = NULL;
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
|
|
||||||
chan = hci_chan_list_lookup_id(hdev, hcon->handle);
|
chan = hci_chan_list_lookup_id(hdev, hcon->handle);
|
||||||
if (chan) {
|
if (chan) {
|
||||||
l2cap_aggregate(chan, pi);
|
l2cap_aggregate(chan, pi);
|
||||||
hci_chan_hold(chan);
|
hci_chan_hold(chan);
|
||||||
return chan;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bt_sk(pi)->parent) {
|
if (bt_sk(pi)->parent) {
|
||||||
@@ -3186,6 +3188,8 @@ static struct hci_chan *l2cap_chan_admit(u8 amp_id, struct l2cap_pinfo *pi)
|
|||||||
(struct hci_ext_fs *) &pi->local_fs,
|
(struct hci_ext_fs *) &pi->local_fs,
|
||||||
(struct hci_ext_fs *) &pi->remote_fs);
|
(struct hci_ext_fs *) &pi->remote_fs);
|
||||||
}
|
}
|
||||||
|
done:
|
||||||
|
hci_dev_put(hdev);
|
||||||
return chan;
|
return chan;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4727,7 +4731,7 @@ static inline int l2cap_create_channel_req(struct l2cap_conn *conn,
|
|||||||
struct hci_dev *hdev;
|
struct hci_dev *hdev;
|
||||||
|
|
||||||
/* Validate AMP controller id */
|
/* 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)) {
|
if (!hdev || !test_bit(HCI_UP, &hdev->flags)) {
|
||||||
struct l2cap_create_chan_rsp rsp;
|
struct l2cap_create_chan_rsp rsp;
|
||||||
|
|
||||||
@@ -4805,7 +4809,7 @@ static inline int l2cap_move_channel_req(struct l2cap_conn *conn,
|
|||||||
|
|
||||||
if (req->dest_amp_id) {
|
if (req->dest_amp_id) {
|
||||||
struct hci_dev *hdev;
|
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 || !test_bit(HCI_UP, &hdev->flags)) {
|
||||||
if (hdev)
|
if (hdev)
|
||||||
hci_dev_put(hdev);
|
hci_dev_put(hdev);
|
||||||
@@ -4813,6 +4817,7 @@ static inline int l2cap_move_channel_req(struct l2cap_conn *conn,
|
|||||||
result = L2CAP_MOVE_CHAN_REFUSED_CONTROLLER;
|
result = L2CAP_MOVE_CHAN_REFUSED_CONTROLLER;
|
||||||
goto send_move_response;
|
goto send_move_response;
|
||||||
}
|
}
|
||||||
|
hci_dev_put(hdev);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (((pi->amp_move_state != L2CAP_AMP_STATE_STABLE &&
|
if (((pi->amp_move_state != L2CAP_AMP_STATE_STABLE &&
|
||||||
|
|||||||
Reference in New Issue
Block a user