Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: stp-xway: Implement get callback

Add an implementation to get the current GPIO state.

The callback is used by the leds-gpio driver for example, in case the
current LED/GPIO state should be kept during driver load.

Signed-off-by: Mathias Kresin <dev@kresin.me>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Mathias Kresin and committed by
Linus Walleij
5b9b2b52 bac5c3b8

+15
+15
drivers/gpio/gpio-stp-xway.c
··· 91 91 }; 92 92 93 93 /** 94 + * xway_stp_get() - gpio_chip->get - get gpios. 95 + * @gc: Pointer to gpio_chip device structure. 96 + * @gpio: GPIO signal number. 97 + * 98 + * Gets the shadow value. 99 + */ 100 + static int xway_stp_get(struct gpio_chip *gc, unsigned int gpio) 101 + { 102 + struct xway_stp *chip = gpiochip_get_data(gc); 103 + 104 + return (xway_stp_r32(chip->virt, XWAY_STP_CPU0) & BIT(gpio)); 105 + } 106 + 107 + /** 94 108 * xway_stp_set() - gpio_chip->set - set gpios. 95 109 * @gc: Pointer to gpio_chip device structure. 96 110 * @gpio: GPIO signal number. ··· 229 215 chip->gc.parent = &pdev->dev; 230 216 chip->gc.label = "stp-xway"; 231 217 chip->gc.direction_output = xway_stp_dir_out; 218 + chip->gc.get = xway_stp_get; 232 219 chip->gc.set = xway_stp_set; 233 220 chip->gc.request = xway_stp_request; 234 221 chip->gc.base = -1;