ath79/mikrotik: use routerbootpart partitions
[oweals/openwrt.git] / target / linux / layerscape / patches-5.4 / 801-audio-0058-MLK-20189-8-ASoC-fsl_sai-use-signed-offset-variable.patch
1 From d8802def525b4f74f66fca02afe9c17a729a3201 Mon Sep 17 00:00:00 2001
2 From: Viorel Suman <viorel.suman@nxp.com>
3 Date: Tue, 13 Nov 2018 11:36:29 +0200
4 Subject: [PATCH] MLK-20189-8: ASoC: fsl_sai: use signed offset variable
5
6 Both dataline_off and dataline_off_dsd fields are unsigned,
7 thus checking negative values make no sense. Use a signed
8 variable to calculate offset instead.
9
10 This fixes Coverity issue: CID1899299
11
12 Signed-off-by: Viorel Suman <viorel.suman@nxp.com>
13 ---
14  sound/soc/fsl/fsl_sai.c | 14 +++++---------
15  1 file changed, 5 insertions(+), 9 deletions(-)
16
17 --- a/sound/soc/fsl/fsl_sai.c
18 +++ b/sound/soc/fsl/fsl_sai.c
19 @@ -1273,7 +1273,7 @@ static int fsl_sai_probe(struct platform
20         char tmp[8];
21         int irq, ret, i;
22         int index;
23 -       int firstbitidx, nextbitidx;
24 +       int firstbitidx, nextbitidx, offset;
25         struct regmap_config fsl_sai_regmap_config = fsl_sai_v2_regmap_config;
26         unsigned long irqflags = 0;
27  
28 @@ -1356,10 +1356,8 @@ static int fsl_sai_probe(struct platform
29         for (i = 0; i < 2; i++) {
30                 firstbitidx = find_first_bit((const unsigned long *)&sai->dataline[i], 8);
31                 nextbitidx = find_next_bit((const unsigned long *)&sai->dataline[i], 8, firstbitidx+1);
32 -               sai->dataline_off[i] = nextbitidx - firstbitidx - 1;
33 -
34 -               if (sai->dataline_off[i] < 0 || sai->dataline_off[i] >= 7)
35 -                       sai->dataline_off[i] = 0;
36 +               offset = nextbitidx - firstbitidx - 1;
37 +               sai->dataline_off[i] = (offset < 0 || offset >= 7 ? 0 : offset);
38         }
39  
40         ret = of_property_read_u32_index(np, "fsl,dataline,dsd", 0, &sai->dataline_dsd[0]);
41 @@ -1378,10 +1376,8 @@ static int fsl_sai_probe(struct platform
42         for (i = 0; i < 2; i++) {
43                 firstbitidx = find_first_bit((const unsigned long *)&sai->dataline_dsd[i], 8);
44                 nextbitidx = find_next_bit((const unsigned long *)&sai->dataline_dsd[i], 8, firstbitidx+1);
45 -               sai->dataline_off_dsd[i] = nextbitidx - firstbitidx - 1;
46 -
47 -               if (sai->dataline_off_dsd[i] < 0 || sai->dataline_off_dsd[i] >= 7)
48 -                       sai->dataline_off_dsd[i] = 0;
49 +               offset = nextbitidx - firstbitidx - 1;
50 +               sai->dataline_off_dsd[i] = (offset < 0 || offset >= 7 ? 0 : offset);
51         }
52  
53         if ((of_find_property(np, "fsl,i2s-xtor", NULL) != NULL) ||