Skip to contentSkip to conversation

ASoC: Convert last few codecs to set_jack

PATCH In review Amadeusz Sławiński 4 participants 17 messages Oct 26 – Nov 2

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

cover ASoC: Convert last few codecs to set_jack

There were still few codecs left using old method of jack detection by exporting public *_mic_detect() function. Convert them to .set_jack callback.

First implement the wrapper around *_mic_detect, currently either none or just one of the arguments is used, so even if function exposes more, wrap it, by accepting only one. (If in the future there is usecase for more arguments, it can be easily added, by exposing jack setting struct, and passing it by data pointer.)

Then convert the boards to use standard snd_soc_component_set_jack call.

And finally remove *_mic_detect() from headers and unexport it.

Amadeusz Sławiński (12):
ASoC: codecs: wm8903: Implement set_jack callback
ASoC: codecs: wm8962: Implement set_jack callback
ASoC: codecs: wm8994: Implement set_jack callback
ASoC: tegra: tegra_wm8903: Use standard callback to set jack
ASoC: tegra: tegra_wm8962: Use standard callback to set jack
ASoC: tegra: tegra_wm8994: Use standard callback to set jack
ASoC: samsung: littlemill: Use standard callback to set jack
ASoC: samsung: midas_wm1811: Use standard callback to set jack
ASoC: samsung: tobermory: Use standard callback to set jack
ASoC: codecs: wm8903: Make wm8903_mic_detect() static
ASoC: codecs: wm8962: Make wm8962_mic_detect() static
ASoC: codecs: wm8994: Make mic detect functions static

 sound/soc/codecs/wm8903.c        | 18 +++++++++++++++---
 sound/soc/codecs/wm8903.h        |  5 -----
 sound/soc/codecs/wm8962.c        | 10 ++++++++--
 sound/soc/codecs/wm8962.h        |  2 --
 sound/soc/codecs/wm8994.c        | 30 +++++++++++++++++++++++-------
 sound/soc/codecs/wm8994.h        |  6 ------
 sound/soc/samsung/littlemill.c   |  6 +-----
 sound/soc/samsung/midas_wm1811.c |  3 +--
 sound/soc/samsung/tobermory.c    |  2 +-
 sound/soc/tegra/tegra_wm8903.c   |  5 ++---
 sound/soc/tegra/tegra_wm8962.c   |  4 ++--
 sound/soc/tegra/tegra_wm8994.c   |  4 ++--
 12 files changed, 55 insertions(+), 40 deletions(-)

base-commit: cc3fc99f1bce93c3ae3771ef98cb91a566da857e

Signature · 1 line
2.56.0
#1 lore raw

PATCH 1/12 ASoC: codecs: wm8903: Implement set_jack callback

Add set_jack callback to the component driver so machine drivers can use the standard snd_soc_component_set_jack() API instead of the driver-specific wm8903_mic_detect() helper.

---
 sound/soc/codecs/wm8903.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)
sound/soc/codecs/wm8903.c +12 -0
index 553f8d68a546..25a488f589a7 100644
@@ -1638,6 +1638,17 @@ int wm8903_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *
 }
 EXPORT_SYMBOL_GPL(wm8903_mic_detect);
 
