[PATCH v1 12/16] gpio: stmpe: Utilize helpers from string_choices.h

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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-stmpe.c | 19 ++++++++-----------
 1 file changed, 8 insertions(+), 11 deletions(-)

diff --git a/drivers/gpio/gpio-stmpe.c b/drivers/gpio/gpio-stmpe.c
index 0fa4f0a93378..ca8a98b252c2 100644
--- a/drivers/gpio/gpio-stmpe.c
+++ b/drivers/gpio/gpio-stmpe.c
@@ -14,6 +14,7 @@
 #include <linux/mfd/stmpe.h>
 #include <linux/seq_file.h>
 #include <linux/bitops.h>
+#include <linux/string_choices.h>
 
 /*
  * These registers are modified under the irq bus lock and cached to avoid
@@ -264,12 +265,12 @@ static void stmpe_dbg_show_one(struct seq_file *s,
 	ret = stmpe_reg_read(stmpe, dir_reg);
 	if (ret < 0)
 		return;
-	dir = !!(ret & mask);
 
+	dir = !!(ret & mask);
+	seq_printf(s, " gpio-%-3d (%-20.20s) %-3.3s %-2.2s ", gpio,
+		   label ?: "(none)", str_out_in(dir), str_hi_lo(val));
 	if (dir) {
-		seq_printf(s, " gpio-%-3d (%-20.20s) out %s",
-			   gpio, label ?: "(none)",
-			   val ? "hi" : "lo");
+		seq_putc(s, '\n');
 	} else {
 		u8 edge_det_reg;
 		u8 rise_reg;
@@ -336,11 +337,9 @@ static void stmpe_dbg_show_one(struct seq_file *s,
 			return;
 		irqen = !!(ret & mask);
 
-		seq_printf(s, " gpio-%-3d (%-20.20s) in  %s %13s %13s %25s %25s",
-			   gpio, label ?: "(none)",
-			   val ? "hi" : "lo",
+		seq_printf(s, "%13s IRQ-%9s %25s %25s\n",
 			   edge_det_values[edge_det],
-			   irqen ? "IRQ-enabled" : "IRQ-disabled",
+			   str_enabled_disabled(irqen),
 			   rise_values[rise],
 			   fall_values[fall]);
 	}
@@ -351,10 +350,8 @@ static void stmpe_dbg_show(struct seq_file *s, struct gpio_chip *gc)
 	unsigned i;
 	unsigned gpio = gc->base;
 
-	for (i = 0; i < gc->ngpio; i++, gpio++) {
+	for (i = 0; i < gc->ngpio; i++, gpio++)
 		stmpe_dbg_show_one(s, gc, i, gpio);
-		seq_putc(s, '\n');
-	}
 }
 
 static struct irq_chip stmpe_gpio_irq_chip = {
-- 
2.39.1




[Index of Archives]     [Linux SPI]     [Linux Kernel]     [Linux ARM (vger)]     [Linux ARM MSM]     [Linux Omap]     [Linux Arm]     [Linux Tegra]     [Fedora ARM]     [Linux for Samsung SOC]     [eCos]     [Linux Fastboot]     [Gcc Help]     [Git]     [DCCP]     [IETF Announce]     [Security]     [Linux MIPS]     [Yosemite Campsites]

  Powered by Linux