int amp_ctrl_put(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);
void amp_ctrl_list_flush(struct amp_mgr *mgr);
if (rsp->status)
return -EINVAL;
- ctrl = amp_ctrl_add(mgr);
+ ctrl = amp_ctrl_add(mgr, rsp->id);
if (!ctrl)
return -ENOMEM;
- ctrl->id = rsp->id;
-
req.id = rsp->id;
a2mp_send(mgr, A2MP_GETAMPASSOC_REQ, __next_ident(mgr), sizeof(req),
&req);
ctrl = amp_ctrl_lookup(mgr, rsp.remote_id);
if (!ctrl) {
- ctrl = amp_ctrl_add(mgr);
+ ctrl = amp_ctrl_add(mgr, rsp.remote_id);
if (ctrl) {
amp_ctrl_get(ctrl);
} else {
size_t assoc_len = le16_to_cpu(hdr->len) - sizeof(*req);
u8 *assoc;
- ctrl->id = rsp.remote_id;
-
assoc = kzalloc(assoc_len, GFP_KERNEL);
if (!assoc) {
amp_ctrl_put(ctrl);
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;
if (!ctrl)
return NULL;
+ kref_init(&ctrl->kref);
+ ctrl->id = id;
+
mutex_lock(&mgr->amp_ctrls_lock);
list_add(&ctrl->list, &mgr->amp_ctrls);
mutex_unlock(&mgr->amp_ctrls_lock);
- kref_init(&ctrl->kref);
-
BT_DBG("mgr %p ctrl %p", mgr, ctrl);
return ctrl;