+static int wm8903_set_jack(struct snd_soc_component *component,
+			   struct snd_soc_jack *jack, void *data)
+{
+	int *shrt = data;
+
+	if (!jack)
+		return wm8903_mic_detect(component, NULL, 0, 0);
+
+	return wm8903_mic_detect(component, jack, SND_JACK_MICROPHONE, shrt ? *shrt : 0);
+}
+
 static irqreturn_t wm8903_irq(int irq, void *data)
 {
 	struct wm8903_priv *wm8903 = data;
@@ -1902,6 +1913,7 @@ static void wm8903_free_gpio(struct wm8903_priv *wm8903)
 static const struct snd_soc_component_driver soc_component_dev_wm8903 = {
 	.resume			= wm8903_resume,
 	.set_bias_level		= wm8903_set_bias_level,
+	.set_jack		= wm8903_set_jack,
 	.seq_notifier		= wm8903_seq_notifier,
 	.controls		= wm8903_snd_controls,
 	.num_controls		= ARRAY_SIZE(wm8903_snd_controls),
Signature · 1 line
2.56.0
#2 lore raw

PATCH 2/12 ASoC: codecs: wm8962: Implement set_jack callback

In reply to Amadeusz Sławiński

Add set_jack callback to the component driver so machine drivers can use the standard snd_soc_component_set_jack() API instead of the driver-specific wm8962_mic_detect() helper.

---
 sound/soc/codecs/wm8962.c | 7 +++++++
 1 file changed, 7 insertions(+)
sound/soc/codecs/wm8962.c +7 -0
index db8b86d522ff..b36e73fabbdd 100644
@@ -3601,9 +3601,16 @@ static void wm8962_remove(struct snd_soc_component *component)
 	wm8962_free_beep(component);
 }
 
+static int wm8962_set_jack(struct snd_soc_component *component,
+			   struct snd_soc_jack *jack, void *data)
+{
+	return wm8962_mic_detect(component, jack);
+}
+
 static const struct snd_soc_component_driver soc_component_dev_wm8962 = {
 	.probe			= wm8962_probe,
 	.remove			= wm8962_remove,
+	.set_jack		= wm8962_set_jack,
 	.set_bias_level		= wm8962_set_bias_level,
 	.set_pll		= wm8962_set_fll,
 	.use_pmdown_time	= 1,
Signature · 1 line
2.56.0
#3 lore raw

PATCH 3/12 ASoC: codecs: wm8994: Implement set_jack callback

In reply to Amadeusz Sławiński

Add set_jack callback to the component driver so machine drivers can use the standard snd_soc_component_set_jack() API instead of driver-specific wm8994_mic_detect() and wm8958_mic_detect() helpers.

---
 sound/soc/codecs/wm8994.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
sound/soc/codecs/wm8994.c +18 -0
index 6b91e02f130b..69afba1764eb 100644
@@ -4642,12 +4642,30 @@ static void wm8994_component_remove(struct snd_soc_component *component)
 	kfree(wm8994->retune_mobile_texts);
 }
 
+static int wm8994_set_jack(struct snd_soc_component *component,
+			   struct snd_soc_jack *jack, void *data)
+{
+	struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
+	struct wm8994 *control = wm8994->wm8994;
+
+	switch (control->type) {
+	case WM8994:
+		return wm8994_mic_detect(component, jack, data ? *(int *)data : 1);
+	case WM1811:
+	case WM8958:
+		return wm8958_mic_detect(component, jack, NULL, NULL, NULL, NULL);
+	default:
+		return -EINVAL;
+	}
+}
+
 static const struct snd_soc_component_driver soc_component_dev_wm8994 = {
 	.probe			= wm8994_component_probe,
 	.remove			= wm8994_component_remove,
 	.suspend		= wm8994_component_suspend,
 	.resume			= wm8994_component_resume,
 	.set_bias_level		= wm8994_set_bias_level,
+	.set_jack		= wm8994_set_jack,
 	.idle_bias_on		= 1,
 	.use_pmdown_time	= 1,
 	.endianness		= 1,
Signature · 1 line
2.56.0
#4 lore raw

Re: [PATCH 03/12] ASoC: codecs: wm8994: Implement set_jack callback

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] ASoC: wm8994: stale jack pointer and active work in wm8958_mic_detect() --

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] ASoC: wm8994: stale jack pointer and active work in wm8958_mic_detect() --

commit 0dc23f1f04114660da148a373855c1151a4983df
Author: Amadeusz Sławiński <[email protected]>

ASoC: codecs: wm8994: Implement set_jack callback

This commit implements the set_jack callback for the wm8994 component driver, delegating to wm8994_mic_detect() for WM8994 and wm8958_mic_detect() for WM1811 and WM8958 so machine drivers can use snd_soc_component_set_jack().

Quoted 10 lines
sound/soc/codecs/wm8994.c +2 -0
index 6b91e02f130b3..69afba1764eb7 100644
@@ -4642,12 +4642,30 @@ static void wm8994_component_remove(struct snd_soc_component *component)
 	kfree(wm8994->retune_mobile_texts);
 }
 
