Message ID | 1442150498-31116-2-git-send-email-jogo@openwrt.org |
---|---|
State | New |
Headers | show |
On Sun, Sep 13, 2015 at 3:21 PM, Jonas Gorski <jogo@openwrt.org> wrote: > Provide generic request/free implementations that pinctrl aware gpio > drivers can use instead of open coding if they use a 1:1 pin to gpio > signal mapping. > > Signed-off-by: Jonas Gorski <jogo@openwrt.org> Hm. Is this really generic? Well I guess of more and more SoC's get pin controllers in front of their GPIOs then yes. But for an off-chip GPIO expander this is not really "generic". > +/** > + * gpiochip_generic_request() - request the gpio function for a pin > + * @chip: the gpiochip owning the GPIO > + * @gpio: the GPIO signal to request for GPIO function > + */ > +int gpiochip_generic_request(struct gpio_chip *chip, unsigned gpio) Second argument should be named "offset", "gpio" is ambigous someone could think it's the global GPIO number. Please collect the various ACKs and I will apply the patch series. I have another comment which will be more of a discussion and possible further improvement. Yours, Linus Walleij -- To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 5db3445..e0853fb 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -15,6 +15,7 @@ #include <linux/acpi.h> #include <linux/gpio/driver.h> #include <linux/gpio/machine.h> +#include <linux/pinctrl/consumer.h> #include "gpiolib.h" @@ -680,6 +681,28 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip) {} #endif /* CONFIG_GPIOLIB_IRQCHIP */ +/** + * gpiochip_generic_request() - request the gpio function for a pin + * @chip: the gpiochip owning the GPIO + * @gpio: the GPIO signal to request for GPIO function + */ +int gpiochip_generic_request(struct gpio_chip *chip, unsigned gpio) +{ + return pinctrl_request_gpio(chip->base + gpio); +} +EXPORT_SYMBOL_GPL(gpiochip_generic_request); + +/** + * gpiochip_generic_free() - free the gpio function from a pin + * @chip: the gpiochip to request the gpio function for + * @gpio: the GPIO signal to free from GPIO + */ +void gpiochip_generic_free(struct gpio_chip *chip, unsigned gpio) +{ + pinctrl_free_gpio(chip->base + gpio); +} +EXPORT_SYMBOL_GPL(gpiochip_generic_free); + #ifdef CONFIG_PINCTRL /** diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h index 1aed31c..0857c28 100644 --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -206,6 +206,9 @@ int _gpiochip_irqchip_add(struct gpio_chip *gpiochip, #endif /* CONFIG_GPIOLIB_IRQCHIP */ +int gpiochip_generic_request(struct gpio_chip *chip, unsigned gpio); +void gpiochip_generic_free(struct gpio_chip *chip, unsigned gpio); + #ifdef CONFIG_PINCTRL /**
Provide generic request/free implementations that pinctrl aware gpio drivers can use instead of open coding if they use a 1:1 pin to gpio signal mapping. Signed-off-by: Jonas Gorski <jogo@openwrt.org> --- drivers/gpio/gpiolib.c | 23 +++++++++++++++++++++++ include/linux/gpio/driver.h | 3 +++ 2 files changed, 26 insertions(+)