[PATCH] ASoC: stm32: sai: Fix unsigned comparison with less than zero
From: Wen Yang
Date: Wed Nov 28 2018 - 21:07:05 EST
The return from the call to stm32_sai_get_clk_div can be a negative error
code however this is being assigned to an unsigned variable 'div'
hence the check is always false. Fix this by making 'div' an
int.
Detected by Coccinelle ("Unsigned expression compared with zero:stages
< 0")
Signed-off-by: Wen Yang <wen.yang99@xxxxxxxxxx>
CC: Mark Brown <broonie@xxxxxxxxxx>
CC: Olivier Moysan <olivier.moysan@xxxxxx>
CC: Arnaud Pouliquen <arnaud.pouliquen@xxxxxx>
CC: Liam Girdwood <lgirdwood@xxxxxxxxx>
CC: Jaroslav Kysela <perex@xxxxxxxx>
CC: Takashi Iwai <tiwai@xxxxxxxx>
CC: Maxime Coquelin <mcoquelin.stm32@xxxxxxxxx>
CC: Alexandre Torgue <alexandre.torgue@xxxxxx>
CC: Julia Lawall <julia.lawall@xxxxxxx>
CC: Wen Yang <yellowriver2010@xxxxxxxxxxx>
CC: linux-stm32@xxxxxxxxxxxxxxxxxxxxxxxxxxxx
CC: linux-kernel@xxxxxxxxxxxxxxx
---
sound/soc/stm/stm32_sai_sub.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
index 211589b0b2ef..6e9fff0f9ed7 100644
--- a/sound/soc/stm/stm32_sai_sub.c
+++ b/sound/soc/stm/stm32_sai_sub.c
@@ -336,7 +336,7 @@ static int stm32_sai_mclk_set_rate(struct clk_hw *hw, unsigned long rate,
{
struct stm32_sai_mclk_data *mclk = to_mclk_data(hw);
struct stm32_sai_sub_data *sai = mclk->sai_data;
- unsigned int div;
+ int div;
int ret;
div = stm32_sai_get_clk_div(sai, parent_rate, rate);
--
2.19.1