Skip to content

Commit 9c791cb

Browse files
Bartosz GolaszewskiLinus Walleij
authored andcommitted
pinctrl: mediatek: paris: don't double-check the GPIO number
GPIO core already makes sure we don't pass invalid GPIO numbers down to the driver callbacks. Remove needless checks from the driver. Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org> Link: https://lore.kernel.org/20250425-gpiochip-set-rv-pinctrl-mediatek-v1-2-93e6a01855e7@linaro.org Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent 7464c88 commit 9c791cb

1 file changed

Lines changed: 0 additions & 19 deletions

File tree

drivers/pinctrl/mediatek/pinctrl-paris.c

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -840,9 +840,6 @@ static int mtk_gpio_get_direction(struct gpio_chip *chip, unsigned int gpio)
840840
const struct mtk_pin_desc *desc;
841841
int value, err;
842842

843-
if (gpio >= hw->soc->npins)
844-
return -EINVAL;
845-
846843
/*
847844
* "Virtual" GPIOs are always and only used for interrupts
848845
* Since they are only used for interrupts, they are always inputs
@@ -868,9 +865,6 @@ static int mtk_gpio_get(struct gpio_chip *chip, unsigned int gpio)
868865
const struct mtk_pin_desc *desc;
869866
int value, err;
870867

871-
if (gpio >= hw->soc->npins)
872-
return -EINVAL;
873-
874868
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
875869

876870
err = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DI, &value);
@@ -885,32 +879,19 @@ static void mtk_gpio_set(struct gpio_chip *chip, unsigned int gpio, int value)
885879
struct mtk_pinctrl *hw = gpiochip_get_data(chip);
886880
const struct mtk_pin_desc *desc;
887881

888-
if (gpio >= hw->soc->npins)
889-
return;
890-
891882
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
892883

893884
mtk_hw_set_value(hw, desc, PINCTRL_PIN_REG_DO, !!value);
894885
}
895886

896887
static int mtk_gpio_direction_input(struct gpio_chip *chip, unsigned int gpio)
897888
{
898-
struct mtk_pinctrl *hw = gpiochip_get_data(chip);
899-
900-
if (gpio >= hw->soc->npins)
901-
return -EINVAL;
902-
903889
return pinctrl_gpio_direction_input(chip, gpio);
904890
}
905891

906892
static int mtk_gpio_direction_output(struct gpio_chip *chip, unsigned int gpio,
907893
int value)
908894
{
909-
struct mtk_pinctrl *hw = gpiochip_get_data(chip);
910-
911-
if (gpio >= hw->soc->npins)
912-
return -EINVAL;
913-
914895
mtk_gpio_set(chip, gpio, value);
915896

916897
return pinctrl_gpio_direction_output(chip, gpio);

0 commit comments

Comments
 (0)