All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] spi: spi-gpio: Use 'cansleep' variants to access GPIO
@ 2013-11-24 12:37 Ezequiel Garcia
       [not found] ` <1385296621-23638-1-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Ezequiel Garcia @ 2013-11-24 12:37 UTC (permalink / raw)
  To: linux-spi-u79uwXL29TY76Z2rM5mHXA
  Cc: broonie-DgEjT+Ai2ygdnm+yROfE0A, Ezequiel Garcia

The GPIO chip in use could be of any kind, and therefore might sleep
when accesing the GPIO lines. Take account of this by using cansleep
instead, which is the most generic case.

Signed-off-by: Ezequiel Garcia <ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
---
 drivers/spi/spi-gpio.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index 3fb09f9..7beeb29 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -115,17 +115,17 @@ spi_to_pdata(const struct spi_device *spi)
 
 static inline void setsck(const struct spi_device *spi, int is_on)
 {
-	gpio_set_value(SPI_SCK_GPIO, is_on);
+	gpio_set_value_cansleep(SPI_SCK_GPIO, is_on);
 }
 
 static inline void setmosi(const struct spi_device *spi, int is_on)
 {
-	gpio_set_value(SPI_MOSI_GPIO, is_on);
+	gpio_set_value_cansleep(SPI_MOSI_GPIO, is_on);
 }
 
 static inline int getmiso(const struct spi_device *spi)
 {
-	return !!gpio_get_value(SPI_MISO_GPIO);
+	return !!gpio_get_value_cansleep(SPI_MISO_GPIO);
 }
 
 #undef pdata
@@ -229,7 +229,7 @@ static void spi_gpio_chipselect(struct spi_device *spi, int is_active)
 
 	if (cs != SPI_GPIO_NO_CHIPSELECT) {
 		/* SPI is normally active-low */
-		gpio_set_value(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active);
+		gpio_set_value_cansleep(cs, (spi->mode & SPI_CS_HIGH) ? is_active : !is_active);
 	}
 }
 
-- 
1.8.1.5

--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] spi: spi-gpio: Use 'cansleep' variants to access GPIO
       [not found] ` <1385296621-23638-1-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
@ 2013-11-24 14:12   ` Mark Brown
       [not found]     ` <20131124141255.GZ14725-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Brown @ 2013-11-24 14:12 UTC (permalink / raw)
  To: Ezequiel Garcia; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 268 bytes --]

On Sun, Nov 24, 2013 at 09:37:01AM -0300, Ezequiel Garcia wrote:
> The GPIO chip in use could be of any kind, and therefore might sleep
> when accesing the GPIO lines. Take account of this by using cansleep
> instead, which is the most generic case.

Applied, thanks.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] spi: spi-gpio: Use 'cansleep' variants to access GPIO
       [not found]     ` <20131124141255.GZ14725-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
@ 2013-11-24 15:56       ` Ezequiel Garcia
  2013-11-25 10:19         ` Mark Brown
  0 siblings, 1 reply; 4+ messages in thread
From: Ezequiel Garcia @ 2013-11-24 15:56 UTC (permalink / raw)
  To: Mark Brown; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

On Sun, Nov 24, 2013 at 02:12:55PM +0000, Mark Brown wrote:
> On Sun, Nov 24, 2013 at 09:37:01AM -0300, Ezequiel Garcia wrote:
> > The GPIO chip in use could be of any kind, and therefore might sleep
> > when accesing the GPIO lines. Take account of this by using cansleep
> > instead, which is the most generic case.
> 
> Applied, thanks.

Mark:

I'm just wondering -as I don't have much experience with gpiolib-
is this replacement the Right Thing To Do?

It seemed to me that the xxx_cansleep variant just adds a check
and a might_sleep, so this change won't hurt the general case.

Is this correct?
-- 
Ezequiel García, Free Electrons
Embedded Linux, Kernel and Android Engineering
http://free-electrons.com
--
To unsubscribe from this list: send the line "unsubscribe linux-spi" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] spi: spi-gpio: Use 'cansleep' variants to access GPIO
  2013-11-24 15:56       ` Ezequiel Garcia
@ 2013-11-25 10:19         ` Mark Brown
  0 siblings, 0 replies; 4+ messages in thread
From: Mark Brown @ 2013-11-25 10:19 UTC (permalink / raw)
  To: Ezequiel Garcia; +Cc: linux-spi-u79uwXL29TY76Z2rM5mHXA

[-- Attachment #1: Type: text/plain, Size: 337 bytes --]

On Sun, Nov 24, 2013 at 12:56:29PM -0300, Ezequiel Garcia wrote:

> I'm just wondering -as I don't have much experience with gpiolib-
> is this replacement the Right Thing To Do?

> It seemed to me that the xxx_cansleep variant just adds a check
> and a might_sleep, so this change won't hurt the general case.

> Is this correct?

Yes.

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-11-25 10:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-24 12:37 [PATCH] spi: spi-gpio: Use 'cansleep' variants to access GPIO Ezequiel Garcia
     [not found] ` <1385296621-23638-1-git-send-email-ezequiel.garcia-wi1+55ScJUtKEb57/3fJTNBPR1lH4CV8@public.gmane.org>
2013-11-24 14:12   ` Mark Brown
     [not found]     ` <20131124141255.GZ14725-GFdadSzt00ze9xe1eoZjHA@public.gmane.org>
2013-11-24 15:56       ` Ezequiel Garcia
2013-11-25 10:19         ` Mark Brown

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.