[PATCH v1 06/16] gpio: adnp: Utilize helpers from string_choices.h
Andy Shevchenko
andriy.shevchenko at linux.intel.com
Mon Mar 6 11:55:46 PST 2023
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 at linux.intel.com>
---
drivers/gpio/gpio-adnp.c | 24 ++++++------------------
1 file changed, 6 insertions(+), 18 deletions(-)
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" : "");
}
}
--
2.39.1
More information about the linux-arm-kernel
mailing list