Skip to contentSkip to conversation

gpiolib: Make use of assign_bit() API (part 2)

PATCH In review Andy Shevchenko 3 participants 3 messages May 18, 2021 – May 21, 2021 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpiolib: Make use of assign_bit() API (part 2)

We have for some time the assign_bit() API to replace open coded

	if (foo)
		set_bit(n, bar);
	else
		clear_bit(n, bar);

Use this API in GPIO library code.

---
 drivers/gpio/gpiolib-sysfs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpio/gpiolib-sysfs.c +1 -4
index 41b3b782bf3f..7c5afd999210 100644
@@ -312,10 +312,7 @@ static int gpio_sysfs_set_active_low(struct device *dev, int value)
 	if (!!test_bit(FLAG_ACTIVE_LOW, &desc->flags) == !!value)
 		return 0;
 
-	if (value)
-		set_bit(FLAG_ACTIVE_LOW, &desc->flags);
-	else
-		clear_bit(FLAG_ACTIVE_LOW, &desc->flags);
+	assign_bit(FLAG_ACTIVE_LOW, &desc->flags, value);
 
 	/* reconfigure poll(2) support if enabled on one edge only */
 	if (flags == GPIO_IRQF_TRIGGER_FALLING ||
Signature · 1 line
2.30.2
#2 lore raw
In reply to Andy Shevchenko
Quoted 32 lines · Andy Shevchenko

We have for some time the assign_bit() API to replace open coded

        if (foo)
                set_bit(n, bar);
        else
                clear_bit(n, bar);

Use this API in GPIO library code.

---
 drivers/gpio/gpiolib-sysfs.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)
drivers/gpio/gpiolib-sysfs.c +1 -5
index 41b3b782bf3f..7c5afd999210 100644
@@ -312,10 +312,7 @@ static int gpio_sysfs_set_active_low(struct device *dev, int value)
        if (!!test_bit(FLAG_ACTIVE_LOW, &desc->flags) == !!value)
                return 0;
 
-       if (value)
-               set_bit(FLAG_ACTIVE_LOW, &desc->flags);
-       else
-               clear_bit(FLAG_ACTIVE_LOW, &desc->flags);
+       assign_bit(FLAG_ACTIVE_LOW, &desc->flags, value);
 
        /* reconfigure poll(2) support if enabled on one edge only */
        if (flags == GPIO_IRQF_TRIGGER_FALLING ||
--
Quoted 2 lines

2.30.2

Patch applied, thanks!

Bartosz