Skip to contentSkip to conversation

ASoC: cs42l52: Catch no-match case in cs42l52_get_clk

PATCH Applied Axel Lin 3 participants 3 messages Dec 20, 2012 – Dec 24, 2012

Subsystems (3)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 ASoC: cs42l52: Catch no-match case in cs42l52_get_clk

In the case of no-match, return -EINVAL instead of 0.

Since we assign i to ret in the for loop, ret always less than ARRAY_SIZE(clk_map_table). Thus remove the boundary checking for ret.

---
 sound/soc/codecs/cs42l52.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
sound/soc/codecs/cs42l52.c +1 -3
index 99bb1c6..9811a54 100644
@@ -737,7 +737,7 @@ static const struct cs42l52_clk_para clk_map_table[] = {
 
 static int cs42l52_get_clk(int mclk, int rate)
 {
-	int i, ret = 0;
+	int i, ret = -EINVAL;
 	u_int mclk1, mclk2 = 0;
 
 	for (i = 0; i < ARRAY_SIZE(clk_map_table); i++) {
@@ -749,8 +749,6 @@ static int cs42l52_get_clk(int mclk, int rate)
 			}
 		}
 	}
-	if (ret > ARRAY_SIZE(clk_map_table))
-		return -EINVAL;
 	return ret;
 }
 
Signature · 1 line
1.7.9.5
Applied
#1 lore raw
Quoted 4 lines · Axel Lin

In the case of no-match, return -EINVAL instead of 0.

Since we assign i to ret in the for loop, ret always less than ARRAY_SIZE(clk_map_table). Thus remove the boundary checking for ret.

Applied, thanks.

Acked-by
#2 lore raw
Quoted 7 lines · Mark Brown
Quoted 4 lines · Axel Lin

In the case of no-match, return -EINVAL instead of 0.

Since we assign i to ret in the for loop, ret always less than ARRAY_SIZE(clk_map_table). Thus remove the boundary checking for ret.

Applied, thanks.

Sorry I did not see this new one. Thanks axel. FWIW