regmap: avoid -Wint-in-bool-context warning
authorArnd Bergmann <arnd@arndb.de>
Fri, 13 Oct 2017 12:12:45 +0000 (14:12 +0200)
committerMark Brown <broonie@kernel.org>
Fri, 13 Oct 2017 17:22:11 +0000 (18:22 +0100)
commit1b0c22e45508ffbd645430e049c52c46bdaad3b4
treeb77ac429a1c53c3557e205f51660377d60aa5200
parent89d5788315f10aece086376b3f5e592afd3dbd29
regmap: avoid -Wint-in-bool-context warning

When we pass the result of a multiplication as the timeout or the delay,
we can get a warning from gcc-7:

drivers/mmc/host/bcm2835.c:596:149: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
drivers/mfd/arizona-core.c:247:195: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]
drivers/gpu/drm/sun4i/sun4i_hdmi_i2c.c:49:27: error: '*' in boolean context, suggest '&&' instead [-Werror=int-in-bool-context]

The warning is a bit questionable inside of a macro, but this is
intentional on the side of the gcc developers.  It is also an indication
of another problem: we evaluate the timeout and sleep arguments multiple
times, which can have undesired side-effects when those are complex
expressions.

This changes the two regmap variants to use local variables for storing
copies of the timeouts.  This adds some more type safety, and avoids both
the double-evaluation and the gcc warning.

Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=81484
Link: http://lkml.kernel.org/r/20170726133756.2161367-1-arnd@arndb.de
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Mark Brown <broonie@kernel.org>
include/linux/regmap.h