OSDN Git Service

ASoC: soc-component: use io_mutex correctly
authorKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Tue, 16 Jun 2020 05:19:52 +0000 (14:19 +0900)
committerMark Brown <broonie@kernel.org>
Mon, 22 Jun 2020 14:13:37 +0000 (15:13 +0100)
commite8712315c44d2e7dfc4d29254941831ed2ddcaef
tree40adc1d0d26e8286b7ff3ad8c40d4c532fc47ea3
parentcf6e26c71bfdff823fd40945b07666d75f1e1412
ASoC: soc-component: use io_mutex correctly

component has io_mutex, but it had been used at
snd_soc_component_update_bits_legacy() only which does read and write.

static int snd_soc_component_update_bits_legacy(...)
{
...
=> mutex_lock(&component->io_mutex);
...
old = snd_soc_component_read(...);
...
ret = snd_soc_component_write(...);
...
=> mutex_unlock(&component->io_mutex);
...
}

It is pointless if it is not used with both read and write functions.
This patch uses io_mutex correctly with read/write.
Here, xxx_no_lock() is local functions.

static int snd_soc_component_read(...)
{
...
=> mutex_lock(&component->io_mutex);
val = soc_component_read_no_lock(...);
=> mutex_unlock(&component->io_mutex);
...
}

static int snd_soc_component_write(...)
{
...
=> mutex_lock(&component->io_mutex);
ret = soc_component_write_no_lock(...);
=> mutex_unlock(&component->io_mutex);
...
}

static int snd_soc_component_update_bits_legacy(...)
{
...
=> mutex_lock(&component->io_mutex);
...
old = soc_component_read_no_lock(...);
...
ret = soc_component_write_no_lock(...);
...
=> mutex_unlock(&component->io_mutex);
...
}

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
Link: https://lore.kernel.org/r/87r1uf4mfa.wl-kuninori.morimoto.gx@renesas.com
Signed-off-by: Mark Brown <broonie@kernel.org>
sound/soc/soc-component.c