Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

gpio: Use str_enable_disable-like helpers

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>

authored by

Krzysztof Kozlowski and committed by
Bartosz Golaszewski
de454ac4 2014c95a

+23 -14
+2 -1
drivers/gpio/gpio-brcmstb.c
··· 9 9 #include <linux/irqchip/chained_irq.h> 10 10 #include <linux/interrupt.h> 11 11 #include <linux/platform_device.h> 12 + #include <linux/string_choices.h> 12 13 13 14 enum gio_reg_index { 14 15 GIO_REG_ODEN = 0, ··· 225 224 ret = disable_irq_wake(priv->parent_wake_irq); 226 225 if (ret) 227 226 dev_err(&priv->pdev->dev, "failed to %s wake-up interrupt\n", 228 - enable ? "enable" : "disable"); 227 + str_enable_disable(enable)); 229 228 return ret; 230 229 } 231 230
+2 -1
drivers/gpio/gpio-crystalcove.c
··· 15 15 #include <linux/platform_device.h> 16 16 #include <linux/regmap.h> 17 17 #include <linux/seq_file.h> 18 + #include <linux/string_choices.h> 18 19 #include <linux/types.h> 19 20 20 21 #define CRYSTALCOVE_GPIO_NUM 16 ··· 318 317 offset = gpio % 8; 319 318 seq_printf(s, " gpio-%-2d %s %s %s %s ctlo=%2x,%s %s %s\n", 320 319 gpio, ctlo & CTLO_DIR_OUT ? "out" : "in ", 321 - ctli & 0x1 ? "hi" : "lo", 320 + str_hi_lo(ctli & 0x1), 322 321 ctli & CTLI_INTCNT_NE ? "fall" : " ", 323 322 ctli & CTLI_INTCNT_PE ? "rise" : " ", 324 323 ctlo,
+2 -1
drivers/gpio/gpio-grgpio.c
··· 30 30 #include <linux/platform_device.h> 31 31 #include <linux/slab.h> 32 32 #include <linux/spinlock.h> 33 + #include <linux/string_choices.h> 33 34 34 35 #define GRGPIO_MAX_NGPIO 32 35 36 ··· 439 438 } 440 439 441 440 dev_info(dev, "regs=0x%p, base=%d, ngpio=%d, irqs=%s\n", 442 - priv->regs, gc->base, gc->ngpio, priv->domain ? "on" : "off"); 441 + priv->regs, gc->base, gc->ngpio, str_on_off(priv->domain)); 443 442 444 443 return 0; 445 444 }
+4 -3
drivers/gpio/gpio-mvebu.c
··· 49 49 #include <linux/pwm.h> 50 50 #include <linux/regmap.h> 51 51 #include <linux/slab.h> 52 + #include <linux/string_choices.h> 52 53 53 54 /* 54 55 * GPIO unit register offsets. ··· 908 907 909 908 if (is_out) { 910 909 seq_printf(s, " out %s %s\n", 911 - out & msk ? "hi" : "lo", 910 + str_hi_lo(out & msk), 912 911 blink & msk ? "(blink )" : ""); 913 912 continue; 914 913 } 915 914 916 915 seq_printf(s, " in %s (act %s) - IRQ", 917 - (data_in ^ in_pol) & msk ? "hi" : "lo", 918 - in_pol & msk ? "lo" : "hi"); 916 + str_hi_lo((data_in ^ in_pol) & msk), 917 + str_lo_hi(in_pol & msk)); 919 918 if (!((edg_msk | lvl_msk) & msk)) { 920 919 seq_puts(s, " disabled\n"); 921 920 continue;
+2 -1
drivers/gpio/gpio-nomadik.c
··· 30 30 #include <linux/reset.h> 31 31 #include <linux/seq_file.h> 32 32 #include <linux/slab.h> 33 + #include <linux/string_choices.h> 33 34 #include <linux/types.h> 34 35 35 36 #include <linux/gpio/gpio-nomadik.h> ··· 431 430 seq_printf(s, " gpio-%-3d (%-20.20s) out %s %s", 432 431 gpio, 433 432 label ?: "(none)", 434 - data_out ? "hi" : "lo", 433 + str_hi_lo(data_out), 435 434 (mode < 0) ? "unknown" : modes[mode]); 436 435 } else { 437 436 int irq = chip->to_irq(chip, offset);
+3 -3
drivers/gpio/gpio-stmpe.c
··· 15 15 #include <linux/platform_device.h> 16 16 #include <linux/seq_file.h> 17 17 #include <linux/slab.h> 18 + #include <linux/string_choices.h> 18 19 19 20 /* 20 21 * These registers are modified under the irq bus lock and cached to avoid ··· 274 273 275 274 if (dir) { 276 275 seq_printf(s, " gpio-%-3d (%-20.20s) out %s", 277 - gpio, label ?: "(none)", 278 - val ? "hi" : "lo"); 276 + gpio, label ?: "(none)", str_hi_lo(val)); 279 277 } else { 280 278 u8 edge_det_reg; 281 279 u8 rise_reg; ··· 343 343 344 344 seq_printf(s, " gpio-%-3d (%-20.20s) in %s %13s %13s %25s %25s", 345 345 gpio, label ?: "(none)", 346 - val ? "hi" : "lo", 346 + str_hi_lo(val), 347 347 edge_det_values[edge_det], 348 348 irqen ? "IRQ-enabled" : "IRQ-disabled", 349 349 rise_values[rise],
+2 -1
drivers/gpio/gpio-wcove.c
··· 15 15 #include <linux/platform_device.h> 16 16 #include <linux/regmap.h> 17 17 #include <linux/seq_file.h> 18 + #include <linux/string_choices.h> 18 19 19 20 /* 20 21 * Whiskey Cove PMIC has 13 physical GPIO pins divided into 3 banks: ··· 394 393 395 394 seq_printf(s, " gpio-%-2d %s %s %s %s ctlo=%2x,%s %s\n", 396 395 gpio, ctlo & CTLO_DIR_OUT ? "out" : "in ", 397 - ctli & 0x1 ? "hi" : "lo", 396 + str_hi_lo(ctli & 0x1), 398 397 ctli & CTLI_INTCNT_NE ? "fall" : " ", 399 398 ctli & CTLI_INTCNT_PE ? "rise" : " ", 400 399 ctlo,
+2 -1
drivers/gpio/gpio-wm831x.c
··· 16 16 #include <linux/mfd/core.h> 17 17 #include <linux/platform_device.h> 18 18 #include <linux/seq_file.h> 19 + #include <linux/string_choices.h> 19 20 20 21 #include <linux/mfd/wm831x/core.h> 21 22 #include <linux/mfd/wm831x/pdata.h> ··· 235 234 seq_printf(s, " %s %s %s %s%s\n" 236 235 " %s%s (0x%4x)\n", 237 236 reg & WM831X_GPN_DIR ? "in" : "out", 238 - wm831x_gpio_get(chip, i) ? "high" : "low", 237 + str_high_low(wm831x_gpio_get(chip, i)), 239 238 pull, 240 239 powerdomain, 241 240 reg & WM831X_GPN_POL ? "" : " inverted",
+2 -1
drivers/gpio/gpio-xra1403.c
··· 13 13 #include <linux/mutex.h> 14 14 #include <linux/seq_file.h> 15 15 #include <linux/spi/spi.h> 16 + #include <linux/string_choices.h> 16 17 #include <linux/regmap.h> 17 18 18 19 /* XRA1403 registers */ ··· 141 140 seq_printf(s, " gpio-%-3d (%-12s) %s %s\n", 142 141 chip->base + i, label, 143 142 (gcr & BIT(i)) ? "in" : "out", 144 - (gsr & BIT(i)) ? "hi" : "lo"); 143 + str_hi_lo(gsr & BIT(i))); 145 144 } 146 145 } 147 146 #else
+2 -1
drivers/gpio/gpiolib.c
··· 26 26 #include <linux/slab.h> 27 27 #include <linux/srcu.h> 28 28 #include <linux/string.h> 29 + #include <linux/string_choices.h> 29 30 30 31 #include <linux/gpio.h> 31 32 #include <linux/gpio/driver.h> ··· 5008 5007 seq_printf(s, " gpio-%-3u (%-20.20s|%-20.20s) %s %s %s%s\n", 5009 5008 gpio, desc->name ?: "", gpiod_get_label(desc), 5010 5009 is_out ? "out" : "in ", 5011 - value >= 0 ? (value ? "hi" : "lo") : "? ", 5010 + value >= 0 ? str_hi_lo(value) : "? ", 5012 5011 is_irq ? "IRQ " : "", 5013 5012 active_low ? "ACTIVE LOW" : ""); 5014 5013 } else if (desc->name) {