Skip to contentSkip to conversation

ASoC: Fix wrong data type access in a few codec drivers

PATCH Applied Jarkko Nikula 4 participants 4 messages May 13, 2011 – May 16, 2011

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

PATCH v2 1/1 ASoC: Fix wrong data type access in a few codec drivers

Commit fafd217 ("ASoC: Store a list of widgets in a DAPM mux/mixer kcontrol") changed the control private data type that is passed to snd_soc_cnew when creating dapm mixer and mux controls. Commit did not update a few codec drivers that are using their own put callbacks and thus are accessing a wrong data type.

---
v2:
- wm8994 and wm8995 needs to be changed too. Thanks to Stephen Warren <[email protected]> for noticing.
- "Otherwise, on Tegra+WM8903, I repro'd the bug, and tested the fix, so:

---
 sound/soc/codecs/tlv320aic3x.c |    3 ++-
 sound/soc/codecs/wm8903.c      |    3 ++-
 sound/soc/codecs/wm8993.c      |    3 ++-
 sound/soc/codecs/wm8994.c      |    6 ++++--
 sound/soc/codecs/wm8995.c      |    4 ++--
 5 files changed, 12 insertions(+), 7 deletions(-)
sound/soc/codecs/tlv320aic3x.c +2 -1
index 6c43c13..c3d96fc 100644
@@ -157,7 +157,8 @@ static int aic3x_read(struct snd_soc_codec *codec, unsigned int reg,
 static int snd_soc_dapm_put_volsw_aic3x(struct snd_kcontrol *kcontrol,
 					struct snd_ctl_elem_value *ucontrol)
 {
-	struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
+	struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
+	struct snd_soc_dapm_widget *widget = wlist->widgets[0];
 	struct soc_mixer_control *mc =
 		(struct soc_mixer_control *)kcontrol->private_value;
 	unsigned int reg = mc->reg;
sound/soc/codecs/wm8903.c +2 -1
index 957cd66..43e3d76 100644
@@ -382,7 +382,8 @@ static void wm8903_seq_notifier(struct snd_soc_dapm_context *dapm,
 static int wm8903_class_w_put(struct snd_kcontrol *kcontrol,
 			      struct snd_ctl_elem_value *ucontrol)
 {
-	struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
+	struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
+	struct snd_soc_dapm_widget *widget = wlist->widgets[0];
 	struct snd_soc_codec *codec = widget->codec;
 	struct wm8903_priv *wm8903 = snd_soc_codec_get_drvdata(codec);
 	u16 reg;
sound/soc/codecs/wm8993.c +2 -1
index 056aef9..9e5ff78 100644
@@ -718,7 +718,8 @@ static int clk_sys_event(struct snd_soc_dapm_widget *w,
 static int class_w_put(struct snd_kcontrol *kcontrol,
 		       struct snd_ctl_elem_value *ucontrol)
 {
-	struct snd_soc_dapm_widget *widget = snd_kcontrol_chip(kcontrol);
+	struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
+	struct snd_soc_dapm_widget *widget = wlist->widgets[0];
 	struct snd_soc_codec *codec = widget->codec;
 	struct wm8993_priv *wm8993 = snd_soc_codec_get_drvdata(codec);
 	int ret;
sound/soc/codecs/wm8994.c +4 -2
index e6dfa10..970a95c 100644
@@ -877,7 +877,8 @@ static const char *hp_mux_text[] = {
 static int wm8994_put_hp_enum(struct snd_kcontrol *kcontrol,
 			      struct snd_ctl_elem_value *ucontrol)
 {
-	struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol);
+	struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
+	struct snd_soc_dapm_widget *w = wlist->widgets[0];
 	struct snd_soc_codec *codec = w->codec;
 	int ret;
 
@@ -1004,7 +1005,8 @@ SOC_DAPM_SINGLE("AIF1.1 Switch", WM8994_DAC2_RIGHT_MIXER_ROUTING,
 static int wm8994_put_class_w(struct snd_kcontrol *kcontrol,
 			      struct snd_ctl_elem_value *ucontrol)
 {
-	struct snd_soc_dapm_widget *w = snd_kcontrol_chip(kcontrol);
+	struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
+	struct snd_soc_dapm_widget *w = wlist->widgets[0];
 	struct snd_soc_codec *codec = w->codec;
 	int ret;
 
sound/soc/codecs/wm8995.c +2 -2
index 67eaaec..5ad873f 100644
@@ -305,11 +305,11 @@ static int check_clk_sys(struct snd_soc_dapm_widget *source,
 static int wm8995_put_class_w(struct snd_kcontrol *kcontrol,
 			      struct snd_ctl_elem_value *ucontrol)
 {
-	struct snd_soc_dapm_widget *w;
+	struct snd_soc_dapm_widget_list *wlist = snd_kcontrol_chip(kcontrol);
+	struct snd_soc_dapm_widget *w = wlist->widgets[0];
 	struct snd_soc_codec *codec;
 	int ret;
 
-	w = snd_kcontrol_chip(kcontrol);
 	codec = w->codec;
 	ret = snd_soc_dapm_put_volsw(kcontrol, ucontrol);
 	wm8995_update_class_w(codec);
Signature · 1 line
1.7.0.4
Acked-by on v2 1/1
#1 lore raw

Jarkko Nikula wrote at Friday, May 13, 2011 10:17 AM:

Quoted 7 lines

Commit fafd217 ("ASoC: Store a list of widgets in a DAPM mux/mixer kcontrol")
changed the control private data type that is passed to snd_soc_cnew when creating dapm mixer and mux controls. Commit did not update a few codec drivers that are using their own put callbacks and thus are accessing a wrong data type.

Quoted 8 lines

---
v2:
- wm8994 and wm8995 needs to be changed too. Thanks to Stephen Warren <[email protected]> for noticing.
- "Otherwise, on Tegra+WM8903, I repro'd the bug, and tested the fix, so:

This version looks good to me. I guess that means:

... although I figure my Tested-by is probably enough.

Thanks for fixing my bugs!

Signature · 1 line
nvpublic
Acked-by
#2 lore raw
Quoted 17 lines · Stephen Warren

Jarkko Nikula wrote at Friday, May 13, 2011 10:17 AM:

Quoted 7 lines

Commit fafd217 ("ASoC: Store a list of widgets in a DAPM mux/mixer kcontrol")
changed the control private data type that is passed to snd_soc_cnew when creating dapm mixer and mux controls. Commit did not update a few codec drivers that are using their own put callbacks and thus are accessing a wrong data type.

Quoted 8 lines

---
v2:
- wm8994 and wm8995 needs to be changed too. Thanks to Stephen Warren <[email protected]> for noticing.
- "Otherwise, on Tegra+WM8903, I repro'd the bug, and tested the fix, so:

Quoted 8 lines

This version looks good to me. I guess that means:

... although I figure my Tested-by is probably enough.

Thanks for fixing my bugs!

Applied
#3 lore raw
In reply to Jarkko Nikula
Quoted 5 lines · Jarkko Nikula

Commit fafd217 ("ASoC: Store a list of widgets in a DAPM mux/mixer kcontrol") changed the control private data type that is passed to snd_soc_cnew when creating dapm mixer and mux controls. Commit did not update a few codec drivers that are using their own put callbacks and thus are accessing a wrong data type.

Applied, thanks.