aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Ujfalusi <peter.ujfalusi@nokia.com>2010-11-30 09:00:00 -0500
committerLiam Girdwood <lrg@slimlogic.co.uk>2010-11-30 10:39:39 -0500
commitd5876ce1242b78987e6243ba3cb23bb61d44d4a9 (patch)
tree088002cb822eff36c791f67a1982b65e272021f2
parent3e202345abc2cea09a3601df527629102f37e563 (diff)
ASoC: tpa6130a2: Simplify power state management
Use simpler way to avoid setting the same power state for the amplifier. Simplifies the check introduced by patch: ASoC: tpa6130a2: Fix unbalanced regulator disables Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com> Cc: Jarkko Nikula <jhnikula@gmail.com> Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
-rw-r--r--sound/soc/codecs/tpa6130a2.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c
index 9d61a1d6fce0..199edf07f47e 100644
--- a/sound/soc/codecs/tpa6130a2.c
+++ b/sound/soc/codecs/tpa6130a2.c
@@ -41,7 +41,7 @@ struct tpa6130a2_data {
41 unsigned char regs[TPA6130A2_CACHEREGNUM]; 41 unsigned char regs[TPA6130A2_CACHEREGNUM];
42 struct regulator *supply; 42 struct regulator *supply;
43 int power_gpio; 43 int power_gpio;
44 unsigned char power_state; 44 u8 power_state:1;
45 enum tpa_model id; 45 enum tpa_model id;
46}; 46};
47 47
@@ -116,7 +116,7 @@ static int tpa6130a2_initialize(void)
116 return ret; 116 return ret;
117} 117}
118 118
119static int tpa6130a2_power(int power) 119static int tpa6130a2_power(u8 power)
120{ 120{
121 struct tpa6130a2_data *data; 121 struct tpa6130a2_data *data;
122 u8 val; 122 u8 val;
@@ -126,8 +126,10 @@ static int tpa6130a2_power(int power)
126 data = i2c_get_clientdata(tpa6130a2_client); 126 data = i2c_get_clientdata(tpa6130a2_client);
127 127
128 mutex_lock(&data->mutex); 128 mutex_lock(&data->mutex);
129 if (power && !data->power_state) { 129 if (power == data->power_state)
130 goto exit;
130 131
132 if (power) {
131 ret = regulator_enable(data->supply); 133 ret = regulator_enable(data->supply);
132 if (ret != 0) { 134 if (ret != 0) {
133 dev_err(&tpa6130a2_client->dev, 135 dev_err(&tpa6130a2_client->dev,
@@ -154,7 +156,7 @@ static int tpa6130a2_power(int power)
154 val = tpa6130a2_read(TPA6130A2_REG_CONTROL); 156 val = tpa6130a2_read(TPA6130A2_REG_CONTROL);
155 val &= ~TPA6130A2_SWS; 157 val &= ~TPA6130A2_SWS;
156 tpa6130a2_i2c_write(TPA6130A2_REG_CONTROL, val); 158 tpa6130a2_i2c_write(TPA6130A2_REG_CONTROL, val);
157 } else if (!power && data->power_state) { 159 } else {
158 /* set SWS */ 160 /* set SWS */
159 val = tpa6130a2_read(TPA6130A2_REG_CONTROL); 161 val = tpa6130a2_read(TPA6130A2_REG_CONTROL);
160 val |= TPA6130A2_SWS; 162 val |= TPA6130A2_SWS;