diff mbox

ASoC: fsl_sai: Fix incorrect condition check in trigger()

Message ID 1397225400-2769-1-git-send-email-Guangyu.Chen@freescale.com (mailing list archive)
State Accepted
Commit f84526cfae46672308a361333c76b724384b61ee
Headers show

Commit Message

Nicolin Chen April 11, 2014, 2:10 p.m. UTC
Patch ASoC: fsl_sai: Fix buggy configurations in trigger() doesn't entirely
fix the condition: FRDE of the current substream direction is being cleared
while the code is still using the non-updated one.

Thus this patch fixes this issue by checking the opposite one's FRDE alone
since the current one's is absolutely disabled.

Signed-off-by: Nicolin Chen <Guangyu.Chen@freescale.com>
---
 sound/soc/fsl/fsl_sai.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Mark Brown April 14, 2014, 8:31 p.m. UTC | #1
On Fri, Apr 11, 2014 at 10:10:00PM +0800, Nicolin Chen wrote:

> +		/* Check if the opposite FRDE is also disabled */
> +		if (!(tx ? rcsr & FSL_SAI_CSR_FRDE : tcsr & FSL_SAI_CSR_FRDE)) {

I've applied this since it's a fix but this is *not* a triumph of
legibility, the ternery operator is often not helpful.
Nicolin Chen April 15, 2014, 2:33 a.m. UTC | #2
On Mon, Apr 14, 2014 at 09:31:26PM +0100, Mark Brown wrote:
> On Fri, Apr 11, 2014 at 10:10:00PM +0800, Nicolin Chen wrote:
> 
> > +		/* Check if the opposite FRDE is also disabled */
> > +		if (!(tx ? rcsr & FSL_SAI_CSR_FRDE : tcsr & FSL_SAI_CSR_FRDE)) {
> 
> I've applied this since it's a fix but this is *not* a triumph of
> legibility, the ternery operator is often not helpful.

It looks like I've got a bad habit again. I'll be careful next time.

Thank you for reminding me,
Nicolin
diff mbox

Patch

diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c
index 9858d42..1716a41 100644
--- a/sound/soc/fsl/fsl_sai.c
+++ b/sound/soc/fsl/fsl_sai.c
@@ -343,7 +343,8 @@  static int fsl_sai_trigger(struct snd_pcm_substream *substream, int cmd,
 		regmap_update_bits(sai->regmap, FSL_SAI_xCSR(tx),
 				   FSL_SAI_CSR_xIE_MASK, 0);
 
-		if (!(tcsr & FSL_SAI_CSR_FRDE || rcsr & FSL_SAI_CSR_FRDE)) {
+		/* Check if the opposite FRDE is also disabled */
+		if (!(tx ? rcsr & FSL_SAI_CSR_FRDE : tcsr & FSL_SAI_CSR_FRDE)) {
 			regmap_update_bits(sai->regmap, FSL_SAI_TCSR,
 					   FSL_SAI_CSR_TERE, 0);
 			regmap_update_bits(sai->regmap, FSL_SAI_RCSR,