mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-18 17:01:35 -04:00
ASoc: qcom: q6adm: Use automatic cleanup of kfree()
Its common pattern in q6dsp code to allocate temporary buffer to send gpr/apr packets and free at the function exit. Now this can be simplified via __free(kfree) mechanism. No functional changes. Signed-off-by: Srinivas Kandagatla <srinivas.kandagatla@oss.qualcomm.com> Link: https://patch.msgid.link/20251023102444.88158-13-srinivas.kandagatla@oss.qualcomm.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
committed by
Mark Brown
parent
88a5f8e628
commit
896f1e4e10
@@ -330,11 +330,8 @@ static int q6adm_device_open(struct q6adm *adm, struct q6copp *copp,
|
||||
struct q6adm_cmd_device_open_v5 *open;
|
||||
int afe_port = q6afe_get_port_id(port_id);
|
||||
struct apr_pkt *pkt;
|
||||
void *p;
|
||||
int ret, pkt_size;
|
||||
|
||||
pkt_size = APR_HDR_SIZE + sizeof(*open);
|
||||
p = kzalloc(pkt_size, GFP_KERNEL);
|
||||
int ret, pkt_size = APR_HDR_SIZE + sizeof(*open);
|
||||
void *p __free(kfree) = kzalloc(pkt_size, GFP_KERNEL);
|
||||
if (!p)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -359,14 +356,9 @@ static int q6adm_device_open(struct q6adm *adm, struct q6copp *copp,
|
||||
ret = q6dsp_map_channels(&open->dev_channel_mapping[0],
|
||||
channel_mode);
|
||||
if (ret)
|
||||
goto err;
|
||||
return ret;
|
||||
|
||||
ret = q6adm_apr_send_copp_pkt(adm, copp, pkt,
|
||||
ADM_CMDRSP_DEVICE_OPEN_V5);
|
||||
|
||||
err:
|
||||
kfree(pkt);
|
||||
return ret;
|
||||
return q6adm_apr_send_copp_pkt(adm, copp, pkt, ADM_CMDRSP_DEVICE_OPEN_V5);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -469,15 +461,12 @@ int q6adm_matrix_map(struct device *dev, int path,
|
||||
struct q6adm_session_map_node_v5 *node;
|
||||
struct apr_pkt *pkt;
|
||||
uint16_t *copps_list;
|
||||
int pkt_size, ret, i, copp_idx;
|
||||
void *matrix_map;
|
||||
struct q6copp *copp;
|
||||
|
||||
int ret, i, copp_idx;
|
||||
/* Assumes port_ids have already been validated during adm_open */
|
||||
pkt_size = (APR_HDR_SIZE + sizeof(*route) + sizeof(*node) +
|
||||
struct q6copp *copp;
|
||||
int pkt_size = (APR_HDR_SIZE + sizeof(*route) + sizeof(*node) +
|
||||
(sizeof(uint32_t) * payload_map.num_copps));
|
||||
|
||||
matrix_map = kzalloc(pkt_size, GFP_KERNEL);
|
||||
void *matrix_map __free(kfree) = kzalloc(pkt_size, GFP_KERNEL);
|
||||
if (!matrix_map)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -515,16 +504,13 @@ int q6adm_matrix_map(struct device *dev, int path,
|
||||
if (port_idx < 0) {
|
||||
dev_err(dev, "Invalid port_id %d\n",
|
||||
payload_map.port_id[i]);
|
||||
kfree(pkt);
|
||||
return -EINVAL;
|
||||
}
|
||||
copp_idx = payload_map.copp_idx[i];
|
||||
|
||||
copp = q6adm_find_copp(adm, port_idx, copp_idx);
|
||||
if (!copp) {
|
||||
kfree(pkt);
|
||||
if (!copp)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
copps_list[i] = copp->id;
|
||||
kref_put(&copp->refcount, q6adm_free_copp);
|
||||
@@ -557,7 +543,6 @@ int q6adm_matrix_map(struct device *dev, int path,
|
||||
|
||||
fail_cmd:
|
||||
mutex_unlock(&adm->lock);
|
||||
kfree(pkt);
|
||||
return ret;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(q6adm_matrix_map);
|
||||
|
||||
Reference in New Issue
Block a user