diff mbox series

[v1,06/16] gpio: adnp: Utilize helpers from string_choices.h

Message ID 20230306195556.55475-7-andriy.shevchenko@linux.intel.com
State New
Headers show
Series gpio: Use string_choices.h | expand

Commit Message

Andy Shevchenko March 6, 2023, 7:55 p.m. UTC
There are a few helpers available to convert a boolean variable
to the dedicated string literals depending on the application.
Use them in the driver.

While at, utilize specifier field for padding the strings where
it's required.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpio-adnp.c | 24 ++++++------------------
 1 file changed, 6 insertions(+), 18 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c
index a6439e3daff0..823cad855ee8 100644
--- a/drivers/gpio/gpio-adnp.c
+++ b/drivers/gpio/gpio-adnp.c
@@ -11,6 +11,7 @@ 
 #include <linux/property.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 
 #define GPIO_DDR(gpio) (0x00 << (gpio)->reg_shift)
 #define GPIO_PLR(gpio) (0x01 << (gpio)->reg_shift)
@@ -211,25 +212,12 @@  static void adnp_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
 
 		for (j = 0; j < 8; j++) {
 			unsigned int bit = (i << adnp->reg_shift) + j;
-			const char *direction = "input ";
-			const char *level = "low ";
-			const char *interrupt = "disabled";
-			const char *pending = "";
 
-			if (ddr & BIT(j))
-				direction = "output";
-
-			if (plr & BIT(j))
-				level = "high";
-
-			if (ier & BIT(j))
-				interrupt = "enabled ";
-
-			if (isr & BIT(j))
-				pending = "pending";
-
-			seq_printf(s, "%2u: %s %s IRQ %s %s\n", bit,
-				   direction, level, interrupt, pending);
+			seq_printf(s, "%2u: %-6.6s %-4.4s IRQ %-8.8s %s\n", bit,
+				   str_output_input(ddr & BIT(j)),
+				   str_high_low(plr & BIT(j)),
+				   str_enabled_disabled(ier & BIT(j)),
+				   (isr & BIT(j)) ? "pending" : "");
 		}
 	}