Skip to contentSkip to conversation

pinctrl: aspeed: fix regmap error handling

PATCH In review Arnd Bergmann 4 participants 4 messages Sep 9, 2016 – Sep 13, 2016

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 pinctrl: aspeed: fix regmap error handling

The newly added aspeed driver tries to check for a negative return value from a pinctrl function, but stores the intermediate value in a 'bool' variable, which cannot work:

drivers/pinctrl/aspeed/pinctrl-aspeed.c: In function 'aspeed_sig_expr_set':
drivers/pinctrl/aspeed/pinctrl-aspeed.c:192:11: error: comparison of constant '0' with boolean expression is always false [-Werror=bool-compare]

This slightly reworks the logic to use an explicit comparison with zero before assigning to the temporary variable.

---
 drivers/pinctrl/aspeed/pinctrl-aspeed.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/aspeed/pinctrl-aspeed.c +3 -3
index 7d461fc30d3c..0391f9f13f3e 100644
@@ -187,10 +187,10 @@ static bool aspeed_sig_expr_set(const struct aspeed_sig_expr *expr,
 			continue;
 
 		ret = regmap_update_bits(map, desc->reg, desc->mask,
-				pattern << __ffs(desc->mask));
+				pattern << __ffs(desc->mask)) == 0;
 
-		if (ret < 0)
-			return false;
+		if (!ret)
+			return ret;
 	}
 
 	return aspeed_sig_expr_eval(expr, enable, map);
Signature · 1 line
2.9.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 9 lines · Arnd Bergmann

The newly added aspeed driver tries to check for a negative return value from a pinctrl function, but stores the intermediate value in a 'bool' variable, which cannot work:

drivers/pinctrl/aspeed/pinctrl-aspeed.c: In function 'aspeed_sig_expr_set':
drivers/pinctrl/aspeed/pinctrl-aspeed.c:192:11: error: comparison of constant '0' with boolean expression is always false [-Werror=bool-compare]

This slightly reworks the logic to use an explicit comparison with zero before assigning to the temporary variable.

Thanks for finding this Arnd.

Colin also found the issue. Thanks Colin!

I think we should take this version of the fix. Linus, can you put this in your tree please?

Quoted 1 line

Cheers,

Joel

Quoted 25 lines
---
 drivers/pinctrl/aspeed/pinctrl-aspeed.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/aspeed/pinctrl-aspeed.c +3 -4
index 7d461fc30d3c..0391f9f13f3e 100644
@@ -187,10 +187,10 @@ static bool aspeed_sig_expr_set(const struct aspeed_sig_expr *expr,
                        continue;
 
                ret = regmap_update_bits(map, desc->reg, desc->mask,
-                               pattern << __ffs(desc->mask));
+                               pattern << __ffs(desc->mask)) == 0;
 
-               if (ret < 0)
-                       return false;
+               if (!ret)
+                       return ret;
        }
 
        return aspeed_sig_expr_eval(expr, enable, map);
--

2.9.0

Reviewed-by
#2 lore raw
Quoted 9 lines · Joel Stanley
Quoted 8 lines · Arnd Bergmann

The newly added aspeed driver tries to check for a negative return value from a pinctrl function, but stores the intermediate value in a 'bool' variable, which cannot work:

drivers/pinctrl/aspeed/pinctrl-aspeed.c: In function 'aspeed_sig_expr_set':
drivers/pinctrl/aspeed/pinctrl-aspeed.c:192:11: error: comparison of constant '0' with boolean expression is always false [-Werror=bool-compare]

Quoted 8 lines
Quoted 2 lines

This slightly reworks the logic to use an explicit comparison with zero before assigning to the temporary variable.

Thanks for finding this Arnd.

Colin also found the issue. Thanks Colin!

I think we should take this version of the fix. Linus, can you put this in your tree please?

+1 on each point above.

I made a change to the loop body in response to feedback in one of the earlier iterations and unfortunately this looks to have slipped past me. I will look at adding a bit more static analysis to my patch submission checklist!

Quoted 4 lines
Quoted 3 lines
Quoted 31 lines

Cheers,

Joel

Quoted 26 lines

---
 drivers/pinctrl/aspeed/pinctrl-aspeed.c | 6 +++---

 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/pinctrl/aspeed/pinctrl-aspeed.c +3 -4
index 7d461fc30d3c..0391f9f13f3e 100644
@@ -187,10 +187,10 @@ static bool aspeed_sig_expr_set(const struct aspeed_sig_expr *expr,
                         continue;
 
                 ret = regmap_update_bits(map, desc->reg, desc->mask,
-                               pattern << __ffs(desc->mask));
+                               pattern << __ffs(desc->mask)) == 0;
 
-               if (ret < 0)
-                       return false;
+               if (!ret)
+                       return ret;
         }
 
         return aspeed_sig_expr_eval(expr, enable, map);
--

2.9.0

#3 lore raw
In reply to Arnd Bergmann
Quoted 11 lines · Arnd Bergmann

The newly added aspeed driver tries to check for a negative return value from a pinctrl function, but stores the intermediate value in a 'bool' variable, which cannot work:

drivers/pinctrl/aspeed/pinctrl-aspeed.c: In function 'aspeed_sig_expr_set':
drivers/pinctrl/aspeed/pinctrl-aspeed.c:192:11: error: comparison of constant '0' with boolean expression is always false [-Werror=bool-compare]

This slightly reworks the logic to use an explicit comparison with zero before assigning to the temporary variable.

Patch applied with the ACKs.
Also added Colin as Reported-by.

Yours,
Linus Walleij