OSDN Git Service

greybus: gpio-gb: remove checks for negative offset variable
authorBill Pemberton <wfp5p@worldbroken.com>
Fri, 16 Jan 2015 18:57:32 +0000 (13:57 -0500)
committerGreg Kroah-Hartman <greg@kroah.com>
Fri, 16 Jan 2015 19:08:15 +0000 (11:08 -0800)
offset is defined as unsigned so there is no point checking for
negative values of offset.

Signed-off-by: Bill Pemberton <wfp5p@worldbroken.com>
Signed-off-by: Greg Kroah-Hartman <greg@kroah.com>
drivers/staging/greybus/gpio-gb.c

index 5fcd018..4997588 100644 (file)
@@ -312,7 +312,7 @@ static int gb_gpio_request(struct gpio_chip *chip, unsigned offset)
        struct gb_gpio_controller *gb_gpio_controller = gpio_chip_to_gb_gpio_controller(chip);
        int ret;
 
-       if (offset < 0 || offset >= chip->ngpio)
+       if (offset >= chip->ngpio)
                return -EINVAL;
        ret = gb_gpio_activate_operation(gb_gpio_controller, (u8)offset);
        if (ret)
@@ -325,7 +325,7 @@ static void gb_gpio_free(struct gpio_chip *chip, unsigned offset)
        struct gb_gpio_controller *gb_gpio_controller = gpio_chip_to_gb_gpio_controller(chip);
        int ret;
 
-       if (offset < 0 || offset >= chip->ngpio) {
+       if (offset >= chip->ngpio) {
                pr_err("bad offset %u supplied (must be 0..%u)\n",
                        offset, chip->ngpio - 1);
                return;
@@ -341,7 +341,7 @@ static int gb_gpio_get_direction(struct gpio_chip *chip, unsigned offset)
        u8 which;
        int ret;
 
-       if (offset < 0 || offset >= chip->ngpio)
+       if (offset >= chip->ngpio)
                return -EINVAL;
        which = (u8)offset;
        ret = gb_gpio_get_direction_operation(gb_gpio_controller, which);
@@ -355,7 +355,7 @@ static int gb_gpio_direction_input(struct gpio_chip *chip, unsigned offset)
        struct gb_gpio_controller *gb_gpio_controller = gpio_chip_to_gb_gpio_controller(chip);
        int ret;
 
-       if (offset < 0 || offset >= chip->ngpio)
+       if (offset >= chip->ngpio)
                return -EINVAL;
        ret = gb_gpio_direction_in_operation(gb_gpio_controller, (u8)offset);
        if (ret)
@@ -369,7 +369,7 @@ static int gb_gpio_direction_output(struct gpio_chip *chip, unsigned offset,
        struct gb_gpio_controller *gb_gpio_controller = gpio_chip_to_gb_gpio_controller(chip);
        int ret;
 
-       if (offset < 0 || offset >= chip->ngpio)
+       if (offset >= chip->ngpio)
                return -EINVAL;
        ret = gb_gpio_direction_out_operation(gb_gpio_controller, (u8)offset, !!value);
        if (ret)
@@ -383,7 +383,7 @@ static int gb_gpio_get(struct gpio_chip *chip, unsigned offset)
        u8 which;
        int ret;
 
-       if (offset < 0 || offset >= chip->ngpio)
+       if (offset >= chip->ngpio)
                return -EINVAL;
        which = (u8)offset;
        ret = gb_gpio_get_value_operation(gb_gpio_controller, which);
@@ -414,7 +414,7 @@ static int gb_gpio_set_debounce(struct gpio_chip *chip, unsigned offset,
        u16 usec;
        int ret;
 
-       if (offset < 0 || offset >= chip->ngpio)
+       if (offset >= chip->ngpio)
                return -EINVAL;
        if (debounce > (unsigned int)U16_MAX)
                return -EINVAL;
@@ -428,7 +428,7 @@ static int gb_gpio_set_debounce(struct gpio_chip *chip, unsigned offset,
 
 static int gb_gpio_to_irq(struct gpio_chip *chip, unsigned offset)
 {
-       if (offset < 0 || offset >= chip->ngpio)
+       if (offset >= chip->ngpio)
                return -EINVAL;
 
        return 0;       /* XXX */