+static int wm8994_set_jack(struct snd_soc_component *component,
+			   struct snd_soc_jack *jack, void *data)

sound/soc/codecs/wm8994.c static void wm8994_component_remove(struct snd_soc_component *component) · line 4656

Quoted 10 lines
sound/soc/codecs/wm8994.c +10 -0
+{
+	struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
+	struct wm8994 *control = wm8994->wm8994;
+
+	switch (control->type) {
+	case WM8994:
+		return wm8994_mic_detect(component, jack, data ? *(int *)data : 1);
+	case WM1811:
+	case WM8958:
+		return wm8958_mic_detect(component, jack, NULL, NULL, NULL, NULL);

[Severity: High]
When snd_soc_component_set_jack(component, NULL, NULL) is called during jack teardown or card unbind on WM1811 or WM8958, wm8994_set_jack() passes a NULL jack pointer to wm8958_mic_detect().

In sound/soc/codecs/wm8994.c, the NULL jack branch of wm8958_mic_detect() does not clear wm8994->micdet[0].jack or cancel pending delayed work:

	} else {
		snd_soc_component_update_bits(component, WM8958_MIC_DETECT_1,
				    WM8958_MICD_ENA, 0);
		wm1811_jackdet_set_mode(component, WM1811_JACKDET_MODE_NONE);
		snd_soc_dapm_disable_pin(dapm, "CLK_SYS");
		snd_soc_dapm_sync(dapm);
	}

Because wm8994->micdet[0].jack remains non-NULL, wm1811_jackdet_set_mode() still treats jack detection as active:

	if (!wm8994->jackdet || !wm8994->micdet[0].jack)
		return;

	if (wm8994->active_refcount)
		mode = WM1811_JACKDET_MODE_AUDIO;

If wm8994->active_refcount is non-zero during teardown, wm1811_jackdet_set_mode() overrides WM1811_JACKDET_MODE_NONE with WM1811_JACKDET_MODE_AUDIO, and subsequent active_dereference() calls re-arm hardware jack or microphone detection.

In addition, pending delayed work items such as wm8958_open_circuit_work, wm1811_jackdet_bootstrap, wm1811_mic_work, and wm8958_mic_work are not canceled and can still dereference the stale wm8994->micdet[0].jack pointer:

	snd_soc_jack_report(wm8994->micdet[0].jack, 0,
			    wm8994->btn_mask |
			    SND_JACK_HEADSET);

Can this leave a dangling jack pointer and cause a use-after-free in snd_soc_jack_report() after the jack is freed?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
#5 lore raw

Re: [PATCH 03/12] ASoC: codecs: wm8994: Implement set_jack callback

Quoted 5 lines · On Mon, 26 Oct 2026 20:34:59 +0000 [email protected] wrote:

[Severity: High]
When snd_soc_component_set_jack(component, NULL, NULL) is called during jack teardown or card unbind on WM1811 or WM8958, wm8994_set_jack() passes a NULL jack pointer to wm8958_mic_detect().

On one hand yes, on the other current code doesn't have those cleanup calls. It should probably be fixed as a followup series.

#6 lore raw

PATCH 4/12 ASoC: tegra: tegra_wm8903: Use standard callback to set jack

In reply to Amadeusz Sławiński

Use snd_soc_component_set_jack() instead of the driver-specific wm8903_mic_detect() callback.

---
 sound/soc/tegra/tegra_wm8903.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
sound/soc/tegra/tegra_wm8903.c +2 -3
index 91180f4cfe17..efd46d4407e6 100644
@@ -93,8 +93,7 @@ static int tegra_wm8903_init(struct snd_soc_pcm_runtime *rtd)
 		if (of_property_read_bool(card->dev->of_node, "nvidia,headset"))
 			shrt = SND_JACK_MICROPHONE;
 
-		wm8903_mic_detect(component, machine->mic_jack,
-				  SND_JACK_MICROPHONE, shrt);
+		snd_soc_component_set_jack(component, machine->mic_jack, &shrt);
 	}
 
 	snd_soc_dapm_force_enable_pin(dapm, "MICBIAS");
@@ -109,7 +108,7 @@ static int tegra_wm8903_remove(struct snd_soc_card *card)
 	struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
 	struct snd_soc_component *component = codec_dai->component;
 
