lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAD=FV=Vkz1e-AEQv30YS-hFos59RES_4qNbH6Wu1UQvfAWLW8A@mail.gmail.com>
Date:	Mon, 22 Sep 2014 09:50:55 -0700
From:	Doug Anderson <dianders@...omium.org>
To:	Heiko Stuebner <heiko@...ech.de>
Cc:	sre@...nel.org, Dmitry Eremin-Solenikov <dbaryshkov@...il.com>,
	David Woodhouse <dwmw2@...radead.org>,
	"linux-pm@...r.kernel.org" <linux-pm@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
	"devicetree@...r.kernel.org" <devicetree@...r.kernel.org>,
	Rob Herring <robh+dt@...nel.org>,
	Mark Rutland <mark.rutland@....com>,
	Pawel Moll <pawel.moll@....com>,
	Ian Campbell <ijc+devicetree@...lion.org.uk>,
	Kumar Gala <galak@...eaurora.org>,
	Heiko Stuebner <heiko.stuebner@...com>
Subject: Re: [PATCH v2 3/3] power: gpio-charger: do not use gpio value directly

Heiko,

On Sun, Sep 21, 2014 at 1:05 PM, Heiko Stuebner <heiko@...ech.de> wrote:
> From: Heiko Stuebner <heiko.stuebner@...com>
>
> 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@...com>
> ---
>  drivers/power/gpio-charger.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/power/gpio-charger.c b/drivers/power/gpio-charger.c
> index 5fe6879..ce99a29 100644
> --- a/drivers/power/gpio-charger.c
> +++ b/drivers/power/gpio-charger.c
> @@ -57,7 +57,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) ? 1 : 0;

There is a common practice about using "!!" for this.  AKA:
"val->intval = !!gpio_get_value_cansleep(pdata->gpio);".

>                 val->intval ^= pdata->gpio_active_low;

It seems like while you're at it you could also fix
"pdata->gpio_active_low" to have the "!!", just to be safe.

...if you don't fix this, perhaps you should fix your last patch to
add a "!!", like:

  pdata->gpio_active_low = !!(flags & OF_GPIO_ACTIVE_LOW);

...technically OF_GPIO_ACTIVE_LOW is 0x1 so it's not a bug, but...
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