diff mbox series

[1/3] ASoC: codecs: rtq9128: Fix string compare in DAPM event callback

Message ID 1697795435-5858-2-git-send-email-cy_huang@richtek.com (mailing list archive)
State New, archived
Headers show
Series ASoC: codecs: rtq9128: Several application fixes | expand

Commit Message

ChiYuan Huang Oct. 20, 2023, 9:50 a.m. UTC
From: ChiYuan Huang <cy_huang@richtek.com>

Since widget name may concatenate the component prefix. To compare the
the name with 'strcmp' function in shared DAPM event callback will
cause the wrong RG field control. Use 'strstr' function, instead.

Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
---
 sound/soc/codecs/rtq9128.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

Comments

ChiYuan Huang Oct. 31, 2023, 9:45 a.m. UTC | #1
On Fri, Oct 20, 2023 at 05:50:33PM +0800, cy_huang@richtek.com wrote:
> From: ChiYuan Huang <cy_huang@richtek.com>
> 
> Since widget name may concatenate the component prefix. To compare the
> the name with 'strcmp' function in shared DAPM event callback will
> cause the wrong RG field control. Use 'strstr' function, instead.
> 
> Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
> ---
>  sound/soc/codecs/rtq9128.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/sound/soc/codecs/rtq9128.c b/sound/soc/codecs/rtq9128.c
> index 371d622c6214..8c1c3c65475e 100644
> --- a/sound/soc/codecs/rtq9128.c
> +++ b/sound/soc/codecs/rtq9128.c
> @@ -291,11 +291,11 @@ static int rtq9128_dac_power_event(struct snd_soc_dapm_widget *w, struct snd_kco
>  
>  	dev_dbg(comp->dev, "%s: %s event %d\n", __func__, w->name, event);
>  
> -	if (strcmp(w->name, "DAC1") == 0)
> +	if (strstr(w->name, "DAC1"))
>  		shift = 6;
> -	else if (strcmp(w->name, "DAC2") == 0)
> +	else if (strstr(w->name, "DAC2"))
>  		shift = 4;
> -	else if (strcmp(w->name, "DAC3") == 0)
> +	else if (strstr(w->name, "DAC3"))
>  		shift = 2;
>  	else
>  		shift = 0;
https://lore.kernel.org/lkml/20231023095428.166563-8-krzysztof.kozlowski@linaro.org/
Since the better change is applied. Please ignore this one.

Still wait the other patch(2&3)'s feedback.

Thanks.
> -- 
> 2.34.1
>
diff mbox series

Patch

diff --git a/sound/soc/codecs/rtq9128.c b/sound/soc/codecs/rtq9128.c
index 371d622c6214..8c1c3c65475e 100644
--- a/sound/soc/codecs/rtq9128.c
+++ b/sound/soc/codecs/rtq9128.c
@@ -291,11 +291,11 @@  static int rtq9128_dac_power_event(struct snd_soc_dapm_widget *w, struct snd_kco
 
 	dev_dbg(comp->dev, "%s: %s event %d\n", __func__, w->name, event);
 
-	if (strcmp(w->name, "DAC1") == 0)
+	if (strstr(w->name, "DAC1"))
 		shift = 6;
-	else if (strcmp(w->name, "DAC2") == 0)
+	else if (strstr(w->name, "DAC2"))
 		shift = 4;
-	else if (strcmp(w->name, "DAC3") == 0)
+	else if (strstr(w->name, "DAC3"))
 		shift = 2;
 	else
 		shift = 0;