-	wm8903_mic_detect(component, NULL, 0, 0);
+	snd_soc_component_set_jack(component, NULL, NULL);
 
 	return 0;
 }
Signature · 1 line
2.56.0
#7 lore raw

PATCH 5/12 ASoC: tegra: tegra_wm8962: Use standard callback to set jack

In reply to Amadeusz Sławiński

Use snd_soc_component_set_jack() instead of the driver-specific wm8962_mic_detect() callback.

---
 sound/soc/tegra/tegra_wm8962.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/tegra/tegra_wm8962.c +2 -2
index 31f9d9181595..1ace9261a0f3 100644
@@ -89,7 +89,7 @@ static int tegra_wm8962_init(struct snd_soc_pcm_runtime *rtd)
 			return err;
 		}
 
-		wm8962_mic_detect(component, machine->mic_jack);
+		snd_soc_component_set_jack(component, machine->mic_jack, NULL);
 	}
 
 	snd_soc_dapm_force_enable_pin(dapm, "MICBIAS");
@@ -104,7 +104,7 @@ static int tegra_wm8962_remove(struct snd_soc_card *card)
 	struct snd_soc_dai *codec_dai = snd_soc_rtd_to_codec(rtd, 0);
 	struct snd_soc_component *component = codec_dai->component;
 
-	wm8962_mic_detect(component, NULL);
+	snd_soc_component_set_jack(component, NULL, NULL);
 
 	return 0;
 }
Signature · 1 line
2.56.0
#8 lore raw

PATCH 6/12 ASoC: tegra: tegra_wm8994: Use standard callback to set jack

In reply to Amadeusz Sławiński

Use snd_soc_component_set_jack() instead of the driver-specific wm8994_mic_detect() callback.

---
 sound/soc/tegra/tegra_wm8994.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
sound/soc/tegra/tegra_wm8994.c +2 -2
index 1550faeba725..11e0ad96caf4 100644
@@ -98,7 +98,7 @@ static int tegra_wm8994_init(struct snd_soc_pcm_runtime *rtd)
 			return err;
 		}
 
-		wm8994_mic_detect(component, machine->mic_jack, 1);
+		snd_soc_component_set_jack(component, machine->mic_jack, NULL);
 	}
 
 	return 0;
@@ -113,7 +113,7 @@ static int tegra_wm8994_remove(struct snd_soc_card *card)
 	struct snd_soc_component *component = codec_dai->component;
 
 	if (!machine->gpiod_mic_det && machine->asoc->add_mic_jack)
-		wm8994_mic_detect(component, NULL, 1);
+		snd_soc_component_set_jack(component, NULL, NULL);
 
 	return 0;
 }
Signature · 1 line
2.56.0
#9 lore raw

PATCH 7/12 ASoC: samsung: littlemill: Use standard callback to set jack

In reply to Amadeusz Sławiński

Use snd_soc_component_set_jack() instead of driver-specific wm8958_mic_detect() and wm8994_mic_detect() callbacks.

---
 sound/soc/samsung/littlemill.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
sound/soc/samsung/littlemill.c +1 -5
index d0d1b1ee326e..fca2e18877f2 100644
@@ -302,11 +302,7 @@ static int littlemill_late_probe(struct snd_soc_card *card)
 	if (ret)
 		return ret;
 
-	/* This will check device compatibility itself */
-	wm8958_mic_detect(component, &littlemill_headset, NULL, NULL, NULL, NULL);
-
-	/* As will this */
-	wm8994_mic_detect(component, &littlemill_headset, 1);
+	snd_soc_component_set_jack(component, &littlemill_headset, NULL);
 
 	return 0;
 }
Signature · 1 line
2.56.0
#10 lore raw

PATCH 8/12 ASoC: samsung: midas_wm1811: Use standard callback to set jack

In reply to Amadeusz Sławiński

Use snd_soc_component_set_jack() instead of the driver-specific wm8958_mic_detect() callback.

---
 sound/soc/samsung/midas_wm1811.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
sound/soc/samsung/midas_wm1811.c +1 -2
index 11466dd3539e..9f27f4cad124 100644
@@ -425,8 +425,7 @@ static int midas_late_probe(struct snd_soc_card *card)
 		if (ret)
 			return ret;
 
