From: Bjorn Andersson <bjorn@kryo.se>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: linux-gpio@vger.kernel.org, Roland Stigge <stigge@antcom.de>,
Vladimir Zapolskiy <vz@mleia.com>
Subject: Re: [PATCH 08/54] gpio: lpc32xx: Be sure to clamp return value
Date: Sun, 27 Dec 2015 20:11:40 -0800 [thread overview]
Message-ID: <20151228041140.GG16437@tuxbot> (raw)
In-Reply-To: <1450793615-22239-1-git-send-email-linus.walleij@linaro.org>
On Tue 22 Dec 06:13 PST 2015, Linus Walleij wrote:
> As we want gpio_chip .get() calls to be able to return negative
> error codes and propagate to drivers, we need to go over all
> drivers and make sure their return values are clamped to [0,1].
> We do this by using the ret = !!(val) design pattern.
>
> Cc: Roland Stigge <stigge@antcom.de>
> Cc: Vladimir Zapolskiy <vz@mleia.com>
> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
> ---
> drivers/gpio/gpio-lpc32xx.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpio/gpio-lpc32xx.c b/drivers/gpio/gpio-lpc32xx.c
> index 47e2dde63734..e888b5fcd236 100644
> --- a/drivers/gpio/gpio-lpc32xx.c
> +++ b/drivers/gpio/gpio-lpc32xx.c
> @@ -288,21 +288,21 @@ static int lpc32xx_gpio_get_value_p012(struct gpio_chip *chip, unsigned pin)
> {
> struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip);
>
> - return __get_gpio_state_p012(group, pin);
> + return !!__get_gpio_state_p012(group, pin);
> }
>
> static int lpc32xx_gpio_get_value_p3(struct gpio_chip *chip, unsigned pin)
> {
> struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip);
>
> - return __get_gpio_state_p3(group, pin);
> + return !!__get_gpio_state_p3(group, pin);
> }
>
> static int lpc32xx_gpi_get_value(struct gpio_chip *chip, unsigned pin)
> {
> struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip);
>
> - return __get_gpi_state_p3(group, pin);
> + return !!__get_gpi_state_p3(group, pin);
> }
>
> static int lpc32xx_gpio_dir_output_p012(struct gpio_chip *chip, unsigned pin,
> @@ -364,7 +364,7 @@ static int lpc32xx_gpo_get_value(struct gpio_chip *chip, unsigned pin)
> {
> struct lpc32xx_gpio_chip *group = to_lpc32xx_gpio(chip);
>
> - return __get_gpo_state_p3(group, pin);
> + return !!__get_gpo_state_p3(group, pin);
> }
>
> static int lpc32xx_gpio_request(struct gpio_chip *chip, unsigned pin)
All of these ends with a "& 1"-operation, so this patch is not needed.
Regards,
Bjorn
prev parent reply other threads:[~2015-12-28 4:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-22 14:13 [PATCH 08/54] gpio: lpc32xx: Be sure to clamp return value Linus Walleij
2015-12-28 4:11 ` Bjorn Andersson [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151228041140.GG16437@tuxbot \
--to=bjorn@kryo.se \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=stigge@antcom.de \
--cc=vz@mleia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).