Skip to contentSkip to conversation

gpio / ACPI: use *_cansleep version of gpiod_get/set APIs

PATCH Superseded Aaron Lu 4 participants 6 messages May 20, 2014 – May 23, 2014 GPIO

lore
Share & tools
lore

Aaron Lu

author
#0 lore raw

PATCH 1/1 gpio / ACPI: use *_cansleep version of gpiod_get/set APIs

The GPIO operation region handler should be called where sleep is allowed, so we should use the *_cansleep version of gpiod_get/set APIs or we will get a warning message complaining invalid context if the GPIO chip has the cansleep flag set.

---
 drivers/gpio/gpiolib-acpi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpio/gpiolib-acpi.c +4 -2
index bf0f8b4..2d398a6 100644
@@ -17,6 +17,7 @@
 #include <linux/acpi.h>
 #include <linux/interrupt.h>
 #include <linux/mutex.h>
+#include <linux/gpio.h>
 
 #include "gpiolib.h"
 
@@ -449,9 +450,10 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
 		mutex_unlock(&achip->conn_lock);
 
 		if (function == ACPI_WRITE)
-			gpiod_set_raw_value(desc, !!((1 << i) & *value));
+			gpiod_set_raw_value_cansleep(desc,
+						     !!((1 << i) & *value));
 		else
-			*value |= gpiod_get_raw_value(desc) << i;
+			*value |= gpiod_get_raw_value_cansleep(desc) << i;
 	}
 
 out:
Signature · 1 line
1.9.0
#1 lore raw
Quoted 16 lines · Aaron Lu

The GPIO operation region handler should be called where sleep is allowed, so we should use the *_cansleep version of gpiod_get/set APIs or we will get a warning message complaining invalid context if the GPIO chip has the cansleep flag set.

---
 drivers/gpio/gpiolib-acpi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpio/gpiolib-acpi.c +0 -0
index bf0f8b4..2d398a6 100644

drivers/gpio/gpiolib-acpi.c line 20

Quoted 4 lines
drivers/gpio/gpiolib-acpi.c +1 -0
@@ -17,6 +17,7 @@
 #include <linux/acpi.h>
 #include <linux/interrupt.h>
 #include <linux/mutex.h>
+#include <linux/gpio.h>

Why the above include?

(Sorry I just noticed this now).

Quoted 18 lines
drivers/gpio/gpiolib-acpi.c +3 -2
 #include "gpiolib.h"
 
@@ -449,9 +450,10 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
 		mutex_unlock(&achip->conn_lock);
 
 		if (function == ACPI_WRITE)
-			gpiod_set_raw_value(desc, !!((1 << i) & *value));
+			gpiod_set_raw_value_cansleep(desc,
+						     !!((1 << i) & *value));
 		else
-			*value |= gpiod_get_raw_value(desc) << i;
+			*value |= gpiod_get_raw_value_cansleep(desc) << i;
 	}
 
 out:
Signature · 1 line
1.9.0
author
#2 lore raw
Quoted 24 lines · Mika Westerberg
Quoted 16 lines · Aaron Lu

The GPIO operation region handler should be called where sleep is allowed, so we should use the *_cansleep version of gpiod_get/set APIs or we will get a warning message complaining invalid context if the GPIO chip has the cansleep flag set.

---
 drivers/gpio/gpiolib-acpi.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/gpio/gpiolib-acpi.c +0 -0
index bf0f8b4..2d398a6 100644

drivers/gpio/gpiolib-acpi.c line 20

Quoted 4 lines
drivers/gpio/gpiolib-acpi.c +1 -0
@@ -17,6 +17,7 @@
 #include <linux/acpi.h>
 #include <linux/interrupt.h>
 #include <linux/mutex.h>
+#include <linux/gpio.h>

Why the above include?

Quoted 1 line

(Sorry I just noticed this now).

My bad - I used the gpio_set_value_cansleep at first which requires the inclusion of that header file. Later, I found that I should use the gpiod_set_raw_value_cansleep instead but forgot to remove that header. Will remove the inclusion in v2, thanks for the remind!

-Aaron

Quoted 19 lines
Quoted 19 lines
drivers/gpio/gpiolib-acpi.c +3 -2
 #include "gpiolib.h"
 
@@ -449,9 +450,10 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
 		mutex_unlock(&achip->conn_lock);
 
 		if (function == ACPI_WRITE)
-			gpiod_set_raw_value(desc, !!((1 << i) & *value));
+			gpiod_set_raw_value_cansleep(desc,
+						     !!((1 << i) & *value));
 		else
-			*value |= gpiod_get_raw_value(desc) << i;
+			*value |= gpiod_get_raw_value_cansleep(desc) << i;
 	}
 
 out:
Signature · 1 line
1.9.0
author
#3 lore raw

PATCH v2 1/1 gpio / ACPI: use *_cansleep version of gpiod_get/set APIs

The GPIO operation region handler should be called where sleep is allowed, so we should use the *_cansleep version of gpiod_get/set APIs or we will get a warning message complaining invalid context if the GPIO chip has the cansleep flag set.

---
v2: remove the inclusion of linux/gpio.h as pointed out by Mika.

 drivers/gpio/gpiolib-acpi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpio/gpiolib-acpi.c +3 -2
index 401add28933f..4a987917c186 100644
@@ -449,9 +449,10 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
 		mutex_unlock(&achip->conn_lock);
 
 		if (function == ACPI_WRITE)
-			gpiod_set_raw_value(desc, !!((1 << i) & *value));
+			gpiod_set_raw_value_cansleep(desc,
+						     !!((1 << i) & *value));
 		else
-			*value |= (u64)gpiod_get_raw_value(desc) << i;
+			*value |= (u64)gpiod_get_raw_value_cansleep(desc) << i;
 	}
 
 out:
Signature · 1 line
1.9.0
Acked-by on v2 1/1
#4 lore raw
Quoted 4 lines · Aaron Lu

The GPIO operation region handler should be called where sleep is allowed, so we should use the *_cansleep version of gpiod_get/set APIs or we will get a warning message complaining invalid context if the GPIO chip has the cansleep flag set.

Quoted 29 lines

---
v2: remove the inclusion of linux/gpio.h as pointed out by Mika.

 drivers/gpio/gpiolib-acpi.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpio/gpiolib-acpi.c +3 -3
index 401add28933f..4a987917c186 100644
@@ -449,9 +449,10 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
                mutex_unlock(&achip->conn_lock);
 
                if (function == ACPI_WRITE)
-                       gpiod_set_raw_value(desc, !!((1 << i) & *value));
+                       gpiod_set_raw_value_cansleep(desc,
+                                                    !!((1 << i) & *value));
                else
-                       *value |= (u64)gpiod_get_raw_value(desc) << i;
+                       *value |= (u64)gpiod_get_raw_value_cansleep(desc) << i;
        }
 
 out:
--

1.9.0

#5 lore raw
In reply to Aaron Lu
Quoted 9 lines · Aaron Lu

The GPIO operation region handler should be called where sleep is allowed, so we should use the *_cansleep version of gpiod_get/set APIs or we will get a warning message complaining invalid context if the GPIO chip has the cansleep flag set.

---
v2: remove the inclusion of linux/gpio.h as pointed out by Mika.

Patch applied with ALex's ACK.

Yours,
Linus Walleij