[alsa-devel] [PATCH 1/2] ASoC: cs4349: Fix suspend/resume
dev_get_drvdata() will not return the snd_soc_runtime to which this CODEC is attached, so the current code will result in undefined behavior. To fix this just use regmap_update_bits(cs4349->regmap, ...) directly instead of snd_soc_update_bits(rtd->codec, ...).
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- sound/soc/codecs/cs4349.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/cs4349.c b/sound/soc/codecs/cs4349.c index a8df8a74..db18799 100644 --- a/sound/soc/codecs/cs4349.c +++ b/sound/soc/codecs/cs4349.c @@ -328,10 +328,9 @@ static int cs4349_i2c_remove(struct i2c_client *client) static int cs4349_runtime_suspend(struct device *dev) { struct cs4349_private *cs4349 = dev_get_drvdata(dev); - struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); int ret;
- ret = snd_soc_update_bits(rtd->codec, CS4349_MISC, PWR_DWN, 1); + ret = regmap_update_bits(cs4349->regmap, CS4349_MISC, PWR_DWN, 1); if (ret < 0) return ret;
@@ -347,10 +346,9 @@ static int cs4349_runtime_suspend(struct device *dev) static int cs4349_runtime_resume(struct device *dev) { struct cs4349_private *cs4349 = dev_get_drvdata(dev); - struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); int ret;
- ret = snd_soc_update_bits(rtd->codec, CS4349_MISC, PWR_DWN, 0); + ret = regmap_update_bits(cs4349->regmap, CS4349_MISC, PWR_DWN, 0); if (ret < 0) return ret;
rtd->codec does not necessarily point to the CODEC instance for which the callback was called (e.g. for CODEC<->CODEC or multi-CODEC links). Use dai->codec instead.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de --- sound/soc/codecs/cs4349.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sound/soc/codecs/cs4349.c b/sound/soc/codecs/cs4349.c index db18799..5101278 100644 --- a/sound/soc/codecs/cs4349.c +++ b/sound/soc/codecs/cs4349.c @@ -94,8 +94,7 @@ static int cs4349_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_codec *codec = dai->codec; struct cs4349_private *cs4349 = snd_soc_codec_get_drvdata(codec); int mode, fmt, ret;
The patch
ASoC: cs4349: Don't use rtd->codec
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From dedae86d4da6c88ec2105e0bd038acc57c203bca Mon Sep 17 00:00:00 2001
From: Lars-Peter Clausen lars@metafoo.de Date: Sun, 19 Jul 2015 12:15:18 +0200 Subject: [PATCH] ASoC: cs4349: Don't use rtd->codec
rtd->codec does not necessarily point to the CODEC instance for which the callback was called (e.g. for CODEC<->CODEC or multi-CODEC links). Use dai->codec instead.
Signed-off-by: Lars-Peter Clausen lars@metafoo.de Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/codecs/cs4349.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/sound/soc/codecs/cs4349.c b/sound/soc/codecs/cs4349.c index 13ccbf75207e..ab071675357e 100644 --- a/sound/soc/codecs/cs4349.c +++ b/sound/soc/codecs/cs4349.c @@ -94,8 +94,7 @@ static int cs4349_pcm_hw_params(struct snd_pcm_substream *substream, struct snd_pcm_hw_params *params, struct snd_soc_dai *dai) { - struct snd_soc_pcm_runtime *rtd = substream->private_data; - struct snd_soc_codec *codec = rtd->codec; + struct snd_soc_codec *codec = dai->codec; struct cs4349_private *cs4349 = snd_soc_codec_get_drvdata(codec); int mode, fmt, ret;
The patch
ASoC: cs4349: Fix suspend/resume
has been applied to the asoc tree at
git://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks, Mark
From cb2510dac7e1c5ac77652bb31e8c39ce2eef8bbe Mon Sep 17 00:00:00 2001
From: Lars-Peter Clausen lars@metafoo.de Date: Sun, 19 Jul 2015 12:15:17 +0200 Subject: [PATCH] ASoC: cs4349: Fix suspend/resume
dev_get_drvdata() will not return the snd_soc_runtime to which this CODEC is attached, so the current code will result in undefined behavior. To fix this just use regmap_update_bits(cs4349->regmap, ...) directly instead of snd_soc_update_bits(rtd->codec, ...).
Signed-off-by: Lars-Peter Clausen lars@metafoo.de Signed-off-by: Mark Brown broonie@kernel.org --- sound/soc/codecs/cs4349.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/sound/soc/codecs/cs4349.c b/sound/soc/codecs/cs4349.c index f4fccc621ceb..13ccbf75207e 100644 --- a/sound/soc/codecs/cs4349.c +++ b/sound/soc/codecs/cs4349.c @@ -328,10 +328,9 @@ static int cs4349_i2c_remove(struct i2c_client *client) static int cs4349_runtime_suspend(struct device *dev) { struct cs4349_private *cs4349 = dev_get_drvdata(dev); - struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); int ret;
- ret = snd_soc_update_bits(rtd->codec, CS4349_MISC, PWR_DWN, 1); + ret = regmap_update_bits(cs4349->regmap, CS4349_MISC, PWR_DWN, 1); if (ret < 0) return ret;
@@ -347,10 +346,9 @@ static int cs4349_runtime_suspend(struct device *dev) static int cs4349_runtime_resume(struct device *dev) { struct cs4349_private *cs4349 = dev_get_drvdata(dev); - struct snd_soc_pcm_runtime *rtd = dev_get_drvdata(dev); int ret;
- ret = snd_soc_update_bits(rtd->codec, CS4349_MISC, PWR_DWN, 0); + ret = regmap_update_bits(cs4349->regmap, CS4349_MISC, PWR_DWN, 0); if (ret < 0) return ret;
On Sun, 19 Jul 2015, Lars-Peter Clausen wrote:
dev_get_drvdata() will not return the snd_soc_runtime to which this CODEC is attached, so the current code will result in undefined behavior. To fix this just use regmap_update_bits(cs4349->regmap, ...) directly instead of snd_soc_update_bits(rtd->codec, ...).
Signed-off-by: Lars-Peter Clausen lars@metafoo.de
sound/soc/codecs/cs4349.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
For both patches Thank you! Acked-by: Tim Howe tim.howe@cirrus.com
participants (3)
-
Lars-Peter Clausen
-
Mark Brown
-
Tim Howe