mirror of
https://github.com/torvalds/linux.git
synced 2026-09-24 06:24:02 +02:00
ASoC: Intel: atom: Use scoped_guard() for scoped locking
Clean up the code using scoped_guard() for mutex locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> Reviewed-by: Cezary Rojewski <cezary.rojewski@intel.com> Link: https://patch.msgid.link/20260626082904.32344-6-phucduc.bui@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
71c0f725d3
commit
08d2d5e683
|
|
@ -750,27 +750,29 @@ int sst_handle_vb_timer(struct snd_soc_dai *dai, bool enable)
|
|||
return ret;
|
||||
}
|
||||
|
||||
mutex_lock(&drv->lock);
|
||||
if (enable)
|
||||
timer_usage++;
|
||||
else
|
||||
timer_usage--;
|
||||
|
||||
/*
|
||||
* Send the command only if this call is the first enable or last
|
||||
* disable
|
||||
*/
|
||||
if ((enable && (timer_usage == 1)) ||
|
||||
(!enable && (timer_usage == 0))) {
|
||||
ret = sst_fill_and_send_cmd_unlocked(drv, SST_IPC_IA_CMD,
|
||||
SST_FLAG_BLOCKED, SST_TASK_SBA, 0, &cmd,
|
||||
sizeof(cmd.header) + cmd.header.length);
|
||||
if (ret && enable) {
|
||||
scoped_guard(mutex, &drv->lock) {
|
||||
if (enable)
|
||||
timer_usage++;
|
||||
else
|
||||
timer_usage--;
|
||||
enable = false;
|
||||
|
||||
/*
|
||||
* Send the command only if this call is the first enable or last
|
||||
* disable
|
||||
*/
|
||||
if ((enable && timer_usage == 1) ||
|
||||
(!enable && timer_usage == 0)) {
|
||||
ret = sst_fill_and_send_cmd_unlocked(drv, SST_IPC_IA_CMD,
|
||||
SST_FLAG_BLOCKED,
|
||||
SST_TASK_SBA, 0, &cmd,
|
||||
sizeof(cmd.header) +
|
||||
cmd.header.length);
|
||||
if (ret && enable) {
|
||||
timer_usage--;
|
||||
enable = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
mutex_unlock(&drv->lock);
|
||||
|
||||
if (!enable)
|
||||
sst->ops->power(sst->dev, false);
|
||||
|
|
|
|||
|
|
@ -304,15 +304,14 @@ static int sst_media_open(struct snd_pcm_substream *substream,
|
|||
spin_lock_init(&stream->status_lock);
|
||||
|
||||
/* get the sst ops */
|
||||
mutex_lock(&sst_lock);
|
||||
if (!sst ||
|
||||
!try_module_get(sst->dev->driver->owner)) {
|
||||
dev_err(dai->dev, "no device available to run\n");
|
||||
ret_val = -ENODEV;
|
||||
goto out_ops;
|
||||
scoped_guard(mutex, &sst_lock) {
|
||||
if (!sst ||
|
||||
!try_module_get(sst->dev->driver->owner)) {
|
||||
dev_err(dai->dev, "no device available to run\n");
|
||||
return -ENODEV;
|
||||
}
|
||||
stream->ops = sst->ops;
|
||||
}
|
||||
stream->ops = sst->ops;
|
||||
mutex_unlock(&sst_lock);
|
||||
|
||||
stream->stream_info.str_id = 0;
|
||||
|
||||
|
|
@ -347,11 +346,6 @@ static int sst_media_open(struct snd_pcm_substream *substream,
|
|||
|
||||
stream = NULL;
|
||||
|
||||
return ret_val;
|
||||
|
||||
out_ops:
|
||||
mutex_unlock(&sst_lock);
|
||||
|
||||
return ret_val;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user