From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jonas Gorski Subject: [PATCH RFT 1/5] gpiolib: provide generic request/free implementations Date: Sun, 13 Sep 2015 15:21:34 +0200 Message-ID: <1442150498-31116-2-git-send-email-jogo@openwrt.org> References: <1442150498-31116-1-git-send-email-jogo@openwrt.org> Return-path: Received: from arrakis.dune.hu ([78.24.191.176]:54516 "EHLO arrakis.dune.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751949AbbIMNWJ (ORCPT ); Sun, 13 Sep 2015 09:22:09 -0400 In-Reply-To: <1442150498-31116-1-git-send-email-jogo@openwrt.org> Sender: linux-gpio-owner@vger.kernel.org List-Id: linux-gpio@vger.kernel.org To: linux-gpio@vger.kernel.org Cc: Linus Walleij , Alexandre Courbot , Joachim Eastwood , Jonas Jensen , Gregory CLEMENT , Thomas Petazzoni , James Hogan , Stefan Agner , Jun Nie , Stephen Warren , Lee Jones , Eric Anholt , Mika Westerberg , Heikki Krogerus , Matthias Brugger , Alessandro Rubini , Sonic Zhang , Laxman Dewangan , Jean-Christophe Plagniol-Villard , Jonas Aaberg , Baruch Siach , Andrew 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 --- drivers/gpio/gpiolib.c | 23 +++++++++++++++++++++++ include/linux/gpio/driver.h | 3 +++ 2 files changed, 26 insertions(+) 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 #include #include +#include #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 /** -- 2.1.4