Re: [PATCH v3 2/5] ASoC: Intel: avs: Use guard() for locking
From: Cezary Rojewski
Date: Tue Jun 23 2026 - 15:47:16 EST
On 6/23/2026 12:57 PM, phucduc.bui@xxxxxxxxx wrote:
From: bui duc phuc <phucduc.bui@xxxxxxxxx>
Clean up the code using guard() for spin & mutex locks.
Merely code refactoring, and no behavior change.
Apart from one point below, looks good overall. What bothers me is lack of includes - all these files are missing linux/cleanup.h header despite clearly using its members.
sound/soc/intel/avs/apl.c | 7 ++-----
sound/soc/intel/avs/control.c | 7 ++-----
sound/soc/intel/avs/core.c | 3 +--
sound/soc/intel/avs/debug.h | 9 ++------
sound/soc/intel/avs/ipc.c | 10 +++------
sound/soc/intel/avs/path.c | 29 +++++++-------------------
sound/soc/intel/avs/utils.c | 39 ++++++++++++-----------------------
7 files changed, 31 insertions(+), 73 deletions(-)
...
int avs_module_id_alloc(struct avs_dev *adev, u16 module_id)
{
int ret, idx, max_id;
- mutex_lock(&adev->modres_mutex);
+ guard(mutex)(&adev->modres_mutex);
idx = avs_module_id_entry_index(adev, module_id);
if (idx == -ENOENT) {
dev_err(adev->dev, "invalid module id: %d", module_id);
- ret = -EINVAL;
- goto exit;
+ return -EINVAL;
}
max_id = adev->mods_info->entries[idx].instance_max_count - 1;
ret = ida_alloc_max(adev->mod_idas[idx], max_id, GFP_KERNEL);
-exit:
- mutex_unlock(&adev->modres_mutex);
+
Drop 'ret' entirely and just 'return ida_alloc_max()'.
return ret;
}