All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
From: Jonas Gorski <jogo@openwrt.org>
To: linux-gpio@vger.kernel.org
Cc: Linus Walleij <linus.walleij@linaro.org>,
	Alexandre Courbot <gnurou@gmail.com>,
	Joachim Eastwood <manabian@gmail.com>,
	Jonas Jensen <jonas.jensen@gmail.com>,
	Gregory CLEMENT <gregory.clement@free-electrons.com>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons.com>,
	James Hogan <james.hogan@imgtec.com>,
	Stefan Agner <stefan@agner.ch>, Jun Nie <jun.nie@linaro.org>,
	Stephen Warren <swarren@wwwdotorg.org>,
	Lee Jones <lee@kernel.org>, Eric Anholt <eric@anholt.net>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	Alessandro Rubini <rubini@unipv.it>,
	Sonic Zhang <sonic.zhang@analog.com>,
	Laxman Dewangan <ldewangan@nvidia.com>,
	Jean-Christophe Plagniol-Villard <plagnioj@jcrosoft.com>,
	Jonas Aaberg <jonas.aberg@stericsson.com>,
	Baruch Siach <baruch@tkos.co.il>,
	Andrew
Subject: [PATCH RFT 4/5] gpio: gpio-pl061: use the generic request/free implementations
Date: Sun, 13 Sep 2015 15:21:37 +0200	[thread overview]
Message-ID: <1442150498-31116-5-git-send-email-jogo@openwrt.org> (raw)
In-Reply-To: <1442150498-31116-1-git-send-email-jogo@openwrt.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 <jogo@openwrt.org>
---
 drivers/gpio/gpio-pl061.c | 32 ++++----------------------------
 1 file changed, 4 insertions(+), 28 deletions(-)

diff --git a/drivers/gpio/gpio-pl061.c b/drivers/gpio/gpio-pl061.c
index 0475613..92a52ff 100644
--- a/drivers/gpio/gpio-pl061.c
+++ b/drivers/gpio/gpio-pl061.c
@@ -52,36 +52,12 @@ struct pl061_gpio {
 
 	void __iomem		*base;
 	struct gpio_chip	gc;
-	bool			uses_pinctrl;
 
 #ifdef CONFIG_PM
 	struct pl061_context_save_regs csave_regs;
 #endif
 };
 
-static int pl061_gpio_request(struct gpio_chip *gc, unsigned offset)
-{
-	/*
-	 * Map back to global GPIO space and request muxing, the direction
-	 * parameter does not matter for this controller.
-	 */
-	struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
-	int gpio = gc->base + offset;
-
-	if (chip->uses_pinctrl)
-		return pinctrl_request_gpio(gpio);
-	return 0;
-}
-
-static void pl061_gpio_free(struct gpio_chip *gc, unsigned offset)
-{
-	struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
-	int gpio = gc->base + offset;
-
-	if (chip->uses_pinctrl)
-		pinctrl_free_gpio(gpio);
-}
-
 static int pl061_direction_input(struct gpio_chip *gc, unsigned offset)
 {
 	struct pl061_gpio *chip = container_of(gc, struct pl061_gpio, gc);
@@ -269,11 +245,11 @@ static int pl061_probe(struct amba_device *adev, const struct amba_id *id)
 		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;
+	}
 
-	chip->gc.request = pl061_gpio_request;
-	chip->gc.free = pl061_gpio_free;
 	chip->gc.direction_input = pl061_direction_input;
 	chip->gc.direction_output = pl061_direction_output;
 	chip->gc.get = pl061_get_value;
-- 
2.1.4

  parent reply	other threads:[~2015-09-13 13:22 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-13 13:21 [PATCH RFT 0/5] gpiochip: add and use generic request/free Jonas Gorski
2015-09-13 13:21 ` [PATCH RFT 1/5] gpiolib: provide generic request/free implementations Jonas Gorski
2015-10-05  9:17   ` Linus Walleij
2015-09-13 13:21 ` [PATCH RFT 2/5] gpio: replace trivial implementations of request/free with generic one Jonas Gorski
2015-09-14 14:37   ` Thomas Petazzoni
2015-09-14 17:14   ` James Hogan
2015-09-15  3:32   ` Stefan Agner
2015-09-20 13:16   ` Joachim Eastwood
2015-09-13 13:21 ` [PATCH RFT 3/5] gpio: gpio-xz: use the generic request/free implementations Jonas Gorski
2015-09-13 13:21 ` Jonas Gorski [this message]
2015-10-05  9:19   ` [PATCH RFT 4/5] gpio: gpio-pl061: " Linus Walleij
2015-10-05 13:12     ` Jonas Gorski
2015-10-06  7:23       ` Linus Walleij
2015-09-13 13:21 ` [PATCH RFT 5/5] pinctrl: replace trivial implementations of gpio_chip request/free Jonas Gorski
2015-09-13 19:07   ` Bjorn Andersson
2015-09-13 19:20   ` Heiko Stübner
2015-09-14 14:18   ` Eric Anholt
2015-09-14 14:41   ` Mika Westerberg
2015-09-14 16:53   ` Andrew Bresticker
2015-09-16 11:07   ` Baruch Siach
2015-09-20 13:40   ` Matthias Brugger
2015-10-01 12:32   ` Lee Jones
2015-10-05 10:37   ` Laxman Dewangan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1442150498-31116-5-git-send-email-jogo@openwrt.org \
    --to=jogo@openwrt.org \
    --cc=baruch@tkos.co.il \
    --cc=eric@anholt.net \
    --cc=gnurou@gmail.com \
    --cc=gregory.clement@free-electrons.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=james.hogan@imgtec.com \
    --cc=jonas.aberg@stericsson.com \
    --cc=jonas.jensen@gmail.com \
    --cc=jun.nie@linaro.org \
    --cc=ldewangan@nvidia.com \
    --cc=lee@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=manabian@gmail.com \
    --cc=matthias.bgg@gmail.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=plagnioj@jcrosoft.com \
    --cc=rubini@unipv.it \
    --cc=sonic.zhang@analog.com \
    --cc=stefan@agner.ch \
    --cc=swarren@wwwdotorg.org \
    --cc=thomas.petazzoni@free-electrons.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.