Commit b560d414 authored by Bartosz Golaszewski's avatar Bartosz Golaszewski Committed by Linus Walleij
Browse files

pinctrl: mediatek: moore: implement gpio_chip::get_direction()



If the gpio_chip::get_direction() callback is not implemented by the GPIO
controller driver, GPIOLIB emits a warning.

Implement get_direction() for the GPIO part of pinctrl-moore.

Fixes: 471e998c ("gpiolib: remove redundant callback check")
Fixes: e623c430 ("gpiolib: sanitize the return value of gpio_chip::get_direction()")
Reported-by: default avatarFrank Wunderlich <frank-w@public-files.de>
Closes: https://lore.kernel.org/all/20260409132724.126258-1-linux@fw-web.de/


Signed-off-by: default avatarBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Tested-By: default avatarFrank Wunderlich <frank-w@public-files.de>
Signed-off-by: default avatarLinus Walleij <linusw@kernel.org>
parent 254f4963
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -520,6 +520,23 @@ static int mtk_gpio_direction_output(struct gpio_chip *chip, unsigned int gpio,
	return pinctrl_gpio_direction_output(chip, gpio);
}

static int mtk_gpio_get_direction(struct gpio_chip *chip, unsigned int offset)
{
	struct mtk_pinctrl *hw = gpiochip_get_data(chip);
	const struct mtk_pin_desc *desc;
	int ret, dir;

	desc = (const struct mtk_pin_desc *)&hw->soc->pins[offset];
	if (!desc->name)
		return -ENOTSUPP;

	ret = mtk_hw_get_value(hw, desc, PINCTRL_PIN_REG_DIR, &dir);
	if (ret)
		return ret;

	return dir ? GPIO_LINE_DIRECTION_OUT : GPIO_LINE_DIRECTION_IN;
}

static int mtk_gpio_to_irq(struct gpio_chip *chip, unsigned int offset)
{
	struct mtk_pinctrl *hw = gpiochip_get_data(chip);
@@ -566,6 +583,7 @@ static int mtk_build_gpiochip(struct mtk_pinctrl *hw)
	chip->parent		= hw->dev;
	chip->request		= gpiochip_generic_request;
	chip->free		= gpiochip_generic_free;
	chip->get_direction	= mtk_gpio_get_direction;
	chip->direction_input	= pinctrl_gpio_direction_input;
	chip->direction_output	= mtk_gpio_direction_output;
	chip->get		= mtk_gpio_get;