Skip to content

Commit

Permalink
gpio: gpiolib: don't compare an unsigned for >= 0
Browse files Browse the repository at this point in the history
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>
Acked-by: Alexandre Courbot <acourbot@nvidia.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Dirk Behme authored and Linus Walleij committed Oct 2, 2015
1 parent 633a506 commit 48b5953
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -995,7 +993,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];
Expand Down

0 comments on commit 48b5953

Please sign in to comment.