Skip to contentSkip to conversation

gpio: sim: Deactivate device in reversed order

PATCH In review Andy Shevchenko 2 participants 4 messages Mar 9, 2023 – Mar 10, 2023 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 gpio: sim: Deactivate device in reversed order

Run the steps to deactivate device in the reserved order to what it has been done in gpio_sim_device_activate_unlocked().

---
 drivers/gpio/gpio-sim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-sim.c +1 -1
index e5dfd636c63c..a1c8702f362c 100644
@@ -953,9 +953,9 @@ static void gpio_sim_device_deactivate_unlocked(struct gpio_sim_device *dev)
 
 	swnode = dev_fwnode(&dev->pdev->dev);
 	platform_device_unregister(dev->pdev);
+	gpio_sim_remove_hogs(dev);
 	gpio_sim_remove_swnode_recursive(swnode);
 	dev->pdev = NULL;
-	gpio_sim_remove_hogs(dev);
 }
 
 static ssize_t
Signature · 1 line
2.39.1
#1 lore raw

PATCH 2/2 gpio: sim: Print boolean as unsigned integer

Print boolean as unsigned integer instead of using %c and manually converting to a character.

---
 drivers/gpio/gpio-sim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-sim.c +1 -1
index a1c8702f362c..5ac1de5db751 100644
@@ -684,7 +684,7 @@ gpio_sim_device_config_live_show(struct config_item *item, char *page)
 	live = gpio_sim_device_is_live_unlocked(dev);
 	mutex_unlock(&dev->lock);
 
-	return sprintf(page, "%c\n", live ? '1' : '0');
+	return sprintf(page, "%u\n", live);
 }
 
 static char **gpio_sim_make_line_names(struct gpio_sim_bank *bank,
Signature · 1 line
2.39.1
#2 lore raw

Re: [PATCH v1 2/2] gpio: sim: Print boolean as unsigned integer

Quoted 23 lines · Andy Shevchenko

Print boolean as unsigned integer instead of using %c and manually converting to a character.

---
 drivers/gpio/gpio-sim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-sim.c +1 -2
index a1c8702f362c..5ac1de5db751 100644
@@ -684,7 +684,7 @@ gpio_sim_device_config_live_show(struct config_item *item, char *page)
        live = gpio_sim_device_is_live_unlocked(dev);
        mutex_unlock(&dev->lock);
 
-       return sprintf(page, "%c\n", live ? '1' : '0');
+       return sprintf(page, "%u\n", live);
 }
 
 static char **gpio_sim_make_line_names(struct gpio_sim_bank *bank,
--
Quoted 2 lines

2.39.1

Sorry but NACK. At first glance the current version is more readable. With the one you're proposing, I need to look at the type of "live" to understand what it will print.

Bart

#3 lore raw
In reply to Andy Shevchenko
Quoted 25 lines · Andy Shevchenko

Run the steps to deactivate device in the reserved order to what it has been done in gpio_sim_device_activate_unlocked().

---
 drivers/gpio/gpio-sim.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpio/gpio-sim.c +1 -2
index e5dfd636c63c..a1c8702f362c 100644
@@ -953,9 +953,9 @@ static void gpio_sim_device_deactivate_unlocked(struct gpio_sim_device *dev)
 
        swnode = dev_fwnode(&dev->pdev->dev);
        platform_device_unregister(dev->pdev);
+       gpio_sim_remove_hogs(dev);
        gpio_sim_remove_swnode_recursive(swnode);
        dev->pdev = NULL;
-       gpio_sim_remove_hogs(dev);
 }
 
 static ssize_t
--
Quoted 2 lines

2.39.1

Meh, doesn't really fix any problem but applied anyway for consistency.

Thanks,
Bart