[PATCH v1 10/16] gpio: mvebu: Utilize helpers from string_choices.h

From: Andy Shevchenko
Date: Mon Mar 06 2023 - 14:56:04 EST


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@xxxxxxxxxxxxxxx>
---
drivers/gpio/gpio-mvebu.c | 27 ++++++++++++---------------
1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/gpio/gpio-mvebu.c b/drivers/gpio/gpio-mvebu.c
index a68f682aec01..f2bbe928577c 100644
--- a/drivers/gpio/gpio-mvebu.c
+++ b/drivers/gpio/gpio-mvebu.c
@@ -48,6 +48,7 @@
#include <linux/pwm.h>
#include <linux/regmap.h>
#include <linux/slab.h>
+#include <linux/string_choices.h>

/*
* GPIO unit register offsets.
@@ -897,32 +898,28 @@ static void mvebu_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
lvl_msk = mvebu_gpio_read_level_mask(mvchip);

for_each_requested_gpio(chip, i, label) {
- u32 msk;
- bool is_out;
+ u32 msk = BIT(i);

- msk = BIT(i);
- is_out = !(io_conf & msk);
+ seq_printf(s, " gpio-%-3d (%-20.20s) %-3.3s ", chip->base + i, label,
+ str_in_out(io_conf & msk));

- seq_printf(s, " gpio-%-3d (%-20.20s)", chip->base + i, label);
-
- if (is_out) {
- seq_printf(s, " out %s %s\n",
- out & msk ? "hi" : "lo",
+ if (!(io_conf & msk)) {
+ seq_printf(s, "%-2.2s %s\n", str_hi_lo(out & msk),
blink & msk ? "(blink )" : "");
continue;
}

- seq_printf(s, " in %s (act %s) - IRQ",
- (data_in ^ in_pol) & msk ? "hi" : "lo",
- in_pol & msk ? "lo" : "hi");
+ seq_printf(s, "%-2.2s (act %-2.2s) - IRQ ",
+ str_hi_lo((data_in ^ in_pol) & msk),
+ str_lo_hi(in_pol & msk));
if (!((edg_msk | lvl_msk) & msk)) {
- seq_puts(s, " disabled\n");
+ seq_puts(s, "disabled\n");
continue;
}
if (edg_msk & msk)
- seq_puts(s, " edge ");
+ seq_puts(s, "edge ");
if (lvl_msk & msk)
- seq_puts(s, " level");
+ seq_puts(s, "level");
seq_printf(s, " (%s)\n", cause & msk ? "pending" : "clear ");
}
}
--
2.39.1