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

pinctrl: bcm: nsp: implement get_direction

The get_direction api is strongly recommended to be implemented. In fact
if it is not implemented gpio-hogs will not get the correct direction.
Add an implementation of get_direction for the nsp-gpio driver.

Signed-off-by: Chris Packham <chris.packham@alliedtelesis.co.nz>
Reviewed-by: Florian Fainelli <f.fainelli@gmail.com>
Link: https://lore.kernel.org/r/20191104001819.2300-3-chris.packham@alliedtelesis.co.nz
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Chris Packham and committed by
Linus Walleij
574dce89 8298d18a

+14
+14
drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
··· 297 297 return 0; 298 298 } 299 299 300 + static int nsp_gpio_get_direction(struct gpio_chip *gc, unsigned gpio) 301 + { 302 + struct nsp_gpio *chip = gpiochip_get_data(gc); 303 + unsigned long flags; 304 + int val; 305 + 306 + raw_spin_lock_irqsave(&chip->lock, flags); 307 + val = nsp_get_bit(chip, REG, NSP_GPIO_OUT_EN, gpio); 308 + raw_spin_unlock_irqrestore(&chip->lock, flags); 309 + 310 + return !val; 311 + } 312 + 300 313 static void nsp_gpio_set(struct gpio_chip *gc, unsigned gpio, int val) 301 314 { 302 315 struct nsp_gpio *chip = gpiochip_get_data(gc); ··· 654 641 gc->free = gpiochip_generic_free; 655 642 gc->direction_input = nsp_gpio_direction_input; 656 643 gc->direction_output = nsp_gpio_direction_output; 644 + gc->get_direction = nsp_gpio_get_direction; 657 645 gc->set = nsp_gpio_set; 658 646 gc->get = nsp_gpio_get; 659 647