gpio / ACPI: use *_cansleep version of gpiod_get/set APIs
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
@@ -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
Quoted 16 lines · Aaron Lu
The GPIO operation region handler should be called where sleep is allowed, so we should use the
*_cansleepversion of gpiod_get/set APIs or we will get a warning message complaining invalid context if the GPIO chip has the cansleep flag set.Signed-off-by Aaron Lu <[email protected]>Acked-by Mika Westerberg <[email protected]>--- drivers/gpio/gpiolib-acpi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpio/gpiolib-acpi.c +0
-0
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
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
*_cansleepversion of gpiod_get/set APIs or we will get a warning message complaining invalid context if the GPIO chip has the cansleep flag set.Signed-off-by Aaron Lu <[email protected]>Acked-by Mika Westerberg <[email protected]>--- drivers/gpio/gpiolib-acpi.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)drivers/gpio/gpiolib-acpi.c +0
-0drivers/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
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
@@ -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
Quoted 4 lines · Aaron Lu
The GPIO operation region handler should be called where sleep is allowed, so we should use the
*_cansleepversion 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
Signed-off-by Aaron Lu <[email protected]>Acked-by Mika Westerberg <[email protected]>---
v2: remove the inclusion oflinux/gpio.has pointed out by Mika.drivers/gpio/gpiolib-acpi.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)drivers/gpio/gpiolib-acpi.c +3
-3@@ -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
Quoted 9 lines · Aaron Lu
The GPIO operation region handler should be called where sleep is allowed, so we should use the
*_cansleepversion of gpiod_get/set APIs or we will get a warning message complaining invalid context if the GPIO chip has the cansleep flag set.Signed-off-by Aaron Lu <[email protected]>Acked-by Mika Westerberg <[email protected]>---
v2: remove the inclusion oflinux/gpio.has pointed out by Mika.
Patch applied with ALex's ACK.
Yours,
Linus Walleij