Skip to contentSkip to conversation

ASoC: ak4458: fail on probe if codec is not present

PATCH In review Viorel Suman 3 participants 6 messages May 13, 2019

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

v2 cover ASoC: ak4458: fail on probe if codec is not present

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(-)
Signature · 1 line
2.7.4
#1 lore raw

PATCH v2 1/2 ASoC: ak4458: rstn_control - return a non-zero on error only

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.

---
 sound/soc/codecs/ak4458.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/codecs/ak4458.c +4 -1
index eab7c76..baf990a 100644
@@ -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,
Signature · 1 line
2.7.4
Reviewed-by on v2 1/2
#2 lore raw

Re: [alsa-devel] [PATCH V2 1/2] ASoC: ak4458: rstn_control - return a non-zero on error only

Quoted 7 lines · 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.

Quoted 27 lines
---
 sound/soc/codecs/ak4458.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/codecs/ak4458.c +4 -2
index eab7c76..baf990a 100644
@@ -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
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel

maintainer
#3 lore raw

Applied "ASoC: ak4458: rstn_control - return a non-zero on error only" to the asoc tree

In reply to Viorel Suman

The patch

ASoC: ak4458: rstn_control - return a non-zero on error only

has been applied to the asoc tree at

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

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

Quoted 1 line

From 176a11834b65ec35e3b7a953f87fb9cc41309497 Mon Sep 17 00:00:00 2001

From: Viorel Suman <[email protected]>
Date: Mon, 13 May 2019 10:02:42 +0000
Subject: [PATCH] ASoC: ak4458: rstn_control - return a non-zero on error only

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.

---
 sound/soc/codecs/ak4458.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
sound/soc/codecs/ak4458.c +4 -1
index 4c5c3ec92609..71562154c0b1 100644
@@ -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,
Signature · 1 line
2.20.1
#4 lore raw

PATCH v2 2/2 ASoC: ak4458: add return value for ak4458_probe

In reply to 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.

---
 sound/soc/codecs/ak4458.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
sound/soc/codecs/ak4458.c +7 -6
index baf990a..7156215 100644
@@ -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)
Signature · 1 line
2.7.4
Reviewed-by on v2 2/2
#5 lore raw

Re: [alsa-devel] [PATCH V2 2/2] ASoC: ak4458: add return value for ak4458_probe

Quoted 7 lines · 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.

Quoted 54 lines
---
 sound/soc/codecs/ak4458.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
sound/soc/codecs/ak4458.c +7 -7
index baf990a..7156215 100644
@@ -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
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel