Skip to contentSkip to conversation

ASoC: tlv320dac33: Limit the US_TO_SAMPLES macro

PATCH In review Peter Ujfalusi 3 participants 3 messages Oct 29, 2010 – Oct 30, 2010

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

PATCH 1/1 ASoC: tlv320dac33: Limit the US_TO_SAMPLES macro

Limit the time window to maximum 1s in the macro. The driver deals with much shorter times (<200ms). This will fix a rare division by zero bug in Mode1. This could happen, when the work is not executed in time (within mode1_latency) after the interrupt. In this case the DAC33 will not receive the needed nSample command in time, and enters to an unknown state, and won't recover.
In such event the time window will increase, and eventually going to be bigger than 1s, resulting devision by zero.

---
 sound/soc/codecs/tlv320dac33.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
sound/soc/codecs/tlv320dac33.c +1 -1
index 6778e2e..c5ab8c8 100644
@@ -58,7 +58,7 @@
 	(1000000000 / ((rate * 1000) / samples))
 
 #define US_TO_SAMPLES(rate, us) \
-	(rate / (1000000 / us))
+	(rate / (1000000 / (us < 1000000 ? us : 1000000)))
 
 #define UTHR_FROM_PERIOD_SIZE(samples, playrate, burstrate) \
 	((samples * 5000) / ((burstrate * 5000) / (burstrate - playrate)))
Signature · 1 line
1.7.3.2
#2 lore raw
Quoted 9 lines · Mark Brown
Quoted 2 lines · Peter Ujfalusi

Limit the time window to maximum 1s in the macro. The driver deals with much shorter times (<200ms).

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

All Peter's fixes applied.

Thanks

Liam

Signature · 3 lines
Freelance Developer, SlimLogic Ltd
ASoC and Voltage Regulator Maintainer.
http://www.slimlogic.co.uk