linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Axel Lin <axel.lin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org,
	Linus Walleij
	<linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: [PATCH] spi: use gpio_request_one() instead of spi_gpio_alloc() helper function
Date: Mon, 05 Dec 2011 15:50:47 +0800	[thread overview]
Message-ID: <1323071447.20963.3.camel@phoenix> (raw)

Signed-off-by: Axel Lin <axel.lin-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
 drivers/spi/spi-gpio.c |   21 ++++-----------------
 1 files changed, 4 insertions(+), 17 deletions(-)

diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index e093d3e..85c2eca 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -256,20 +256,6 @@ static void spi_gpio_cleanup(struct spi_device *spi)
 	spi_bitbang_cleanup(spi);
 }
 
-static int __init spi_gpio_alloc(unsigned pin, const char *label, bool is_in)
-{
-	int value;
-
-	value = gpio_request(pin, label);
-	if (value == 0) {
-		if (is_in)
-			value = gpio_direction_input(pin);
-		else
-			value = gpio_direction_output(pin, 0);
-	}
-	return value;
-}
-
 static int __init
 spi_gpio_request(struct spi_gpio_platform_data *pdata, const char *label,
 	u16 *res_flags)
@@ -279,7 +265,8 @@ spi_gpio_request(struct spi_gpio_platform_data *pdata, const char *label,
 	/* NOTE:  SPI_*_GPIO symbols may reference "pdata" */
 
 	if (SPI_MOSI_GPIO != SPI_GPIO_NO_MOSI) {
-		value = spi_gpio_alloc(SPI_MOSI_GPIO, label, false);
+		value = gpio_request_one(SPI_MOSI_GPIO, GPIOF_OUT_INIT_LOW,
+					 label);
 		if (value)
 			goto done;
 	} else {
@@ -288,7 +275,7 @@ spi_gpio_request(struct spi_gpio_platform_data *pdata, const char *label,
 	}
 
 	if (SPI_MISO_GPIO != SPI_GPIO_NO_MISO) {
-		value = spi_gpio_alloc(SPI_MISO_GPIO, label, true);
+		value = gpio_request_one(SPI_MISO_GPIO, GPIOF_IN, label);
 		if (value)
 			goto free_mosi;
 	} else {
@@ -296,7 +283,7 @@ spi_gpio_request(struct spi_gpio_platform_data *pdata, const char *label,
 		*res_flags |= SPI_MASTER_NO_RX;
 	}
 
-	value = spi_gpio_alloc(SPI_SCK_GPIO, label, false);
+	value = gpio_request_one(SPI_SCK_GPIO, GPIOF_OUT_INIT_LOW, label);
 	if (value)
 		goto free_miso;
 
-- 
1.7.5.4




------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d

             reply	other threads:[~2011-12-05  7:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-12-05  7:50 Axel Lin [this message]
2011-12-06  1:27 ` [PATCH] spi: use gpio_request_one() instead of spi_gpio_alloc() helper function Denis Kuzmenko
2011-12-07 21:21 ` Wolfram Sang
2011-12-08  1:36   ` Axel Lin
2011-12-08  8:46     ` Wolfram Sang

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=1323071447.20963.3.camel@phoenix \
    --to=axel.lin-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=linus.walleij-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).