Skip to content

Commit

Permalink
ASoC: rt711_*: add snd_soc_component remove callback
Browse files Browse the repository at this point in the history
We do some IO operations in the snd_soc_component_set_jack callback
function and snd_soc_component_set_jack() will be called when soc
component is removed. However, we should not access SoundWire registers
when the bus is suspended.
So set regcache_cache_only(regmap, true) to avoid accessing in the
soc component removal process.

Signed-off-by: Bard Liao <[email protected]>
  • Loading branch information
bardliao authored and kv2019i committed Dec 18, 2020
1 parent 03b55f5 commit 2742943
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
9 changes: 9 additions & 0 deletions sound/soc/codecs/rt711-sdca.c
Original file line number Diff line number Diff line change
Expand Up @@ -1109,6 +1109,14 @@ static int rt711_sdca_probe(struct snd_soc_component *component)
return 0;
}

void rt711_sdca_remove(struct snd_soc_component *component)
{
struct rt711_sdca_priv *rt711 = snd_soc_component_get_drvdata(component);

regcache_cache_only(rt711->regmap, true);
regcache_cache_only(rt711->mbq_regmap, true);
}

static const struct snd_soc_component_driver soc_sdca_dev_rt711 = {
.probe = rt711_sdca_probe,
.controls = rt711_sdca_snd_controls,
Expand All @@ -1118,6 +1126,7 @@ static const struct snd_soc_component_driver soc_sdca_dev_rt711 = {
.dapm_routes = rt711_sdca_audio_map,
.num_dapm_routes = ARRAY_SIZE(rt711_sdca_audio_map),
.set_jack = rt711_sdca_set_jack_detect,
.remove = rt711_sdca_remove,
};

static int rt711_sdca_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream,
Expand Down
8 changes: 8 additions & 0 deletions sound/soc/codecs/rt711.c
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,13 @@ static int rt711_probe(struct snd_soc_component *component)
return 0;
}

void rt711_remove(struct snd_soc_component *component)
{
struct rt711_priv *rt711 = snd_soc_component_get_drvdata(component);

regcache_cache_only(rt711->regmap, true);
}

static const struct snd_soc_component_driver soc_codec_dev_rt711 = {
.probe = rt711_probe,
.set_bias_level = rt711_set_bias_level,
Expand All @@ -905,6 +912,7 @@ static const struct snd_soc_component_driver soc_codec_dev_rt711 = {
.dapm_routes = rt711_audio_map,
.num_dapm_routes = ARRAY_SIZE(rt711_audio_map),
.set_jack = rt711_set_jack_detect,
.remove = rt711_remove,
};

static int rt711_set_sdw_stream(struct snd_soc_dai *dai, void *sdw_stream,
Expand Down

0 comments on commit 2742943

Please sign in to comment.