pinctrl: aspeed: fix regmap error handling
Subsystems (4)
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
@@ -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
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
Signed-off-by Arnd Bergmann <[email protected]>
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@@ -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
Andrew Jeffery
Reviewed-byQuoted 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
Signed-off-by Arnd Bergmann <[email protected]>Acked-by Joel Stanley <[email protected]>
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@@ -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
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.
Signed-off-by Arnd Bergmann <[email protected]>
Patch applied with the ACKs.
Also added Colin as Reported-by.
Yours,
Linus Walleij