LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH V2 0/2] ASoC: ak4458: fail on probe if codec is not present
@ 2019-05-13 10:02 Viorel Suman
  2019-05-13 10:02 ` [PATCH V2 1/2] ASoC: ak4458: rstn_control - return a non-zero on error only Viorel Suman
  2019-05-13 10:02 ` [PATCH V2 2/2] ASoC: ak4458: add return value for ak4458_probe Viorel Suman
  0 siblings, 2 replies; 5+ messages in thread
From: Viorel Suman @ 2019-05-13 10:02 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Viorel Suman, S.j. Wang, Daniel Baluta, Julia Lawall,
	Colin Ian King, alsa-devel, linux-kernel
  Cc: dl-linux-imx, Viorel Suman

AK4458 is probed successfully even if AK4458 is not present - this
is caused by probe function returning no error on i2c access failure.
The patchset fixes this.

Changes since V1:
  Conditional statement rewritten as suggested by Mark.

Viorel Suman (2):
  ASoC: ak4458: rstn_control - return a non-zero on error only
  ASoC: ak4458: add return value for ak4458_probe

 sound/soc/codecs/ak4458.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

-- 
2.7.4


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

* [PATCH V2 1/2] ASoC: ak4458: rstn_control - return a non-zero on error only
  2019-05-13 10:02 [PATCH V2 0/2] ASoC: ak4458: fail on probe if codec is not present Viorel Suman
@ 2019-05-13 10:02 ` Viorel Suman
  2019-05-13 11:12   ` [alsa-devel] " Daniel Baluta
  2019-05-13 10:02 ` [PATCH V2 2/2] ASoC: ak4458: add return value for ak4458_probe Viorel Suman
  1 sibling, 1 reply; 5+ messages in thread
From: Viorel Suman @ 2019-05-13 10:02 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Viorel Suman, S.j. Wang, Daniel Baluta, Julia Lawall,
	Colin Ian King, alsa-devel, linux-kernel
  Cc: dl-linux-imx, Viorel Suman

snd_soc_component_update_bits() may return 1 if operation
was successful and the value of the register changed.
Return a non-zero in ak4458_rstn_control for an error only.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
---
 sound/soc/codecs/ak4458.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c
index eab7c76..baf990a 100644
--- a/sound/soc/codecs/ak4458.c
+++ b/sound/soc/codecs/ak4458.c
@@ -304,7 +304,10 @@ static int ak4458_rstn_control(struct snd_soc_component *component, int bit)
 					  AK4458_00_CONTROL1,
 					  AK4458_RSTN_MASK,
 					  0x0);
-	return ret;
+	if (ret < 0)
+		return ret;
+
+	return 0;
 }
 
 static int ak4458_hw_params(struct snd_pcm_substream *substream,
-- 
2.7.4


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

* [PATCH V2 2/2] ASoC: ak4458: add return value for ak4458_probe
  2019-05-13 10:02 [PATCH V2 0/2] ASoC: ak4458: fail on probe if codec is not present Viorel Suman
  2019-05-13 10:02 ` [PATCH V2 1/2] ASoC: ak4458: rstn_control - return a non-zero on error only Viorel Suman
@ 2019-05-13 10:02 ` Viorel Suman
  2019-05-13 11:14   ` [alsa-devel] " Daniel Baluta
  1 sibling, 1 reply; 5+ messages in thread
From: Viorel Suman @ 2019-05-13 10:02 UTC (permalink / raw)
  To: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	Viorel Suman, S.j. Wang, Daniel Baluta, Julia Lawall,
	Colin Ian King, alsa-devel, linux-kernel
  Cc: dl-linux-imx, Viorel Suman

AK4458 is probed successfully even if AK4458 is not present - this
is caused by probe function returning no error on i2c access failure.
Return an error on probe if i2c access has failed.

Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
---
 sound/soc/codecs/ak4458.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c
index baf990a..7156215 100644
--- a/sound/soc/codecs/ak4458.c
+++ b/sound/soc/codecs/ak4458.c
@@ -539,9 +539,10 @@ static void ak4458_power_on(struct ak4458_priv *ak4458)
 	}
 }
 
-static void ak4458_init(struct snd_soc_component *component)
+static int ak4458_init(struct snd_soc_component *component)
 {
 	struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component);
+	int ret;
 
 	/* External Mute ON */
 	if (ak4458->mute_gpiod)
@@ -549,21 +550,21 @@ static void ak4458_init(struct snd_soc_component *component)
 
 	ak4458_power_on(ak4458);
 
-	snd_soc_component_update_bits(component, AK4458_00_CONTROL1,
+	ret = snd_soc_component_update_bits(component, AK4458_00_CONTROL1,
 			    0x80, 0x80);   /* ACKS bit = 1; 10000000 */
+	if (ret < 0)
+		return ret;
 
-	ak4458_rstn_control(component, 1);
+	return ak4458_rstn_control(component, 1);
 }
 
 static int ak4458_probe(struct snd_soc_component *component)
 {
 	struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component);
 
-	ak4458_init(component);
-
 	ak4458->fs = 48000;
 
-	return 0;
+	return ak4458_init(component);
 }
 
 static void ak4458_remove(struct snd_soc_component *component)
-- 
2.7.4


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

