All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dirk Behme <dirk.behme@gmail.com>
To: Linus Walleij <linus.walleij@linaro.org>,
	Alexandre Courbot <gnurou@gmail.com>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [PATCH] gpiolib: don't compare an unsigned for >= 0
Date: Sun, 30 Aug 2015 07:13:56 +0200	[thread overview]
Message-ID: <55E29114.4050008@gmail.com> (raw)
In-Reply-To: <1439913752-26634-1-git-send-email-dirk.behme@gmail.com>

On 18.08.2015 18:02, Dirk Behme wrote:
> The parameter offset is an unsigned, so it makes no sense to compare
> it for >= 0. Fix the compiler warning regarding this by removing this
> comparison.
>
> As the macro GPIO_OFFSET_VALID is only used at this single place, simplify
> the code by dropping the macro completely and dropping the invert, too.
>
> No functional change.
>
> Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
> ---
>   drivers/gpio/gpiolib.c | 4 +---
>   1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index bf4bd1d..9841b05 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -47,8 +47,6 @@
>    */
>   DEFINE_SPINLOCK(gpio_lock);
>
> -#define GPIO_OFFSET_VALID(chip, offset) (offset >= 0 && offset < chip->ngpio)
> -
>   static DEFINE_MUTEX(gpio_lookup_lock);
>   static LIST_HEAD(gpio_lookup_list);
>   LIST_HEAD(gpio_chips);
> @@ -914,7 +912,7 @@ const char *gpiochip_is_requested(struct gpio_chip *chip, unsigned offset)
>   {
>   	struct gpio_desc *desc;
>
> -	if (!GPIO_OFFSET_VALID(chip, offset))
> +	if (offset >= chip->ngpio)
>   		return NULL;
>
>   	desc = &chip->desc[offset];


What do you think about this? Could this be applied?

Best regards

Dirk


  reply	other threads:[~2015-08-30  5:14 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-18 16:02 [PATCH] gpiolib: don't compare an unsigned for >= 0 Dirk Behme
2015-08-30  5:13 ` Dirk Behme [this message]
2015-08-31  4:44   ` Alexandre Courbot
2015-09-23  9:41     ` Dirk Behme
2015-10-02  8:57 ` Linus Walleij

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=55E29114.4050008@gmail.com \
    --to=dirk.behme@gmail.com \
    --cc=gnurou@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.