diff options
author | Peter Ujfalusi <peter.ujfalusi@nokia.com> | 2010-10-21 08:03:03 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-10-21 17:06:53 -0400 |
commit | 872a64d7e73f0e4dc435295da393db25332172b8 (patch) | |
tree | 426e9bf41fabbd57241a71dad8664af4bd658066 /sound/soc/codecs/tpa6130a2.c | |
parent | cf4bb69884c8f6a5791e0e251f0b9dc5d32fc256 (diff) |
ASoC: tpa6130a2: Error handling for broken chip
Correct/Implement handling of broken chip.
Fail the i2c_prope if the communication with the chip
fails.
Signed-off-by: Peter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: Liam Girdwood <lrg@slimlogic.co.uk>
Diffstat (limited to 'sound/soc/codecs/tpa6130a2.c')
-rw-r--r-- | sound/soc/codecs/tpa6130a2.c | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/sound/soc/codecs/tpa6130a2.c b/sound/soc/codecs/tpa6130a2.c index 99b70e5978a2..329acc1a2074 100644 --- a/sound/soc/codecs/tpa6130a2.c +++ b/sound/soc/codecs/tpa6130a2.c | |||
@@ -98,16 +98,21 @@ static u8 tpa6130a2_read(int reg) | |||
98 | return data->regs[reg]; | 98 | return data->regs[reg]; |
99 | } | 99 | } |
100 | 100 | ||
101 | static void tpa6130a2_initialize(void) | 101 | static int tpa6130a2_initialize(void) |
102 | { | 102 | { |
103 | struct tpa6130a2_data *data; | 103 | struct tpa6130a2_data *data; |
104 | int i; | 104 | int i, ret = 0; |
105 | 105 | ||
106 | BUG_ON(tpa6130a2_client == NULL); | 106 | BUG_ON(tpa6130a2_client == NULL); |
107 | data = i2c_get_clientdata(tpa6130a2_client); | 107 | data = i2c_get_clientdata(tpa6130a2_client); |
108 | 108 | ||
109 | for (i = 1; i < TPA6130A2_REG_VERSION; i++) | 109 | for (i = 1; i < TPA6130A2_REG_VERSION; i++) { |
110 | tpa6130a2_i2c_write(i, data->regs[i]); | 110 | ret = tpa6130a2_i2c_write(i, data->regs[i]); |
111 | if (ret < 0) | ||
112 | break; | ||
113 | } | ||
114 | |||
115 | return ret; | ||
111 | } | 116 | } |
112 | 117 | ||
113 | static int tpa6130a2_power(int power) | 118 | static int tpa6130a2_power(int power) |
@@ -133,7 +138,16 @@ static int tpa6130a2_power(int power) | |||
133 | } | 138 | } |
134 | 139 | ||
135 | data->power_state = 1; | 140 | data->power_state = 1; |
136 | tpa6130a2_initialize(); | 141 | ret = tpa6130a2_initialize(); |
142 | if (ret < 0) { | ||
143 | dev_err(&tpa6130a2_client->dev, | ||
144 | "Failed to initialize chip\n"); | ||
145 | if (data->power_gpio >= 0) | ||
146 | gpio_set_value(data->power_gpio, 0); | ||
147 | regulator_disable(data->supply); | ||
148 | data->power_state = 0; | ||
149 | goto exit; | ||
150 | } | ||
137 | 151 | ||
138 | /* Clear SWS */ | 152 | /* Clear SWS */ |
139 | val = tpa6130a2_read(TPA6130A2_REG_CONTROL); | 153 | val = tpa6130a2_read(TPA6130A2_REG_CONTROL); |
@@ -375,7 +389,9 @@ int tpa6130a2_add_controls(struct snd_soc_codec *codec) | |||
375 | { | 389 | { |
376 | struct tpa6130a2_data *data; | 390 | struct tpa6130a2_data *data; |
377 | 391 | ||
378 | BUG_ON(tpa6130a2_client == NULL); | 392 | if (tpa6130a2_client == NULL) |
393 | return -ENODEV; | ||
394 | |||
379 | data = i2c_get_clientdata(tpa6130a2_client); | 395 | data = i2c_get_clientdata(tpa6130a2_client); |
380 | 396 | ||
381 | snd_soc_dapm_new_controls(codec, tpa6130a2_dapm_widgets, | 397 | snd_soc_dapm_new_controls(codec, tpa6130a2_dapm_widgets, |