summaryrefslogtreecommitdiffstats
path: root/arch/arm/mach-pxa/sharpsl_pm.h
diff options
context:
space:
mode:
authorRobert Jarzmik2016-08-02 00:01:32 +0200
committerRobert Jarzmik2016-09-09 18:07:59 +0200
commitca26475bf02ed8562b9b46f91d3e8b52ec312541 (patch)
treec8f99d3ef5a244058d589272fb3e2622a270d8cb /arch/arm/mach-pxa/sharpsl_pm.h
parentarm: trizeps4_defconfig: disable IDE subsystem (diff)
downloadkernel-qcow2-linux-ca26475bf02ed8562b9b46f91d3e8b52ec312541.tar.gz
kernel-qcow2-linux-ca26475bf02ed8562b9b46f91d3e8b52ec312541.tar.xz
kernel-qcow2-linux-ca26475bf02ed8562b9b46f91d3e8b52ec312541.zip
ARM: pxa: fix GPIO double shifts
The commit 9bf448c66d4b ("ARM: pxa: use generic gpio operation instead of gpio register") from Oct 17, 2011, leads to the following static checker warning: arch/arm/mach-pxa/spitz_pm.c:172 spitz_charger_wakeup() warn: double left shift '!gpio_get_value(SPITZ_GPIO_KEY_INT) << (1 << ((SPITZ_GPIO_KEY_INT) & 31))' As Dan reported, the value is shifted three times : - once by gpio_get_value(), which returns either 0 or BIT(gpio) - once by the shift operation '<<' - a last time by GPIO_bit(gpio) which is BIT(gpio) Therefore the calculation lead to a chained or operator of : - (1 << gpio) << (1 << gpio) = (2^gpio)^gpio = 2 ^ (gpio * gpio) It is be sheer luck the former statement works, only because each gpio used is strictly smaller than 6, and therefore 2^(gpio^2) never overflows a 32 bits value, and because it is used as a boolean value to check a gpio activation. As the xxx_charger_wakeup() functions are used as a true/false detection mechanism, take that opportunity to change their prototypes from integer return value to boolean one. Fixes: 9bf448c66d4b ("ARM: pxa: use generic gpio operation instead of gpio register") Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Cc: Joe Perches <joe@perches.com> Signed-off-by: Robert Jarzmik <robert.jarzmik@free.fr>
Diffstat (limited to 'arch/arm/mach-pxa/sharpsl_pm.h')
-rw-r--r--arch/arm/mach-pxa/sharpsl_pm.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/arch/arm/mach-pxa/sharpsl_pm.h b/arch/arm/mach-pxa/sharpsl_pm.h
index 905be6755f04..fa75b6df8134 100644
--- a/arch/arm/mach-pxa/sharpsl_pm.h
+++ b/arch/arm/mach-pxa/sharpsl_pm.h
@@ -34,7 +34,7 @@ struct sharpsl_charger_machinfo {
#define SHARPSL_STATUS_LOCK 5
#define SHARPSL_STATUS_CHRGFULL 6
#define SHARPSL_STATUS_FATAL 7
- unsigned long (*charger_wakeup)(void);
+ bool (*charger_wakeup)(void);
int (*should_wakeup)(unsigned int resume_on_alarm);
void (*backlight_limit)(int);
int (*backlight_get_status) (void);