From 83d9cddb85a0cc7497012846567d16add52916d4 Mon Sep 17 00:00:00 2001 From: Johan Hovold Date: Thu, 19 Mar 2015 16:51:12 +0100 Subject: [PATCH] greybus: gpio: remove overly defensive argument verification Remove overly defensive argument verification in gpio-chip callbacks. We should trust gpiolib to get this right (or we would not even get any callback) just like the other gpio drivers do. Signed-off-by: Johan Hovold Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/gpio.c | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/drivers/staging/greybus/gpio.c b/drivers/staging/greybus/gpio.c index a1bf1430fced..8384ad17e9be 100644 --- a/drivers/staging/greybus/gpio.c +++ b/drivers/staging/greybus/gpio.c @@ -415,8 +415,6 @@ 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 >= chip->ngpio) - return -EINVAL; ret = gb_gpio_activate_operation(gb_gpio_controller, (u8)offset); if (ret) ; /* return ret; */ @@ -428,11 +426,6 @@ 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 >= chip->ngpio) { - pr_err("bad offset %u supplied (must be 0..%u)\n", - offset, chip->ngpio - 1); - return; - } ret = gb_gpio_deactivate_operation(gb_gpio_controller, (u8)offset); if (ret) ; /* return ret; */ @@ -444,8 +437,6 @@ static int gb_gpio_get_direction(struct gpio_chip *chip, unsigned offset) u8 which; int ret; - if (offset >= chip->ngpio) - return -EINVAL; which = (u8)offset; ret = gb_gpio_get_direction_operation(gb_gpio_controller, which); if (ret) @@ -458,8 +449,6 @@ 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 >= chip->ngpio) - return -EINVAL; ret = gb_gpio_direction_in_operation(gb_gpio_controller, (u8)offset); if (ret) ; /* return ret; */ @@ -472,8 +461,6 @@ 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 >= chip->ngpio) - return -EINVAL; ret = gb_gpio_direction_out_operation(gb_gpio_controller, (u8)offset, !!value); if (ret) ; /* return ret; */ @@ -486,8 +473,6 @@ static int gb_gpio_get(struct gpio_chip *chip, unsigned offset) u8 which; int ret; - if (offset >= chip->ngpio) - return -EINVAL; which = (u8)offset; ret = gb_gpio_get_value_operation(gb_gpio_controller, which); if (ret) @@ -500,11 +485,6 @@ static void gb_gpio_set(struct gpio_chip *chip, unsigned offset, int value) struct gb_gpio_controller *gb_gpio_controller = gpio_chip_to_gb_gpio_controller(chip); int ret; - if (offset < 0 || offset >= chip->ngpio) { - pr_err("bad offset %u supplied (must be 0..%u)\n", - offset, chip->ngpio - 1); - return; - } ret = gb_gpio_set_value_operation(gb_gpio_controller, (u8)offset, !!value); if (ret) ; /* return ret; */ @@ -517,8 +497,6 @@ static int gb_gpio_set_debounce(struct gpio_chip *chip, unsigned offset, u16 usec; int ret; - if (offset >= chip->ngpio) - return -EINVAL; if (debounce > U16_MAX) return -EINVAL; usec = (u16)debounce; -- 2.39.5