* Re: [alsa-devel] [PATCH V2 1/2] ASoC: ak4458: rstn_control - return a non-zero on error only
  2019-05-13 10:02 ` [PATCH V2 1/2] ASoC: ak4458: rstn_control - return a non-zero on error only Viorel Suman
@ 2019-05-13 11:12   ` Daniel Baluta
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Baluta @ 2019-05-13 11:12 UTC (permalink / raw)
  To: Viorel Suman
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	S.j. Wang, Daniel Baluta, Julia Lawall, Colin Ian King,
	alsa-devel, linux-kernel, Viorel Suman, dl-linux-imx

On Mon, May 13, 2019 at 1:04 PM Viorel Suman <viorel.suman@nxp.com> wrote:
>
> snd_soc_component_update_bits() may return 1 if operation
> was successful and the value of the register changed.
> Return a non-zero in ak4458_rstn_control for an error only.
>
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> Signed-off-by: Viorel Suman <viorel.suman@nxp.com>

Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>

> ---
>  sound/soc/codecs/ak4458.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c
> index eab7c76..baf990a 100644
> --- a/sound/soc/codecs/ak4458.c
> +++ b/sound/soc/codecs/ak4458.c
> @@ -304,7 +304,10 @@ static int ak4458_rstn_control(struct snd_soc_component *component, int bit)
>                                           AK4458_00_CONTROL1,
>                                           AK4458_RSTN_MASK,
>                                           0x0);
> -       return ret;
> +       if (ret < 0)
> +               return ret;
> +
> +       return 0;
>  }
>
>  static int ak4458_hw_params(struct snd_pcm_substream *substream,
> --
> 2.7.4
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

* Re: [alsa-devel] [PATCH V2 2/2] ASoC: ak4458: add return value for ak4458_probe
  2019-05-13 10:02 ` [PATCH V2 2/2] ASoC: ak4458: add return value for ak4458_probe Viorel Suman
@ 2019-05-13 11:14   ` Daniel Baluta
  0 siblings, 0 replies; 5+ messages in thread
From: Daniel Baluta @ 2019-05-13 11:14 UTC (permalink / raw)
  To: Viorel Suman
  Cc: Liam Girdwood, Mark Brown, Jaroslav Kysela, Takashi Iwai,
	S.j. Wang, Daniel Baluta, Julia Lawall, Colin Ian King,
	alsa-devel, linux-kernel, Viorel Suman, dl-linux-imx

On Mon, May 13, 2019 at 1:05 PM Viorel Suman <viorel.suman@nxp.com> wrote:
>
> AK4458 is probed successfully even if AK4458 is not present - this
> is caused by probe function returning no error on i2c access failure.
> Return an error on probe if i2c access has failed.
>
> Signed-off-by: Shengjiu Wang <shengjiu.wang@nxp.com>
> Signed-off-by: Viorel Suman <viorel.suman@nxp.com>

Reviewed-by: Daniel Baluta <daniel.baluta@nxp.com>

> ---
>  sound/soc/codecs/ak4458.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/sound/soc/codecs/ak4458.c b/sound/soc/codecs/ak4458.c
> index baf990a..7156215 100644
> --- a/sound/soc/codecs/ak4458.c
> +++ b/sound/soc/codecs/ak4458.c
> @@ -539,9 +539,10 @@ static void ak4458_power_on(struct ak4458_priv *ak4458)
>         }
>  }
>
> -static void ak4458_init(struct snd_soc_component *component)
> +static int ak4458_init(struct snd_soc_component *component)
>  {
>         struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component);
> +       int ret;
>
>         /* External Mute ON */
>         if (ak4458->mute_gpiod)
> @@ -549,21 +550,21 @@ static void ak4458_init(struct snd_soc_component *component)
>
>         ak4458_power_on(ak4458);
>
> -       snd_soc_component_update_bits(component, AK4458_00_CONTROL1,
> +       ret = snd_soc_component_update_bits(component, AK4458_00_CONTROL1,
>                             0x80, 0x80);   /* ACKS bit = 1; 10000000 */
> +       if (ret < 0)
> +               return ret;
>
> -       ak4458_rstn_control(component, 1);
> +       return ak4458_rstn_control(component, 1);
>  }
>
>  static int ak4458_probe(struct snd_soc_component *component)
>  {
>         struct ak4458_priv *ak4458 = snd_soc_component_get_drvdata(component);
>
> -       ak4458_init(component);
> -
>         ak4458->fs = 48000;
>
> -       return 0;
> +       return ak4458_init(component);
>  }
>
>  static void ak4458_remove(struct snd_soc_component *component)
> --
> 2.7.4
>
> _______________________________________________
> Alsa-devel mailing list
> Alsa-devel@alsa-project.org
> https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

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

end of thread, other threads:[~2019-05-13 11:14 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-13 10:02 [PATCH V2 0/2] ASoC: ak4458: fail on probe if codec is not present Viorel Suman
2019-05-13 10:02 ` [PATCH V2 1/2] ASoC: ak4458: rstn_control - return a non-zero on error only Viorel Suman
2019-05-13 11:12   ` [alsa-devel] " Daniel Baluta
2019-05-13 10:02 ` [PATCH V2 2/2] ASoC: ak4458: add return value for ak4458_probe Viorel Suman
2019-05-13 11:14   ` [alsa-devel] " Daniel Baluta

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 NNTP newsgroup(s).