Skip to contentSkip to conversation

ASoC: tpa6130a2: Fix unbalanced regulator disables

PATCH Applied Jarkko Nikula 5 participants 8 messages Oct 28, 2010 – Nov 3, 2010

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

PATCH 1/1 ASoC: tpa6130a2: Fix unbalanced regulator disables

This driver has unbalanced regulator_disable when doing module loading and unloading. This is because tpa6130a2_probe followed by tpa6130a2_remove calls twice tpa6130a2_power(0). Fix this by implementing a state checking in tpa6130a2_power.

---
 sound/soc/codecs/tpa6130a2.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/tpa6130a2.c +2 -2
index 329acc1..83b5631 100644
@@ -125,7 +125,7 @@ static int tpa6130a2_power(int power)
 	data = i2c_get_clientdata(tpa6130a2_client);
 
 	mutex_lock(&data->mutex);
-	if (power) {
+	if (power && !data->power_state) {
 		/* Power on */
 		if (data->power_gpio >= 0)
 			gpio_set_value(data->power_gpio, 1);
@@ -153,7 +153,7 @@ static int tpa6130a2_power(int power)
 		val = tpa6130a2_read(TPA6130A2_REG_CONTROL);
 		val &= ~TPA6130A2_SWS;
 		tpa6130a2_i2c_write(TPA6130A2_REG_CONTROL, val);
-	} else {
+	} else if (!power && data->power_state) {
 		/* set SWS */
 		val = tpa6130a2_read(TPA6130A2_REG_CONTROL);
 		val |= TPA6130A2_SWS;
Signature · 1 line
1.7.1
Acked-by on v1 1/1
#1 lore raw
Quoted 4 lines · On Thursday 28 October 2010 14:05:40 ext Jarkko Nikula wrote:

This driver has unbalanced regulator_disable when doing module loading and unloading. This is because tpa6130a2_probe followed by tpa6130a2_remove calls twice tpa6130a2_power(0). Fix this by implementing a state checking in tpa6130a2_power.

#3 lore raw
Quoted 10 lines · Mark Brown
Quoted 7 lines · Jarkko Nikula

This driver has unbalanced regulator_disable when doing module loading and unloading. This is because tpa6130a2_probe followed by tpa6130a2_remove calls twice tpa6130a2_power(0). Fix this by implementing a state checking in tpa6130a2_power.

Applied.

Thanks

Liam

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk
#4 lore raw
In reply to Jarkko Nikula

At Thu, 28 Oct 2010 14:05:40 +0300,

Quoted 26 lines · Jarkko Nikula

This driver has unbalanced regulator_disable when doing module loading and unloading. This is because tpa6130a2_probe followed by tpa6130a2_remove calls twice tpa6130a2_power(0). Fix this by implementing a state checking in tpa6130a2_power.

---
 sound/soc/codecs/tpa6130a2.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
sound/soc/codecs/tpa6130a2.c +1 -1
index 329acc1..83b5631 100644
@@ -125,7 +125,7 @@ static int tpa6130a2_power(int power)
 	data = i2c_get_clientdata(tpa6130a2_client);
 
 	mutex_lock(&data->mutex);
-	if (power) {
+	if (power && !data->power_state) {
 		/* Power on */
 		if (data->power_gpio >= 0)
 			gpio_set_value(data->power_gpio, 1);

sound/soc/codecs/tpa6130a2.c static int tpa6130a2_power(int power) · line 159

Quoted 8 lines
sound/soc/codecs/tpa6130a2.c +1 -1
@@ -153,7 +153,7 @@ static int tpa6130a2_power(int power)
 		val = tpa6130a2_read(TPA6130A2_REG_CONTROL);
 		val &= ~TPA6130A2_SWS;
 		tpa6130a2_i2c_write(TPA6130A2_REG_CONTROL, val);
-	} else {
+	} else if (!power && data->power_state) {
 		/* set SWS */
 		val = tpa6130a2_read(TPA6130A2_REG_CONTROL);
 		val |= TPA6130A2_SWS;

This seems triggering a compile warning:

sound/soc/codecs/tpa6130a2.c:122:6: warning: ‘ret’ may be used uninitialized in this function

Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel

#5 lore raw
Quoted 4 lines · On Wed, 03 Nov 2010 15:00:12 +0100 Takashi Iwai <[email protected]> wrote:

This seems triggering a compile warning:

sound/soc/codecs/tpa6130a2.c:122:6: warning: ‘ret’ may be used uninitialized in this function

My shame. I send a patch in a minute.

Signature · 5 lines
Jarkko
_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#6 lore raw

PATCH 1/1 ASoC: tpa6130a2: Get rid of compile warning from tpa6130a2_power

In reply to Takashi Iwai

Patch "ASoC: tpa6130a2: Fix unbalanced regulator disables" introduced a compiler warning "‘ret’ may be used uninitialized in this function". Initialize ret to zero to get rid of it and making sure that the function does not return any random error code when the code is falling through.

---
 sound/soc/codecs/tpa6130a2.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
sound/soc/codecs/tpa6130a2.c +1 -1
index 83b5631..ee4fb20 100644
@@ -119,7 +119,7 @@ static int tpa6130a2_power(int power)
 {
 	struct	tpa6130a2_data *data;
 	u8	val;
-	int	ret;
+	int	ret = 0;
 
 	BUG_ON(tpa6130a2_client == NULL);
 	data = i2c_get_clientdata(tpa6130a2_client);
Signature · 6 lines
1.7.2.3

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel
#7 lore raw

Re: [PATCH] ASoC: tpa6130a2: Get rid of compile warning from tpa6130a2_power

At Wed, 3 Nov 2010 16:39:00 +0200,

Quoted 7 lines · Jarkko Nikula

Patch "ASoC: tpa6130a2: Fix unbalanced regulator disables" introduced a compiler warning "‘ret’ may be used uninitialized in this function". Initialize ret to zero to get rid of it and making sure that the function does not return any random error code when the code is falling through.

Thanks!

Applied now directly to sound git tree as I'm going to send a pull request soon later.

Mark, Liam, please pull back to your trees later on.

Takashi

Quoted 20 lines
---
 sound/soc/codecs/tpa6130a2.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
sound/soc/codecs/tpa6130a2.c +1 -1
index 83b5631..ee4fb20 100644
@@ -119,7 +119,7 @@ static int tpa6130a2_power(int power)
 {
 	struct	tpa6130a2_data *data;
 	u8	val;
-	int	ret;
+	int	ret = 0;
 
 	BUG_ON(tpa6130a2_client == NULL);
 	data = i2c_get_clientdata(tpa6130a2_client);
Signature · 1 line
1.7.2.3

_______________________________________________
Alsa-devel mailing list
[email protected]
http://mailman.alsa-project.org/mailman/listinfo/alsa-devel