mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2025-01-10 07:00:48 +00:00
Bluetooth: AMP: Factor out amp_ctrl_add
Add ctrl_id parameter to amp_ctrl_add since we always set it after function ctrl is created. Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com> Signed-off-by: Gustavo Padovan <gustavo.padovan@collabora.co.uk>
This commit is contained in:
parent
85e34368de
commit
fa4ebc66c4
@ -26,7 +26,7 @@ struct amp_ctrl {
|
|||||||
|
|
||||||
int amp_ctrl_put(struct amp_ctrl *ctrl);
|
int amp_ctrl_put(struct amp_ctrl *ctrl);
|
||||||
void amp_ctrl_get(struct amp_ctrl *ctrl);
|
void amp_ctrl_get(struct amp_ctrl *ctrl);
|
||||||
struct amp_ctrl *amp_ctrl_add(struct amp_mgr *mgr);
|
struct amp_ctrl *amp_ctrl_add(struct amp_mgr *mgr, u8 id);
|
||||||
struct amp_ctrl *amp_ctrl_lookup(struct amp_mgr *mgr, u8 id);
|
struct amp_ctrl *amp_ctrl_lookup(struct amp_mgr *mgr, u8 id);
|
||||||
void amp_ctrl_list_flush(struct amp_mgr *mgr);
|
void amp_ctrl_list_flush(struct amp_mgr *mgr);
|
||||||
|
|
||||||
|
@ -316,12 +316,10 @@ static int a2mp_getinfo_rsp(struct amp_mgr *mgr, struct sk_buff *skb,
|
|||||||
if (rsp->status)
|
if (rsp->status)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
ctrl = amp_ctrl_add(mgr);
|
ctrl = amp_ctrl_add(mgr, rsp->id);
|
||||||
if (!ctrl)
|
if (!ctrl)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
ctrl->id = rsp->id;
|
|
||||||
|
|
||||||
req.id = rsp->id;
|
req.id = rsp->id;
|
||||||
a2mp_send(mgr, A2MP_GETAMPASSOC_REQ, __next_ident(mgr), sizeof(req),
|
a2mp_send(mgr, A2MP_GETAMPASSOC_REQ, __next_ident(mgr), sizeof(req),
|
||||||
&req);
|
&req);
|
||||||
@ -461,7 +459,7 @@ static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb,
|
|||||||
|
|
||||||
ctrl = amp_ctrl_lookup(mgr, rsp.remote_id);
|
ctrl = amp_ctrl_lookup(mgr, rsp.remote_id);
|
||||||
if (!ctrl) {
|
if (!ctrl) {
|
||||||
ctrl = amp_ctrl_add(mgr);
|
ctrl = amp_ctrl_add(mgr, rsp.remote_id);
|
||||||
if (ctrl) {
|
if (ctrl) {
|
||||||
amp_ctrl_get(ctrl);
|
amp_ctrl_get(ctrl);
|
||||||
} else {
|
} else {
|
||||||
@ -474,8 +472,6 @@ static int a2mp_createphyslink_req(struct amp_mgr *mgr, struct sk_buff *skb,
|
|||||||
size_t assoc_len = le16_to_cpu(hdr->len) - sizeof(*req);
|
size_t assoc_len = le16_to_cpu(hdr->len) - sizeof(*req);
|
||||||
u8 *assoc;
|
u8 *assoc;
|
||||||
|
|
||||||
ctrl->id = rsp.remote_id;
|
|
||||||
|
|
||||||
assoc = kzalloc(assoc_len, GFP_KERNEL);
|
assoc = kzalloc(assoc_len, GFP_KERNEL);
|
||||||
if (!assoc) {
|
if (!assoc) {
|
||||||
amp_ctrl_put(ctrl);
|
amp_ctrl_put(ctrl);
|
||||||
|
@ -45,7 +45,7 @@ int amp_ctrl_put(struct amp_ctrl *ctrl)
|
|||||||
return kref_put(&ctrl->kref, &_ctrl_destroy);
|
return kref_put(&ctrl->kref, &_ctrl_destroy);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct amp_ctrl *amp_ctrl_add(struct amp_mgr *mgr)
|
struct amp_ctrl *amp_ctrl_add(struct amp_mgr *mgr, u8 id)
|
||||||
{
|
{
|
||||||
struct amp_ctrl *ctrl;
|
struct amp_ctrl *ctrl;
|
||||||
|
|
||||||
@ -53,12 +53,13 @@ struct amp_ctrl *amp_ctrl_add(struct amp_mgr *mgr)
|
|||||||
if (!ctrl)
|
if (!ctrl)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
kref_init(&ctrl->kref);
|
||||||
|
ctrl->id = id;
|
||||||
|
|
||||||
mutex_lock(&mgr->amp_ctrls_lock);
|
mutex_lock(&mgr->amp_ctrls_lock);
|
||||||
list_add(&ctrl->list, &mgr->amp_ctrls);
|
list_add(&ctrl->list, &mgr->amp_ctrls);
|
||||||
mutex_unlock(&mgr->amp_ctrls_lock);
|
mutex_unlock(&mgr->amp_ctrls_lock);
|
||||||
|
|
||||||
kref_init(&ctrl->kref);
|
|
||||||
|
|
||||||
BT_DBG("mgr %p ctrl %p", mgr, ctrl);
|
BT_DBG("mgr %p ctrl %p", mgr, ctrl);
|
||||||
|
|
||||||
return ctrl;
|
return ctrl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user