-		wm8958_mic_detect(aif1_dai->component, &priv->headset_jack,
-				  NULL, NULL, NULL, NULL);
+		snd_soc_component_set_jack(aif1_dai->component, &priv->headset_jack, NULL);
 	} else {
 		/* Some devices (n8000, t310) use a GPIO to detect the jack. */
 		ret = snd_soc_card_jack_new_pins(card, "Headset",
Signature · 1 line
2.56.0
#11 lore raw

PATCH 9/12 ASoC: samsung: tobermory: Use standard callback to set jack

In reply to Amadeusz Sławiński

Use snd_soc_component_set_jack() instead of the driver-specific wm8962_mic_detect() callback.

---
 sound/soc/samsung/tobermory.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
sound/soc/samsung/tobermory.c +1 -1
index 5448c16199bd..2cce1aa0c5ec 100644
@@ -193,7 +193,7 @@ static int tobermory_late_probe(struct snd_soc_card *card)
 	if (ret)
 		return ret;
 
-	wm8962_mic_detect(component, &tobermory_headset);
+	snd_soc_component_set_jack(component, &tobermory_headset, NULL);
 
 	return 0;
 }
Signature · 1 line
2.56.0
#12 lore raw

PATCH 10/12 ASoC: codecs: wm8903: Make wm8903_mic_detect() static

In reply to Amadeusz Sławiński

Now that all callers have been switched to snd_soc_component_set_jack(), make wm8903_mic_detect() static and unexport it.

---
 sound/soc/codecs/wm8903.c | 6 +++---
 sound/soc/codecs/wm8903.h | 5 -----
 2 files changed, 3 insertions(+), 8 deletions(-)
sound/soc/codecs/wm8903.c +3 -3
index 25a488f589a7..9dbc295b0889 100644
@@ -1598,8 +1598,9 @@ static int wm8903_hw_params(struct snd_pcm_substream *substream,
  * micdet_cfg in the platform data.  Using this function will force on
  * the microphone bias for the device.
  */
-int wm8903_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack,
-		      int det, int shrt)
+static int wm8903_mic_detect(struct snd_soc_component *component,
+			     struct snd_soc_jack *jack,
+			     int det, int shrt)
 {
 	struct wm8903_priv *wm8903 = snd_soc_component_get_drvdata(component);
 	int irq_mask = WM8903_MICDET_EINT | WM8903_MICSHRT_EINT;
@@ -1636,7 +1637,6 @@ int wm8903_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(wm8903_mic_detect);
 
 static int wm8903_set_jack(struct snd_soc_component *component,
 			   struct snd_soc_jack *jack, void *data)
sound/soc/codecs/wm8903.h +0 -5
index 4b036f4b755e..2526d0c69029 100644
@@ -11,11 +11,6 @@
 
 #include <linux/i2c.h>
 
-extern int wm8903_mic_detect(struct snd_soc_component *component,
-			     struct snd_soc_jack *jack,
-			     int det, int shrt);
-
-
 /*
  * Register values.
  */
Signature · 1 line
2.56.0
#13 lore raw

PATCH 11/12 ASoC: codecs: wm8962: Make wm8962_mic_detect() static

In reply to Amadeusz Sławiński

Now that all callers have been switched to snd_soc_component_set_jack(), make wm8962_mic_detect() static and unexport it.

---
 sound/soc/codecs/wm8962.c | 3 +--
 sound/soc/codecs/wm8962.h | 2 --
 2 files changed, 1 insertion(+), 4 deletions(-)
sound/soc/codecs/wm8962.c +1 -2
index b36e73fabbdd..31c9080cd814 100644
@@ -3244,7 +3244,7 @@ static irqreturn_t wm8962_irq(int irq, void *data)
  *
  * If no jack is supplied detection will be disabled.
  */
-int wm8962_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack)
+static int wm8962_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack)
 {
 	struct wm8962_priv *wm8962 = snd_soc_component_get_drvdata(component);
 	struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component);
