mirror of
https://github.com/torvalds/linux.git
synced 2026-10-10 12:28:02 +02:00
ASoC: codecs: rt5514-spi: Use guard() for mutex locks
Clean up the code using guard() for mutex locks. Merely code refactoring, and no behavior change. Signed-off-by: bui duc phuc <phucduc.bui@gmail.com> Link: https://patch.msgid.link/20260721102600.523199-18-phucduc.bui@gmail.com Signed-off-by: Mark Brown <broonie@kernel.org>
This commit is contained in:
parent
f7a116261d
commit
ed2e18138f
|
|
@ -6,6 +6,7 @@
|
|||
* Author: Oder Chiou <oder_chiou@realtek.com>
|
||||
*/
|
||||
|
||||
#include <linux/cleanup.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/spi/spi.h>
|
||||
|
|
@ -79,17 +80,17 @@ static void rt5514_spi_copy_work(struct work_struct *work)
|
|||
unsigned int cur_wp, remain_data;
|
||||
u8 buf[8];
|
||||
|
||||
mutex_lock(&rt5514_dsp->dma_lock);
|
||||
guard(mutex)(&rt5514_dsp->dma_lock);
|
||||
if (!rt5514_dsp->substream) {
|
||||
dev_err(rt5514_dsp->dev, "No pcm substream\n");
|
||||
goto done;
|
||||
return;
|
||||
}
|
||||
|
||||
runtime = rt5514_dsp->substream->runtime;
|
||||
period_bytes = snd_pcm_lib_period_bytes(rt5514_dsp->substream);
|
||||
if (!period_bytes) {
|
||||
schedule_delayed_work(&rt5514_dsp->copy_work, 5);
|
||||
goto done;
|
||||
return;
|
||||
}
|
||||
|
||||
if (rt5514_dsp->buf_size % period_bytes)
|
||||
|
|
@ -111,7 +112,7 @@ static void rt5514_spi_copy_work(struct work_struct *work)
|
|||
|
||||
if (remain_data < period_bytes) {
|
||||
schedule_delayed_work(&rt5514_dsp->copy_work, 5);
|
||||
goto done;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -146,9 +147,6 @@ static void rt5514_spi_copy_work(struct work_struct *work)
|
|||
snd_pcm_period_elapsed(rt5514_dsp->substream);
|
||||
|
||||
schedule_delayed_work(&rt5514_dsp->copy_work, 5);
|
||||
|
||||
done:
|
||||
mutex_unlock(&rt5514_dsp->dma_lock);
|
||||
}
|
||||
|
||||
static void rt5514_schedule_copy(struct rt5514_dsp *rt5514_dsp)
|
||||
|
|
@ -216,7 +214,7 @@ static int rt5514_spi_hw_params(struct snd_soc_component *component,
|
|||
snd_soc_component_get_drvdata(component);
|
||||
u8 buf[8];
|
||||
|
||||
mutex_lock(&rt5514_dsp->dma_lock);
|
||||
guard(mutex)(&rt5514_dsp->dma_lock);
|
||||
rt5514_dsp->substream = substream;
|
||||
rt5514_dsp->dma_offset = 0;
|
||||
|
||||
|
|
@ -225,8 +223,6 @@ static int rt5514_spi_hw_params(struct snd_soc_component *component,
|
|||
if (buf[0] & RT5514_IRQ_STATUS_BIT)
|
||||
rt5514_schedule_copy(rt5514_dsp);
|
||||
|
||||
mutex_unlock(&rt5514_dsp->dma_lock);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -236,9 +232,8 @@ static int rt5514_spi_hw_free(struct snd_soc_component *component,
|
|||
struct rt5514_dsp *rt5514_dsp =
|
||||
snd_soc_component_get_drvdata(component);
|
||||
|
||||
mutex_lock(&rt5514_dsp->dma_lock);
|
||||
rt5514_dsp->substream = NULL;
|
||||
mutex_unlock(&rt5514_dsp->dma_lock);
|
||||
scoped_guard(mutex, &rt5514_dsp->dma_lock)
|
||||
rt5514_dsp->substream = NULL;
|
||||
|
||||
cancel_delayed_work_sync(&rt5514_dsp->copy_work);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user