power: gpio-charger: do not use gpio value directly
authorHeiko Stuebner <heiko.stuebner@bq.com>
Tue, 23 Sep 2014 20:42:16 +0000 (22:42 +0200)
committerSebastian Reichel <sre@kernel.org>
Wed, 24 Sep 2014 23:45:59 +0000 (01:45 +0200)
Some gpio implementations return interesting values for gpio_get_value when
the value is not 0 - as seen on a imx6sl board. Therefore do not use the
value returned from gpio_get_value directly but simply check for 0 or not 0.

Signed-off-by: Heiko Stuebner <heiko.stuebner@bq.com>
Reviewed-by: Doug Anderson <dianders@chromium.org>
Tested-by: Doug Anderson <dianders@chromium.org>
Signed-off-by: Sebastian Reichel <sre@kernel.org>
drivers/power/gpio-charger.c

index a0024b2..7536933 100644 (file)
@@ -55,7 +55,7 @@ static int gpio_charger_get_property(struct power_supply *psy,
 
        switch (psp) {
        case POWER_SUPPLY_PROP_ONLINE:
-               val->intval = gpio_get_value_cansleep(pdata->gpio);
+               val->intval = !!gpio_get_value_cansleep(pdata->gpio);
                val->intval ^= pdata->gpio_active_low;
                break;
        default: