]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gpio: Use str_enable_disable-like helpers
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tue, 14 Jan 2025 19:14:38 +0000 (20:14 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Mon, 3 Feb 2025 08:12:44 +0000 (09:12 +0100)
Replace ternary (condition ? "enable" : "disable") syntax with helpers
from string_choices.h because:
1. Simple function call with one argument is easier to read.  Ternary
   operator has three arguments and with wrapping might lead to quite
   long code.
2. Is slightly shorter thus also easier to read.
3. It brings uniformity in the text - same string.
4. Allows deduping by the linker, which results in a smaller binary
   file.

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Acked-by: Doug Berger <opendmb@gmail.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Link: https://lore.kernel.org/r/20250114191438.857656-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
drivers/gpio/gpio-brcmstb.c
drivers/gpio/gpio-crystalcove.c
drivers/gpio/gpio-grgpio.c
drivers/gpio/gpio-mvebu.c
drivers/gpio/gpio-nomadik.c
drivers/gpio/gpio-stmpe.c
drivers/gpio/gpio-wcove.c
drivers/gpio/gpio-wm831x.c
drivers/gpio/gpio-xra1403.c
drivers/gpio/gpiolib.c

index 491b529d25f8d35ec33f015f87586d784dcac7c6..ca3472977431e42f66e727a99ef4894451ff9d8e 100644 (file)
@@ -9,6 +9,7 @@
 #include <linux/irqchip/chained_irq.h>
 #include <linux/interrupt.h>
 #include <linux/platform_device.h>
+#include <linux/string_choices.h>
 
 enum gio_reg_index {
        GIO_REG_ODEN = 0,
@@ -224,7 +225,7 @@ static int brcmstb_gpio_priv_set_wake(struct brcmstb_gpio_priv *priv,
                ret = disable_irq_wake(priv->parent_wake_irq);
        if (ret)
                dev_err(&priv->pdev->dev, "failed to %s wake-up interrupt\n",
-                               enable ? "enable" : "disable");
+                       str_enable_disable(enable));
        return ret;
 }
 
index 25db014494a4de9bb8c44d0b2bd39d8786c3bb59..56effd0f50c763e38ed0a07799f34c8cf4176d4f 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/seq_file.h>
+#include <linux/string_choices.h>
 #include <linux/types.h>
 
 #define CRYSTALCOVE_GPIO_NUM   16
@@ -317,7 +318,7 @@ static void crystalcove_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip
                offset = gpio % 8;
                seq_printf(s, " gpio-%-2d %s %s %s %s ctlo=%2x,%s %s %s\n",
                           gpio, ctlo & CTLO_DIR_OUT ? "out" : "in ",
-                          ctli & 0x1 ? "hi" : "lo",
+                          str_hi_lo(ctli & 0x1),
                           ctli & CTLI_INTCNT_NE ? "fall" : "    ",
                           ctli & CTLI_INTCNT_PE ? "rise" : "    ",
                           ctlo,
index 169f33c41c5925ca97282cb00cf6f6e5180baf06..30a0522ae735ff51577342313beb3a3b5cbb3357 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/platform_device.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/string_choices.h>
 
 #define GRGPIO_MAX_NGPIO 32
 
@@ -438,7 +439,7 @@ static int grgpio_probe(struct platform_device *ofdev)
        }
 
        dev_info(dev, "regs=0x%p, base=%d, ngpio=%d, irqs=%s\n",
-                priv->regs, gc->base, gc->ngpio, priv->domain ? "on" : "off");
+                priv->regs, gc->base, gc->ngpio, str_on_off(priv->domain));
 
        return 0;
 }
index 5ffb332e98493582e4b51645688f67a7ac0df60d..363bad286c329e21ad4573568f89befa9655a9c1 100644 (file)
@@ -49,6 +49,7 @@
 #include <linux/pwm.h>
 #include <linux/regmap.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 
 /*
  * GPIO unit register offsets.
@@ -907,14 +908,14 @@ static void mvebu_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
 
                if (is_out) {
                        seq_printf(s, " out %s %s\n",
-                                  out & msk ? "hi" : "lo",
+                                  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");
+                          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");
                        continue;
index 836f1cc760c26d672bee7d79b37b362185c40a99..fa19a44943fd7ae167079b34a48f669a38ec4ae7 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/reset.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 #include <linux/types.h>
 
 #include <linux/gpio/gpio-nomadik.h>
@@ -430,7 +431,7 @@ void nmk_gpio_dbg_show_one(struct seq_file *s, struct pinctrl_dev *pctldev,
                seq_printf(s, " gpio-%-3d (%-20.20s) out %s           %s",
                           gpio,
                           label ?: "(none)",
-                          data_out ? "hi" : "lo",
+                          str_hi_lo(data_out),
                           (mode < 0) ? "unknown" : modes[mode]);
        } else {
                int irq = chip->to_irq(chip, offset);
index 75a3633ceddbb8fcc7a2d51dfb3816401777819c..2e22e1eb7495ba6c1f326f1f1c3d001a8212548e 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/platform_device.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 
 /*
  * These registers are modified under the irq bus lock and cached to avoid
@@ -273,8 +274,7 @@ static void stmpe_dbg_show_one(struct seq_file *s,
 
        if (dir) {
                seq_printf(s, " gpio-%-3d (%-20.20s) out %s",
-                          gpio, label ?: "(none)",
-                          val ? "hi" : "lo");
+                          gpio, label ?: "(none)", str_hi_lo(val));
        } else {
                u8 edge_det_reg;
                u8 rise_reg;
@@ -343,7 +343,7 @@ static void stmpe_dbg_show_one(struct seq_file *s,
 
                seq_printf(s, " gpio-%-3d (%-20.20s) in  %s %13s %13s %25s %25s",
                           gpio, label ?: "(none)",
-                          val ? "hi" : "lo",
+                          str_hi_lo(val),
                           edge_det_values[edge_det],
                           irqen ? "IRQ-enabled" : "IRQ-disabled",
                           rise_values[rise],
index 94ca9d03c0949453abf3ad82e013698a7a97ffda..1ec24f6f9300f33f5b3f0f8deb539e08392b8188 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
 #include <linux/seq_file.h>
+#include <linux/string_choices.h>
 
 /*
  * Whiskey Cove PMIC has 13 physical GPIO pins divided into 3 banks:
@@ -393,7 +394,7 @@ static void wcove_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
 
                seq_printf(s, " gpio-%-2d %s %s %s %s ctlo=%2x,%s %s\n",
                           gpio, ctlo & CTLO_DIR_OUT ? "out" : "in ",
-                          ctli & 0x1 ? "hi" : "lo",
+                          str_hi_lo(ctli & 0x1),
                           ctli & CTLI_INTCNT_NE ? "fall" : "    ",
                           ctli & CTLI_INTCNT_PE ? "rise" : "    ",
                           ctlo,
index f7d5120ff8f13e80dcc39f401426fd5b0b58082a..61bb83a1e8ae4de29c57066944ce25beacdb454c 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/mfd/core.h>
 #include <linux/platform_device.h>
 #include <linux/seq_file.h>
+#include <linux/string_choices.h>
 
 #include <linux/mfd/wm831x/core.h>
 #include <linux/mfd/wm831x/pdata.h>
@@ -234,7 +235,7 @@ static void wm831x_gpio_dbg_show(struct seq_file *s, struct gpio_chip *chip)
                seq_printf(s, " %s %s %s %s%s\n"
                           "                                  %s%s (0x%4x)\n",
                           reg & WM831X_GPN_DIR ? "in" : "out",
-                          wm831x_gpio_get(chip, i) ? "high" : "low",
+                          str_high_low(wm831x_gpio_get(chip, i)),
                           pull,
                           powerdomain,
                           reg & WM831X_GPN_POL ? "" : " inverted",
index dc2710c21c508ae53ba442b336726a96323af77b..842cf875bb92036616adc63748dda85c47af544c 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/mutex.h>
 #include <linux/seq_file.h>
 #include <linux/spi/spi.h>
+#include <linux/string_choices.h>
 #include <linux/regmap.h>
 
 /* XRA1403 registers */
@@ -140,7 +141,7 @@ static void xra1403_dbg_show(struct seq_file *s, struct gpio_chip *chip)
                seq_printf(s, " gpio-%-3d (%-12s) %s %s\n",
                           chip->base + i, label,
                           (gcr & BIT(i)) ? "in" : "out",
-                          (gsr & BIT(i)) ? "hi" : "lo");
+                          str_hi_lo(gsr & BIT(i)));
        }
 }
 #else
index 679ed764cb143c4b3357106de1570e8d38441372..be335158350896e7867fc0d5cb0da9c953ea52ff 100644 (file)
@@ -26,6 +26,7 @@
 #include <linux/slab.h>
 #include <linux/srcu.h>
 #include <linux/string.h>
+#include <linux/string_choices.h>
 
 #include <linux/gpio.h>
 #include <linux/gpio/driver.h>
@@ -5007,7 +5008,7 @@ static void gpiolib_dbg_show(struct seq_file *s, struct gpio_device *gdev)
                        seq_printf(s, " gpio-%-3u (%-20.20s|%-20.20s) %s %s %s%s\n",
                                   gpio, desc->name ?: "", gpiod_get_label(desc),
                                   is_out ? "out" : "in ",
-                                  value >= 0 ? (value ? "hi" : "lo") : "?  ",
+                                  value >= 0 ? str_hi_lo(value) : "?  ",
                                   is_irq ? "IRQ " : "",
                                   active_low ? "ACTIVE LOW" : "");
                } else if (desc->name) {