@@ -3282,7 +3282,6 @@ int wm8962_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(wm8962_mic_detect);
 
 static int beep_rates[] = {
 	500, 1000, 2000, 4000,
sound/soc/codecs/wm8962.h +0 -2
index e7f4a70ab8a4..f7e886978a50 100644
@@ -3776,6 +3776,4 @@
 #define WM8962_VSS_ENA_SHIFT                         0  /* VSS_ENA */
 #define WM8962_VSS_ENA_WIDTH                         1  /* VSS_ENA */
 
-int wm8962_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack);
-
 #endif
Signature · 1 line
2.56.0
#14 lore raw

PATCH 12/12 ASoC: codecs: wm8994: Make mic detect functions static

In reply to Amadeusz Sławiński

Now that all callers have been switched to snd_soc_component_set_jack(), make wm8994_mic_detect() and wm8958_mic_detect() static and unexport them.

---
 sound/soc/codecs/wm8994.c | 12 +++++-------
 sound/soc/codecs/wm8994.h |  6 ------
 2 files changed, 5 insertions(+), 13 deletions(-)
sound/soc/codecs/wm8994.c +5 -7
index 69afba1764eb..43b5a05253d4 100644
@@ -3540,8 +3540,8 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994)
  * Configuration of detection levels is available via the micbias1_lvl
  * and micbias2_lvl platform data members.
  */
-int wm8994_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack,
-		      int micbias)
+static int wm8994_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack,
+			     int micbias)
 {
 	struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component);
 	struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
@@ -3608,7 +3608,6 @@ int wm8994_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(wm8994_mic_detect);
 
 static void wm8994_mic_work(struct work_struct *work)
 {
@@ -3959,9 +3958,9 @@ static void wm1811_jackdet_bootstrap(struct work_struct *work)
  * flexiblity a callback is provided which allows a completely custom
  * detection algorithm.
  */
-int wm8958_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack,
-		      wm1811_micdet_cb det_cb, void *det_cb_data,
-		      wm1811_mic_id_cb id_cb, void *id_cb_data)
+static int wm8958_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack,
+			     wm1811_micdet_cb det_cb, void *det_cb_data,
+			     wm1811_mic_id_cb id_cb, void *id_cb_data)
 {
 	struct snd_soc_dapm_context *dapm = snd_soc_component_to_dapm(component);
 	struct wm8994_priv *wm8994 = snd_soc_component_get_drvdata(component);
@@ -4050,7 +4049,6 @@ int wm8958_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *
 
 	return 0;
 }
