diff options
author | Viorel Suman <viorel.suman@nxp.com> | 2018-11-13 11:36:29 +0200 |
---|---|---|
committer | Dong Aisheng <aisheng.dong@nxp.com> | 2019-11-25 15:54:08 +0800 |
commit | 34ef089c731667deb812342b263da8294b6543af (patch) | |
tree | 8a8936e249e789f8996739f746ccb9467d5bdb90 /sound/soc/fsl/fsl_sai.c | |
parent | f2fa8b69e55c0e1eb5beae0a5d766b54d3b486d7 (diff) |
MLK-20189-8: ASoC: fsl_sai: use signed offset variable
Both dataline_off and dataline_off_dsd fields are unsigned,
thus checking negative values make no sense. Use a signed
variable to calculate offset instead.
This fixes Coverity issue: CID1899299
Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
Diffstat (limited to 'sound/soc/fsl/fsl_sai.c')
-rw-r--r-- | sound/soc/fsl/fsl_sai.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/sound/soc/fsl/fsl_sai.c b/sound/soc/fsl/fsl_sai.c index 5614c1baa1cd..eb92e749c354 100644 --- a/sound/soc/fsl/fsl_sai.c +++ b/sound/soc/fsl/fsl_sai.c @@ -1273,7 +1273,7 @@ static int fsl_sai_probe(struct platform_device *pdev) char tmp[8]; int irq, ret, i; int index; - int firstbitidx, nextbitidx; + int firstbitidx, nextbitidx, offset; struct regmap_config fsl_sai_regmap_config = fsl_sai_v2_regmap_config; unsigned long irqflags = 0; @@ -1356,10 +1356,8 @@ static int fsl_sai_probe(struct platform_device *pdev) for (i = 0; i < 2; i++) { firstbitidx = find_first_bit((const unsigned long *)&sai->dataline[i], 8); nextbitidx = find_next_bit((const unsigned long *)&sai->dataline[i], 8, firstbitidx+1); - sai->dataline_off[i] = nextbitidx - firstbitidx - 1; - - if (sai->dataline_off[i] < 0 || sai->dataline_off[i] >= 7) - sai->dataline_off[i] = 0; + offset = nextbitidx - firstbitidx - 1; + sai->dataline_off[i] = (offset < 0 || offset >= 7 ? 0 : offset); } ret = of_property_read_u32_index(np, "fsl,dataline,dsd", 0, &sai->dataline_dsd[0]); @@ -1378,10 +1376,8 @@ static int fsl_sai_probe(struct platform_device *pdev) for (i = 0; i < 2; i++) { firstbitidx = find_first_bit((const unsigned long *)&sai->dataline_dsd[i], 8); nextbitidx = find_next_bit((const unsigned long *)&sai->dataline_dsd[i], 8, firstbitidx+1); - sai->dataline_off_dsd[i] = nextbitidx - firstbitidx - 1; - - if (sai->dataline_off_dsd[i] < 0 || sai->dataline_off_dsd[i] >= 7) - sai->dataline_off_dsd[i] = 0; + offset = nextbitidx - firstbitidx - 1; + sai->dataline_off_dsd[i] = (offset < 0 || offset >= 7 ? 0 : offset); } if ((of_find_property(np, "fsl,i2s-xtor", NULL) != NULL) || |