diff mbox

[v4,2/2] spi: omap2-mcspi: Add gpio_request and init CS

Message ID 1431041814-24757-3-git-send-email-mwelling@ieee.org (mailing list archive)
State New, archived
Headers show

Commit Message

Michael Welling May 7, 2015, 11:36 p.m. UTC
If GPIO chipselects are specified initialise the GPIO in the setup function.

Signed-off-by: Michael Welling <mwelling@ieee.org>
---
 drivers/spi/spi-omap2-mcspi.c |    7 +++++++
 1 file changed, 7 insertions(+)

Comments

Mark Brown May 8, 2015, 5:09 p.m. UTC | #1
On Thu, May 07, 2015 at 06:36:54PM -0500, Michael Welling wrote:

> +	if (gpio_is_valid(spi->cs_gpio)) {
> +		if (gpio_request(spi->cs_gpio, dev_name(&spi->dev)) == 0)
> +			gpio_direction_output(spi->cs_gpio,
> +			!(spi->mode & SPI_CS_HIGH));
> +	}

I'm not seeing anything that frees this GPIO?
Michael Welling May 8, 2015, 5:37 p.m. UTC | #2
On Fri, May 08, 2015 at 06:09:16PM +0100, Mark Brown wrote:
> On Thu, May 07, 2015 at 06:36:54PM -0500, Michael Welling wrote:
> 
> > +	if (gpio_is_valid(spi->cs_gpio)) {
> > +		if (gpio_request(spi->cs_gpio, dev_name(&spi->dev)) == 0)
> > +			gpio_direction_output(spi->cs_gpio,
> > +			!(spi->mode & SPI_CS_HIGH));
> > +	}
> 
> I'm not seeing anything that frees this GPIO?

Ooops I forgot to add this to the cleanup function.

It appears that the transfer_one patch got applied so how should I
provide the new version of this patch?

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Mark Brown May 8, 2015, 5:53 p.m. UTC | #3
On Fri, May 08, 2015 at 12:37:37PM -0500, Michael Welling wrote:

> It appears that the transfer_one patch got applied so how should I
> provide the new version of this patch?

Incrementally.
diff mbox

Patch

diff --git a/drivers/spi/spi-omap2-mcspi.c b/drivers/spi/spi-omap2-mcspi.c
index 3ac06ad..370c333 100644
--- a/drivers/spi/spi-omap2-mcspi.c
+++ b/drivers/spi/spi-omap2-mcspi.c
@@ -35,6 +35,7 @@ 
 #include <linux/gcd.h>
 
 #include <linux/spi/spi.h>
+#include <linux/gpio.h>
 
 #include <linux/platform_data/spi-omap2-mcspi.h>
 
@@ -1015,6 +1016,12 @@  static int omap2_mcspi_setup(struct spi_device *spi)
 	if (ret < 0)
 		return ret;
 
+	if (gpio_is_valid(spi->cs_gpio)) {
+		if (gpio_request(spi->cs_gpio, dev_name(&spi->dev)) == 0)
+			gpio_direction_output(spi->cs_gpio,
+			!(spi->mode & SPI_CS_HIGH));
+	}
+
 	ret = omap2_mcspi_setup_transfer(spi, NULL);
 	pm_runtime_mark_last_busy(mcspi->dev);
 	pm_runtime_put_autosuspend(mcspi->dev);