<div dir="ltr"><div>Hi</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Mar 18, 2022 at 5:35 PM Meng Tang <<a href="mailto:tangmeng@uniontech.com">tangmeng@uniontech.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Today, hp_jack_event and mic_jack_event always return 0. However,<br>
snd_soc_dapm_disable_pin and snd_soc_dapm_enable_pin may return a<br>
non-zero value, this will cause the user who calling hp_jack_event<br>
and mic_jack_event don't know whether the operation was really<br>
successfully.<br>
<br>
This patch corrects the behavior by properly returning 1 when the<br>
value gets updated.<br>
<br>
Signed-off-by: Meng Tang <<a href="mailto:tangmeng@uniontech.com" target="_blank">tangmeng@uniontech.com</a>><br>
---<br>
 sound/soc/fsl/fsl-asoc-card.c | 16 ++++++++++------<br>
 1 file changed, 10 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/sound/soc/fsl/fsl-asoc-card.c b/sound/soc/fsl/fsl-asoc-card.c<br>
index 370bc790c6ba..f2641c2cb047 100644<br>
--- a/sound/soc/fsl/fsl-asoc-card.c<br>
+++ b/sound/soc/fsl/fsl-asoc-card.c<br>
@@ -457,16 +457,18 @@ static int fsl_asoc_card_audmux_init(struct device_node *np,<br>
 static int hp_jack_event(struct notifier_block *nb, unsigned long event,<br>
                         void *data)<br>
 {<br>
+       int ret;<br>
+<br>
        struct snd_soc_jack *jack = (struct snd_soc_jack *)data;<br>
        struct snd_soc_dapm_context *dapm = &jack->card->dapm;</blockquote><div>The "int ret" should be here.</div><div>The variables have order, the short one should be behind the long one.</div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> </blockquote><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
        if (event & SND_JACK_HEADPHONE)<br>
                /* Disable speaker if headphone is plugged in */<br>
-               snd_soc_dapm_disable_pin(dapm, "Ext Spk");<br>
+               ret = snd_soc_dapm_disable_pin(dapm, "Ext Spk");<br>
        else<br>
-               snd_soc_dapm_enable_pin(dapm, "Ext Spk");<br>
+               ret = snd_soc_dapm_enable_pin(dapm, "Ext Spk");<br>
<br>
-       return 0;<br>
+       return ret;<br>
 }<br>
<br>
 static struct notifier_block hp_jack_nb = {<br>
@@ -476,16 +478,18 @@ static struct notifier_block hp_jack_nb = {<br>
 static int mic_jack_event(struct notifier_block *nb, unsigned long event,<br>
                          void *data)<br>
 {<br>
+       int ret;<br>
+<br>
        struct snd_soc_jack *jack = (struct snd_soc_jack *)data;<br>
        struct snd_soc_dapm_context *dapm = &jack->card->dapm;<br></blockquote><div>ditto. </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
        if (event & SND_JACK_MICROPHONE)<br>
                /* Disable dmic if microphone is plugged in */<br>
-               snd_soc_dapm_disable_pin(dapm, "DMIC");<br>
+               ret = snd_soc_dapm_disable_pin(dapm, "DMIC");<br>
        else<br>
-               snd_soc_dapm_enable_pin(dapm, "DMIC");<br>
+               ret = snd_soc_dapm_enable_pin(dapm, "DMIC");<br>
<br>
-       return 0;<br>
+       return ret;<br>
 }<br>
<br>
 static struct notifier_block mic_jack_nb = {<br>
-- <br>
2.20.1<br>
<br>
<br>
<br>
</blockquote></div></div>