Skip to contentSkip to conversation

gpiolib: cdev: add GPIO_V2_LINE_FLAG_EDGE_BOTH and use it in edge_irq_thread()

PATCH Applied Kent Gibson 2 participants 2 messages Oct 29, 2020 – Oct 30, 2020

Subsystems (2)
lore
Share & tools
lore

Kent Gibson

author reviewer
#0 lore raw

PATCH 1/1 gpiolib: cdev: add GPIO_V2_LINE_FLAG_EDGE_BOTH and use it in edge_irq_thread()

Add GPIO_V2_LINE_FLAG_EDGE_BOTH macro and use it in edge_irq_thread() to improve readability of edge handling cases.

---
 drivers/gpio/gpiolib-cdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpio/gpiolib-cdev.c +3 -2
index ea787eb3810d..5eb4435afa64 100644
@@ -510,6 +510,8 @@ struct linereq {
 	(GPIO_V2_LINE_FLAG_EDGE_RISING | \
 	 GPIO_V2_LINE_FLAG_EDGE_FALLING)
 
+#define GPIO_V2_LINE_FLAG_EDGE_BOTH GPIO_V2_LINE_EDGE_FLAGS
+
 #define GPIO_V2_LINE_VALID_FLAGS \
 	(GPIO_V2_LINE_FLAG_ACTIVE_LOW | \
 	 GPIO_V2_LINE_DIRECTION_FLAGS | \
@@ -569,8 +571,7 @@ static irqreturn_t edge_irq_thread(int irq, void *p)
 	line->timestamp_ns = 0;
 
 	eflags = READ_ONCE(line->eflags);
-	if (eflags == (GPIO_V2_LINE_FLAG_EDGE_RISING |
-		       GPIO_V2_LINE_FLAG_EDGE_FALLING)) {
+	if (eflags == GPIO_V2_LINE_FLAG_EDGE_BOTH) {
 		int level = gpiod_get_value_cansleep(line->desc);
 
 		if (level)
Signature · 1 line
2.29.0
#1 lore raw
Quoted 34 lines · Kent Gibson

Add GPIO_V2_LINE_FLAG_EDGE_BOTH macro and use it in edge_irq_thread() to improve readability of edge handling cases.

---
 drivers/gpio/gpiolib-cdev.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/gpio/gpiolib-cdev.c +3 -3
index ea787eb3810d..5eb4435afa64 100644
@@ -510,6 +510,8 @@ struct linereq {
        (GPIO_V2_LINE_FLAG_EDGE_RISING | \
         GPIO_V2_LINE_FLAG_EDGE_FALLING)
 
+#define GPIO_V2_LINE_FLAG_EDGE_BOTH GPIO_V2_LINE_EDGE_FLAGS
+
 #define GPIO_V2_LINE_VALID_FLAGS \
        (GPIO_V2_LINE_FLAG_ACTIVE_LOW | \
         GPIO_V2_LINE_DIRECTION_FLAGS | \
@@ -569,8 +571,7 @@ static irqreturn_t edge_irq_thread(int irq, void *p)
        line->timestamp_ns = 0;
 
        eflags = READ_ONCE(line->eflags);
-       if (eflags == (GPIO_V2_LINE_FLAG_EDGE_RISING |
-                      GPIO_V2_LINE_FLAG_EDGE_FALLING)) {
+       if (eflags == GPIO_V2_LINE_FLAG_EDGE_BOTH) {
                int level = gpiod_get_value_cansleep(line->desc);
 
                if (level)
--
Quoted 2 lines

2.29.0

Applied, thanks!

Bartosz