提交 a3b55791 编写于 作者: P Peter Ujfalusi 提交者: Liam Girdwood

ASoC: tlv320dac33: Fix inconsistent spinlock usage

The lock is used within the interrupt handler.
Correct the spinlock usage, and use irqsave/irqrestore
flavour of spin_lock/unlock.
Signed-off-by: NPeter Ujfalusi <peter.ujfalusi@nokia.com>
Acked-by: NMark Brown <broonie@opensource.wolfsonmicro.com>
Signed-off-by: NLiam Girdwood <lrg@slimlogic.co.uk>
上级 fa4d1f59
...@@ -670,6 +670,7 @@ static inline void dac33_prefill_handler(struct tlv320dac33_priv *dac33) ...@@ -670,6 +670,7 @@ static inline void dac33_prefill_handler(struct tlv320dac33_priv *dac33)
{ {
struct snd_soc_codec *codec = dac33->codec; struct snd_soc_codec *codec = dac33->codec;
unsigned int delay; unsigned int delay;
unsigned long flags;
switch (dac33->fifo_mode) { switch (dac33->fifo_mode) {
case DAC33_FIFO_MODE1: case DAC33_FIFO_MODE1:
...@@ -677,10 +678,10 @@ static inline void dac33_prefill_handler(struct tlv320dac33_priv *dac33) ...@@ -677,10 +678,10 @@ static inline void dac33_prefill_handler(struct tlv320dac33_priv *dac33)
DAC33_THRREG(dac33->nsample)); DAC33_THRREG(dac33->nsample));
/* Take the timestamps */ /* Take the timestamps */
spin_lock_irq(&dac33->lock); spin_lock_irqsave(&dac33->lock, flags);
dac33->t_stamp2 = ktime_to_us(ktime_get()); dac33->t_stamp2 = ktime_to_us(ktime_get());
dac33->t_stamp1 = dac33->t_stamp2; dac33->t_stamp1 = dac33->t_stamp2;
spin_unlock_irq(&dac33->lock); spin_unlock_irqrestore(&dac33->lock, flags);
dac33_write16(codec, DAC33_PREFILL_MSB, dac33_write16(codec, DAC33_PREFILL_MSB,
DAC33_THRREG(dac33->alarm_threshold)); DAC33_THRREG(dac33->alarm_threshold));
...@@ -692,11 +693,11 @@ static inline void dac33_prefill_handler(struct tlv320dac33_priv *dac33) ...@@ -692,11 +693,11 @@ static inline void dac33_prefill_handler(struct tlv320dac33_priv *dac33)
break; break;
case DAC33_FIFO_MODE7: case DAC33_FIFO_MODE7:
/* Take the timestamp */ /* Take the timestamp */
spin_lock_irq(&dac33->lock); spin_lock_irqsave(&dac33->lock, flags);
dac33->t_stamp1 = ktime_to_us(ktime_get()); dac33->t_stamp1 = ktime_to_us(ktime_get());
/* Move back the timestamp with drain time */ /* Move back the timestamp with drain time */
dac33->t_stamp1 -= dac33->mode7_us_to_lthr; dac33->t_stamp1 -= dac33->mode7_us_to_lthr;
spin_unlock_irq(&dac33->lock); spin_unlock_irqrestore(&dac33->lock, flags);
dac33_write16(codec, DAC33_PREFILL_MSB, dac33_write16(codec, DAC33_PREFILL_MSB,
DAC33_THRREG(DAC33_MODE7_MARGIN)); DAC33_THRREG(DAC33_MODE7_MARGIN));
...@@ -714,13 +715,14 @@ static inline void dac33_prefill_handler(struct tlv320dac33_priv *dac33) ...@@ -714,13 +715,14 @@ static inline void dac33_prefill_handler(struct tlv320dac33_priv *dac33)
static inline void dac33_playback_handler(struct tlv320dac33_priv *dac33) static inline void dac33_playback_handler(struct tlv320dac33_priv *dac33)
{ {
struct snd_soc_codec *codec = dac33->codec; struct snd_soc_codec *codec = dac33->codec;
unsigned long flags;
switch (dac33->fifo_mode) { switch (dac33->fifo_mode) {
case DAC33_FIFO_MODE1: case DAC33_FIFO_MODE1:
/* Take the timestamp */ /* Take the timestamp */
spin_lock_irq(&dac33->lock); spin_lock_irqsave(&dac33->lock, flags);
dac33->t_stamp2 = ktime_to_us(ktime_get()); dac33->t_stamp2 = ktime_to_us(ktime_get());
spin_unlock_irq(&dac33->lock); spin_unlock_irqrestore(&dac33->lock, flags);
dac33_write16(codec, DAC33_NSAMPLE_MSB, dac33_write16(codec, DAC33_NSAMPLE_MSB,
DAC33_THRREG(dac33->nsample)); DAC33_THRREG(dac33->nsample));
...@@ -773,10 +775,11 @@ static irqreturn_t dac33_interrupt_handler(int irq, void *dev) ...@@ -773,10 +775,11 @@ static irqreturn_t dac33_interrupt_handler(int irq, void *dev)
{ {
struct snd_soc_codec *codec = dev; struct snd_soc_codec *codec = dev;
struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec); struct tlv320dac33_priv *dac33 = snd_soc_codec_get_drvdata(codec);
unsigned long flags;
spin_lock(&dac33->lock); spin_lock_irqsave(&dac33->lock, flags);
dac33->t_stamp1 = ktime_to_us(ktime_get()); dac33->t_stamp1 = ktime_to_us(ktime_get());
spin_unlock(&dac33->lock); spin_unlock_irqrestore(&dac33->lock, flags);
/* Do not schedule the workqueue in Mode7 */ /* Do not schedule the workqueue in Mode7 */
if (dac33->fifo_mode != DAC33_FIFO_MODE7) if (dac33->fifo_mode != DAC33_FIFO_MODE7)
...@@ -1173,15 +1176,16 @@ static snd_pcm_sframes_t dac33_dai_delay( ...@@ -1173,15 +1176,16 @@ static snd_pcm_sframes_t dac33_dai_delay(
unsigned int time_delta, uthr; unsigned int time_delta, uthr;
int samples_out, samples_in, samples; int samples_out, samples_in, samples;
snd_pcm_sframes_t delay = 0; snd_pcm_sframes_t delay = 0;
unsigned long flags;
switch (dac33->fifo_mode) { switch (dac33->fifo_mode) {
case DAC33_FIFO_BYPASS: case DAC33_FIFO_BYPASS:
break; break;
case DAC33_FIFO_MODE1: case DAC33_FIFO_MODE1:
spin_lock(&dac33->lock); spin_lock_irqsave(&dac33->lock, flags);
t0 = dac33->t_stamp1; t0 = dac33->t_stamp1;
t1 = dac33->t_stamp2; t1 = dac33->t_stamp2;
spin_unlock(&dac33->lock); spin_unlock_irqrestore(&dac33->lock, flags);
t_now = ktime_to_us(ktime_get()); t_now = ktime_to_us(ktime_get());
/* We have not started to fill the FIFO yet, delay is 0 */ /* We have not started to fill the FIFO yet, delay is 0 */
...@@ -1246,10 +1250,10 @@ static snd_pcm_sframes_t dac33_dai_delay( ...@@ -1246,10 +1250,10 @@ static snd_pcm_sframes_t dac33_dai_delay(
} }
break; break;
case DAC33_FIFO_MODE7: case DAC33_FIFO_MODE7:
spin_lock(&dac33->lock); spin_lock_irqsave(&dac33->lock, flags);
t0 = dac33->t_stamp1; t0 = dac33->t_stamp1;
uthr = dac33->uthr; uthr = dac33->uthr;
spin_unlock(&dac33->lock); spin_unlock_irqrestore(&dac33->lock, flags);
t_now = ktime_to_us(ktime_get()); t_now = ktime_to_us(ktime_get());
/* We have not started to fill the FIFO yet, delay is 0 */ /* We have not started to fill the FIFO yet, delay is 0 */
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册