linux-sound.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] ASoC: cs42l43: Add clear of stashed pointer on component remove
@ 2024-02-02 14:06 Charles Keepax
  2024-02-02 14:06 ` [PATCH 2/3] ASoC: cs42l43: Sync the hp ilimit works when removing the component Charles Keepax
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Charles Keepax @ 2024-02-02 14:06 UTC (permalink / raw
  To: broonie; +Cc: lgirdwood, alsa-devel, patches, linux-sound

If the component is removed the stashed component pointer in the
CODECs private struct should also be cleared to prevent use of a stale
pointer.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/cs42l43.c | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c
index 2c402086924d..9e1deb3242cb 100644
--- a/sound/soc/codecs/cs42l43.c
+++ b/sound/soc/codecs/cs42l43.c
@@ -2111,10 +2111,18 @@ static int cs42l43_component_probe(struct snd_soc_component *component)
 	return 0;
 }
 
+static void cs42l43_component_remove(struct snd_soc_component *component)
+{
+	struct cs42l43_codec *priv = snd_soc_component_get_drvdata(component);
+
+	priv->component = NULL;
+}
+
 static const struct snd_soc_component_driver cs42l43_component_drv = {
 	.name			= "cs42l43-codec",
 
 	.probe			= cs42l43_component_probe,
+	.remove			= cs42l43_component_remove,
 	.set_sysclk		= cs42l43_set_sysclk,
 	.set_jack		= cs42l43_set_jack,
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/3] ASoC: cs42l43: Sync the hp ilimit works when removing the component
  2024-02-02 14:06 [PATCH 1/3] ASoC: cs42l43: Add clear of stashed pointer on component remove Charles Keepax
@ 2024-02-02 14:06 ` Charles Keepax
  2024-02-02 14:06 ` [PATCH 3/3] ASoC: cs42l43: Shut down jack detection on component remove Charles Keepax
  2024-02-06  9:37 ` [PATCH 1/3] ASoC: cs42l43: Add clear of stashed pointer " Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Charles Keepax @ 2024-02-02 14:06 UTC (permalink / raw
  To: broonie; +Cc: lgirdwood, alsa-devel, patches, linux-sound

Synchronise the headphone ilimit work functions when removing the
component. These can only trigger whilst the headphone is enabled which
shouldn't be possible once the component is removed but the works rely
on the stashed component pointer so they should be shut down before the
code moves on from component remove.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/cs42l43.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c
index 9e1deb3242cb..c84d5952cdb5 100644
--- a/sound/soc/codecs/cs42l43.c
+++ b/sound/soc/codecs/cs42l43.c
@@ -2115,6 +2115,9 @@ static void cs42l43_component_remove(struct snd_soc_component *component)
 {
 	struct cs42l43_codec *priv = snd_soc_component_get_drvdata(component);
 
+	cancel_work_sync(&priv->hp_ilimit_work);
+	cancel_delayed_work_sync(&priv->hp_ilimit_clear_work);
+
 	priv->component = NULL;
 }
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 3/3] ASoC: cs42l43: Shut down jack detection on component remove
  2024-02-02 14:06 [PATCH 1/3] ASoC: cs42l43: Add clear of stashed pointer on component remove Charles Keepax
  2024-02-02 14:06 ` [PATCH 2/3] ASoC: cs42l43: Sync the hp ilimit works when removing the component Charles Keepax
@ 2024-02-02 14:06 ` Charles Keepax
  2024-02-06  9:37 ` [PATCH 1/3] ASoC: cs42l43: Add clear of stashed pointer " Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Charles Keepax @ 2024-02-02 14:06 UTC (permalink / raw
  To: broonie; +Cc: lgirdwood, alsa-devel, patches, linux-sound

Disable the jack detection and sync in any currently running work when
the component is removed.

Signed-off-by: Charles Keepax <ckeepax@opensource.cirrus.com>
---
 sound/soc/codecs/cs42l43.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/sound/soc/codecs/cs42l43.c b/sound/soc/codecs/cs42l43.c
index c84d5952cdb5..256767ef4c03 100644
--- a/sound/soc/codecs/cs42l43.c
+++ b/sound/soc/codecs/cs42l43.c
@@ -2115,6 +2115,13 @@ static void cs42l43_component_remove(struct snd_soc_component *component)
 {
 	struct cs42l43_codec *priv = snd_soc_component_get_drvdata(component);
 
+	cs42l43_set_jack(priv->component, NULL, NULL);
+
+	cancel_delayed_work_sync(&priv->bias_sense_timeout);
+	cancel_delayed_work_sync(&priv->tip_sense_work);
+	cancel_delayed_work_sync(&priv->button_press_work);
+	cancel_work_sync(&priv->button_release_work);
+
 	cancel_work_sync(&priv->hp_ilimit_work);
 	cancel_delayed_work_sync(&priv->hp_ilimit_clear_work);
 
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/3] ASoC: cs42l43: Add clear of stashed pointer on component remove
  2024-02-02 14:06 [PATCH 1/3] ASoC: cs42l43: Add clear of stashed pointer on component remove Charles Keepax
  2024-02-02 14:06 ` [PATCH 2/3] ASoC: cs42l43: Sync the hp ilimit works when removing the component Charles Keepax
  2024-02-02 14:06 ` [PATCH 3/3] ASoC: cs42l43: Shut down jack detection on component remove Charles Keepax
@ 2024-02-06  9:37 ` Mark Brown
  2 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2024-02-06  9:37 UTC (permalink / raw
  To: Charles Keepax; +Cc: lgirdwood, alsa-devel, patches, linux-sound

On Fri, 02 Feb 2024 14:06:17 +0000, Charles Keepax wrote:
> If the component is removed the stashed component pointer in the
> CODECs private struct should also be cleared to prevent use of a stale
> pointer.
> 
> 

Applied to

   https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next

Thanks!

[1/3] ASoC: cs42l43: Add clear of stashed pointer on component remove
      commit: cd2a2388614fcf2b9b626332c0da53a2c6cbf2ee
[2/3] ASoC: cs42l43: Sync the hp ilimit works when removing the component
      commit: 7fa1a01ba6cb64bc24e7ba0dbee589f3f09f3cf7
[3/3] ASoC: cs42l43: Shut down jack detection on component remove
      commit: 3ef9f445ddb1e061ce497f54ca75bbaec52a3a46

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-02-06  9:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-02 14:06 [PATCH 1/3] ASoC: cs42l43: Add clear of stashed pointer on component remove Charles Keepax
2024-02-02 14:06 ` [PATCH 2/3] ASoC: cs42l43: Sync the hp ilimit works when removing the component Charles Keepax
2024-02-02 14:06 ` [PATCH 3/3] ASoC: cs42l43: Shut down jack detection on component remove Charles Keepax
2024-02-06  9:37 ` [PATCH 1/3] ASoC: cs42l43: Add clear of stashed pointer " Mark Brown

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).