diff options
author | Peter Ujfalusi <peter.ujfalusi@nokia.com> | 2010-10-26 04:45:59 -0400 |
---|---|---|
committer | Liam Girdwood <lrg@slimlogic.co.uk> | 2010-10-30 12:33:38 -0400 |
commit | 911a0f0bfc01750590e8ac6e7f9f4921f470b0d1 (patch) | |
tree | 79bf7b5fd9a13d706533ce23b9243d52670028b3 /sound | |
parent | 84eae18c867fcb7ce43d5830e23377ed33e45df9 (diff) |
ASoC: tlv320dac33: Error handling for broken chip
Correct/Implement handling of broken chip.
Fail the soc_prope if the communication with the chip
fails (can not read chip ID).
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')
-rw-r--r-- | sound/soc/codecs/tlv320dac33.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/sound/soc/codecs/tlv320dac33.c b/sound/soc/codecs/tlv320dac33.c index d251ff54a2d3..fed14582b498 100644 --- a/sound/soc/codecs/tlv320dac33.c +++ b/sound/soc/codecs/tlv320dac33.c | |||
@@ -200,7 +200,7 @@ static int dac33_read(struct snd_soc_codec *codec, unsigned int reg, | |||
200 | u8 *value) | 200 | u8 *value) |
201 | { | 201 | { |
202 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); | 202 | struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); |
203 | int val; | 203 | int val, ret = 0; |
204 | 204 | ||
205 | *value = reg & 0xff; | 205 | *value = reg & 0xff; |
206 | 206 | ||
@@ -210,6 +210,7 @@ static int dac33_read(struct snd_soc_codec *codec, unsigned int reg, | |||
210 | if (val < 0) { | 210 | if (val < 0) { |
211 | dev_err(codec->dev, "Read failed (%d)\n", val); | 211 | dev_err(codec->dev, "Read failed (%d)\n", val); |
212 | value[0] = dac33_read_reg_cache(codec, reg); | 212 | value[0] = dac33_read_reg_cache(codec, reg); |
213 | ret = val; | ||
213 | } else { | 214 | } else { |
214 | value[0] = val; | 215 | value[0] = val; |
215 | dac33_write_reg_cache(codec, reg, val); | 216 | dac33_write_reg_cache(codec, reg, val); |
@@ -218,7 +219,7 @@ static int dac33_read(struct snd_soc_codec *codec, unsigned int reg, | |||
218 | value[0] = dac33_read_reg_cache(codec, reg); | 219 | value[0] = dac33_read_reg_cache(codec, reg); |
219 | } | 220 | } |
220 | 221 | ||
221 | return 0; | 222 | return ret; |
222 | } | 223 | } |
223 | 224 | ||
224 | static int dac33_write(struct snd_soc_codec *codec, unsigned int reg, | 225 | static int dac33_write(struct snd_soc_codec *codec, unsigned int reg, |
@@ -329,13 +330,18 @@ static void dac33_init_chip(struct snd_soc_codec *codec) | |||
329 | dac33_read_reg_cache(codec, DAC33_LINER_TO_RLO_VOL)); | 330 | dac33_read_reg_cache(codec, DAC33_LINER_TO_RLO_VOL)); |
330 | } | 331 | } |
331 | 332 | ||
332 | static inline void dac33_read_id(struct snd_soc_codec *codec) | 333 | static inline int dac33_read_id(struct snd_soc_codec *codec) |
333 | { | 334 | { |
335 | int i, ret = 0; | ||
334 | u8 reg; | 336 | u8 reg; |
335 | 337 | ||
336 | dac33_read(codec, DAC33_DEVICE_ID_MSB, ®); | 338 | for (i = 0; i < 3; i++) { |
337 | dac33_read(codec, DAC33_DEVICE_ID_LSB, ®); | 339 | ret = dac33_read(codec, DAC33_DEVICE_ID_MSB + i, ®); |
338 | dac33_read(codec, DAC33_DEVICE_REV_ID, ®); | 340 | if (ret < 0) |
341 | break; | ||
342 | } | ||
343 | |||
344 | return ret; | ||
339 | } | 345 | } |
340 | 346 | ||
341 | static inline void dac33_soft_power(struct snd_soc_codec *codec, int power) | 347 | static inline void dac33_soft_power(struct snd_soc_codec *codec, int power) |
@@ -1414,9 +1420,15 @@ static int dac33_soc_probe(struct snd_soc_codec *codec) | |||
1414 | dev_err(codec->dev, "Failed to power up codec: %d\n", ret); | 1420 | dev_err(codec->dev, "Failed to power up codec: %d\n", ret); |
1415 | goto err_power; | 1421 | goto err_power; |
1416 | } | 1422 | } |
1417 | dac33_read_id(codec); | 1423 | ret = dac33_read_id(codec); |
1418 | dac33_hard_power(codec, 0); | 1424 | dac33_hard_power(codec, 0); |
1419 | 1425 | ||
1426 | if (ret < 0) { | ||
1427 | dev_err(codec->dev, "Failed to read chip ID: %d\n", ret); | ||
1428 | ret = -ENODEV; | ||
1429 | goto err_power; | ||
1430 | } | ||
1431 | |||
1420 | /* Check if the IRQ number is valid and request it */ | 1432 | /* Check if the IRQ number is valid and request it */ |
1421 | if (dac33->irq >= 0) { | 1433 | if (dac33->irq >= 0) { |
1422 | ret = request_irq(dac33->irq, dac33_interrupt_handler, | 1434 | ret = request_irq(dac33->irq, dac33_interrupt_handler, |