-EXPORT_SYMBOL_GPL(wm8958_mic_detect);
 
 static void wm8958_mic_work(struct work_struct *work)
 {
sound/soc/codecs/wm8994.h +0 -6
index e7df0a1a2314..7ed5f5e50fc0 100644
@@ -47,12 +47,6 @@ enum wm8994_vmid_mode {
 typedef void (*wm1811_micdet_cb)(void *data);
 typedef void (*wm1811_mic_id_cb)(void *data, u16 status);
 
-int wm8994_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack,
-		      int micbias);
-int wm8958_mic_detect(struct snd_soc_component *component, struct snd_soc_jack *jack,
-		      wm1811_micdet_cb det_cb, void *det_cb_data,
-		      wm1811_mic_id_cb id_cb, void *id_cb_data);
-
 int wm8994_vmid_mode(struct snd_soc_component *component, enum wm8994_vmid_mode mode);
 
 int wm8958_aif_ev(struct snd_soc_dapm_widget *w,
Signature · 1 line
2.56.0
Reviewed-by on the v1 series
#15 lore raw
In reply to Amadeusz Sławiński
Quoted 28 lines · Amadeusz Sławiński

There were still few codecs left using old method of jack detection by exporting public *_mic_detect() function. Convert them to .set_jack callback.

First implement the wrapper around *_mic_detect, currently either none or just one of the arguments is used, so even if function exposes more, wrap it, by accepting only one. (If in the future there is usecase for more arguments, it can be easily added, by exposing jack setting struct, and passing it by data pointer.)

Then convert the boards to use standard snd_soc_component_set_jack call.

And finally remove *_mic_detect() from headers and unexport it.

Amadeusz Sławiński (12):
ASoC: codecs: wm8903: Implement set_jack callback
ASoC: codecs: wm8962: Implement set_jack callback
ASoC: codecs: wm8994: Implement set_jack callback
ASoC: tegra: tegra_wm8903: Use standard callback to set jack
ASoC: tegra: tegra_wm8962: Use standard callback to set jack
ASoC: tegra: tegra_wm8994: Use standard callback to set jack
ASoC: samsung: littlemill: Use standard callback to set jack
ASoC: samsung: midas_wm1811: Use standard callback to set jack
ASoC: samsung: tobermory: Use standard callback to set jack
ASoC: codecs: wm8903: Make wm8903_mic_detect() static
ASoC: codecs: wm8962: Make wm8962_mic_detect() static
ASoC: codecs: wm8994: Make mic detect functions static

Quoted 13 lines
 sound/soc/codecs/wm8903.c        | 18 +++++++++++++++---
 sound/soc/codecs/wm8903.h        |  5 -----
 sound/soc/codecs/wm8962.c        | 10 ++++++++--
 sound/soc/codecs/wm8962.h        |  2 --
 sound/soc/codecs/wm8994.c        | 30 +++++++++++++++++++++++-------
 sound/soc/codecs/wm8994.h        |  6 ------
 sound/soc/samsung/littlemill.c   |  6 +-----
 sound/soc/samsung/midas_wm1811.c |  3 +--
 sound/soc/samsung/tobermory.c    |  2 +-
 sound/soc/tegra/tegra_wm8903.c   |  5 ++---
 sound/soc/tegra/tegra_wm8962.c   |  4 ++--
 sound/soc/tegra/tegra_wm8994.c   |  4 ++--
 12 files changed, 55 insertions(+), 40 deletions(-)

Thanks,
Charles

maintainer
#16 lore raw
In reply to Amadeusz Sławiński
Quoted 6 lines · Amadeusz Sławiński

ASoC: Convert last few codecs to set_jack

There were still few codecs left using old method of jack detection by exporting public *_mic_detect() function. Convert them to .set_jack callback.

Quoted 7 lines

First implement the wrapper around *_mic_detect, currently either none or just one of the arguments is used, so even if function exposes more, wrap it, by accepting only one. (If in the future there is usecase for more arguments, it can be easily added, by exposing jack setting struct, and passing it by data pointer.)

[...]

Applied to

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

Thanks!

[01/12] ASoC: codecs: wm8903: Implement set_jack callback

        https://git.kernel.org/broonie/sound/c/a4caab7d56de
[02/12] ASoC: codecs: wm8962: Implement set_jack callback
        https://git.kernel.org/broonie/sound/c/800168760d8c
[03/12] ASoC: codecs: wm8994: Implement set_jack callback
        https://git.kernel.org/broonie/sound/c/4a6580462040
[04/12] ASoC: tegra: tegra_wm8903: Use standard callback to set jack
        https://git.kernel.org/broonie/sound/c/a0fd49280f20
[05/12] ASoC: tegra: tegra_wm8962: Use standard callback to set jack
        https://git.kernel.org/broonie/sound/c/ef64cd77d560
[06/12] ASoC: tegra: tegra_wm8994: Use standard callback to set jack
        https://git.kernel.org/broonie/sound/c/d62ba82ac0c4
[07/12] ASoC: samsung: littlemill: Use standard callback to set jack
        https://git.kernel.org/broonie/sound/c/e239f7051461
[08/12] ASoC: samsung: midas_wm1811: Use standard callback to set jack
        https://git.kernel.org/broonie/sound/c/acaf89519907
[09/12] ASoC: samsung: tobermory: Use standard callback to set jack
        https://git.kernel.org/broonie/sound/c/8d1075ae5a3e
[10/12] ASoC: codecs: wm8903: Make wm8903_mic_detect() static
        https://git.kernel.org/broonie/sound/c/677bd4322e5b
[11/12] ASoC: codecs: wm8962: Make wm8962_mic_detect() static
        https://git.kernel.org/broonie/sound/c/cc0b45ca04c5
[12/12] ASoC: codecs: wm8994: Make mic detect functions static
        https://git.kernel.org/broonie/sound/c/36b7514ec139

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