From patchwork Sun Sep 13 13:21:36 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jonas Gorski X-Patchwork-Id: 517175 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id C5AF41400B7 for ; Sun, 13 Sep 2015 23:22:46 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752466AbbIMNWq (ORCPT ); Sun, 13 Sep 2015 09:22:46 -0400 Received: from arrakis.dune.hu ([78.24.191.176]:54555 "EHLO arrakis.dune.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752455AbbIMNWp (ORCPT ); Sun, 13 Sep 2015 09:22:45 -0400 Received: from localhost (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id DA37F28BE4D; Sun, 13 Sep 2015 15:21:19 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=ALL_TRUSTED,BAYES_00 autolearn=ham version=3.3.2 X-Virus-Scanned: at arrakis.dune.hu Received: from localhost.localdomain (dslb-088-073-016-160.088.073.pools.vodafone-ip.de [88.73.16.160]) by arrakis.dune.hu (Postfix) with ESMTPSA id 8039C28BE32; Sun, 13 Sep 2015 15:20:53 +0200 (CEST) From: Jonas Gorski 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 Bresticker , Heiko Stuebner , Srinivas Kandagatla , Maxime Coquelin , Patrice Chotard , John Crispin , Kumar Gala , Andy Gross , David Brown , Tomasz Figa , Maxime Ripard , Tony Prisk Subject: [PATCH RFT 3/5] gpio: gpio-xz: use the generic request/free implementations Date: Sun, 13 Sep 2015 15:21:36 +0200 Message-Id: <1442150498-31116-4-git-send-email-jogo@openwrt.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1442150498-31116-1-git-send-email-jogo@openwrt.org> References: <1442150498-31116-1-git-send-email-jogo@openwrt.org> Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Instead of storing in the chip data whether the chip uses pinctrl and conditionally call pinctrl_{request,free}_gpio, just don't populate request/free in that case. This makes the implementations trivial and the same as the generic implementations, thus we can just use them. Signed-off-by: Jonas Gorski --- drivers/gpio/gpio-zx.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/drivers/gpio/gpio-zx.c b/drivers/gpio/gpio-zx.c index 12ee196..19f9be4 100644 --- a/drivers/gpio/gpio-zx.c +++ b/drivers/gpio/gpio-zx.c @@ -41,7 +41,6 @@ struct zx_gpio { void __iomem *base; struct gpio_chip gc; - bool uses_pinctrl; }; static inline struct zx_gpio *to_zx(struct gpio_chip *gc) @@ -49,25 +48,6 @@ static inline struct zx_gpio *to_zx(struct gpio_chip *gc) return container_of(gc, struct zx_gpio, gc); } -static int zx_gpio_request(struct gpio_chip *gc, unsigned offset) -{ - struct zx_gpio *chip = to_zx(gc); - int gpio = gc->base + offset; - - if (chip->uses_pinctrl) - return pinctrl_request_gpio(gpio); - return 0; -} - -static void zx_gpio_free(struct gpio_chip *gc, unsigned offset) -{ - struct zx_gpio *chip = to_zx(gc); - int gpio = gc->base + offset; - - if (chip->uses_pinctrl) - pinctrl_free_gpio(gpio); -} - static int zx_direction_input(struct gpio_chip *gc, unsigned offset) { struct zx_gpio *chip = to_zx(gc); @@ -252,12 +232,12 @@ static int zx_gpio_probe(struct platform_device *pdev) return PTR_ERR(chip->base); spin_lock_init(&chip->lock); - if (of_property_read_bool(dev->of_node, "gpio-ranges")) - chip->uses_pinctrl = true; + if (of_property_read_bool(dev->of_node, "gpio-ranges")) { + chip->gc.request = gpiochip_generic_request; + chip->gc.free = gpiochip_generic_free; + } id = of_alias_get_id(dev->of_node, "gpio"); - chip->gc.request = zx_gpio_request; - chip->gc.free = zx_gpio_free; chip->gc.direction_input = zx_direction_input; chip->gc.direction_output = zx_direction_output; chip->gc.get = zx_get_value;