]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
pinctrl: Use str_enable_disable-like helpers
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tue, 14 Jan 2025 20:36:02 +0000 (21:36 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Wed, 15 Jan 2025 11:52:26 +0000 (12:52 +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.

Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: Antonio Borneo <antonio.borneo@foss.st.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/20250114203602.1013275-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
14 files changed:
drivers/pinctrl/bcm/pinctrl-nsp-gpio.c
drivers/pinctrl/cirrus/pinctrl-lochnagar.c
drivers/pinctrl/nomadik/pinctrl-abx500.c
drivers/pinctrl/nomadik/pinctrl-nomadik.c
drivers/pinctrl/pinctrl-amd.c
drivers/pinctrl/pinctrl-gemini.c
drivers/pinctrl/pinctrl-stmfx.c
drivers/pinctrl/qcom/pinctrl-msm.c
drivers/pinctrl/qcom/pinctrl-spmi-gpio.c
drivers/pinctrl/qcom/pinctrl-spmi-mpp.c
drivers/pinctrl/qcom/pinctrl-ssbi-gpio.c
drivers/pinctrl/qcom/pinctrl-ssbi-mpp.c
drivers/pinctrl/samsung/pinctrl-exynos.c
drivers/pinctrl/stm32/pinctrl-stm32.c

index 84af6aae36d180edca40890464cc7e605504d807..a96be8f244e0c1cf91515c5e878899d5fbce8e5e 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/pinctrl/pinctrl.h>
 #include <linux/platform_device.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 
 #include "../pinctrl-utils.h"
 
@@ -254,7 +255,7 @@ static int nsp_gpio_irq_set_type(struct irq_data *d, unsigned int type)
        raw_spin_unlock_irqrestore(&chip->lock, flags);
 
        dev_dbg(chip->dev, "gpio:%u level_low:%s falling:%s\n", gpio,
-               level_low ? "true" : "false", falling ? "true" : "false");
+               str_true_false(level_low), str_true_false(falling));
        return 0;
 }
 
index 014297a3fbd28725eaf4a5f1d24f18476753f581..0f32866a4aef2c84b99f3c56374d8dfd9150b024 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/of.h>
 #include <linux/platform_device.h>
 #include <linux/regmap.h>
+#include <linux/string_choices.h>
 
 #include <linux/pinctrl/consumer.h>
 #include <linux/pinctrl/pinconf-generic.h>
@@ -1068,7 +1069,7 @@ static void lochnagar_gpio_set(struct gpio_chip *chip,
        value = !!value;
 
        dev_dbg(priv->dev, "Set GPIO %s to %s\n",
-               pin->name, value ? "high" : "low");
+               pin->name, str_high_low(value));
 
        switch (pin->type) {
        case LN_PTYPE_MUX:
index 4ce2e35a6373358e6ccf8109ebb1aed43df21ade..8cd4ba5cf0bdae7a6ca9b0b289aec5ed40e8f9e0 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/property.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 #include <linux/types.h>
 
 #include <linux/mfd/abx500.h>
@@ -496,7 +497,7 @@ static void abx500_gpio_dbg_show_one(struct seq_file *s,
 
                seq_printf(s, " %-9s", pull_up_down[pd]);
        } else
-               seq_printf(s, " %-9s", chip->get(chip, offset) ? "hi" : "lo");
+               seq_printf(s, " %-9s", str_hi_lo(chip->get(chip, offset)));
 
        mode = abx500_get_mode(pctldev, chip, offset);
 
@@ -865,7 +866,7 @@ static int abx500_pin_config_set(struct pinctrl_dev *pctldev,
                        pin, configs[i],
                        (param == PIN_CONFIG_OUTPUT) ? "output " : "input",
                        (param == PIN_CONFIG_OUTPUT) ?
-                       (argument ? "high" : "low") :
+                       str_high_low(argument) :
                        (argument ? "pull up" : "pull down"));
 
                /* on ABx500, there is no GPIO0, so adjust the offset */
index dcc662be080004c87141938a7f2d27b20d46f28a..8940e04fcf4cc4898cda5a5734574bfed6a175c6 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/string_choices.h>
 #include <linux/types.h>
 
 /* Since we request GPIOs from ourself */
@@ -1125,15 +1126,15 @@ static int nmk_pin_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
                                slpm_pull ? pullnames[pull] : "same",
                                slpm_output ? (output ? "output" : "input")
                                : "same",
-                               slpm_val ? (val ? "high" : "low") : "same");
+                               slpm_val ? str_high_low(val) : "same");
                }
 
                dev_dbg(nmk_chip->chip.parent,
                        "pin %d [%#lx]: pull %s, slpm %s (%s%s), lowemi %s\n",
                        pin, cfg, pullnames[pull], slpmnames[slpm],
                        output ? "output " : "input",
-                       output ? (val ? "high" : "low") : "",
-                       lowemi ? "on" : "off");
+                       output ? str_high_low(val) : "",
+                       str_on_off(lowemi));
 
                ret = clk_enable(nmk_chip->clk);
                if (ret)
index a03feb5a60dda80f289c21730ebded14928f0d75..1d7fdcdec4c8551d5f9bf4ed9e59d389ef7a08e4 100644 (file)
@@ -30,6 +30,7 @@
 #include <linux/pinctrl/pinconf.h>
 #include <linux/pinctrl/pinconf-generic.h>
 #include <linux/pinctrl/pinmux.h>
+#include <linux/string_choices.h>
 #include <linux/suspend.h>
 
 #include "core.h"
@@ -458,7 +459,7 @@ static int amd_gpio_irq_set_wake(struct irq_data *d, unsigned int on)
 
        if (err)
                dev_err(&gpio_dev->pdev->dev, "failed to %s wake-up interrupt\n",
-                       on ? "enable" : "disable");
+                       str_enable_disable(on));
 
        return 0;
 }
index 631612539af73f0479a9a0ad77f945b29b57d4cb..e9f61927858d58395b3b47a5bca43bd9a4511ca6 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/regmap.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 
 #include <linux/pinctrl/machine.h>
 #include <linux/pinctrl/pinconf-generic.h>
@@ -2237,7 +2238,7 @@ static int gemini_pmx_set_mux(struct pinctrl_dev *pctldev,
                                "pin group %s could not be %s: "
                                "probably a hardware limitation\n",
                                gemini_padgroups[i],
-                               enabled ? "enabled" : "disabled");
+                               str_enabled_disabled(enabled));
                        dev_err(pmx->dev,
                                "GLOBAL MISC CTRL before: %08x, after %08x, expected %08x\n",
                                before, after, expected);
@@ -2245,7 +2246,7 @@ static int gemini_pmx_set_mux(struct pinctrl_dev *pctldev,
                        dev_dbg(pmx->dev,
                                "padgroup %s %s\n",
                                gemini_padgroups[i],
-                               enabled ? "enabled" : "disabled");
+                               str_enabled_disabled(enabled));
                }
        }
 
@@ -2259,7 +2260,7 @@ static int gemini_pmx_set_mux(struct pinctrl_dev *pctldev,
                                "pin group %s could not be %s: "
                                "probably a hardware limitation\n",
                                gemini_padgroups[i],
-                               enabled ? "enabled" : "disabled");
+                               str_enabled_disabled(enabled));
                        dev_err(pmx->dev,
                                "GLOBAL MISC CTRL before: %08x, after %08x, expected %08x\n",
                                before, after, expected);
@@ -2267,7 +2268,7 @@ static int gemini_pmx_set_mux(struct pinctrl_dev *pctldev,
                        dev_dbg(pmx->dev,
                                "padgroup %s %s\n",
                                gemini_padgroups[i],
-                               enabled ? "enabled" : "disabled");
+                               str_enabled_disabled(enabled));
                }
        }
 
@@ -2588,7 +2589,7 @@ static int gemini_pmx_probe(struct platform_device *pdev)
        tmp = val;
        for_each_set_bit(i, &tmp, PADS_MAXBIT) {
                dev_dbg(dev, "pad group %s %s\n", gemini_padgroups[i],
-                       (val & BIT(i)) ? "enabled" : "disabled");
+                       str_enabled_disabled(val & BIT(i)));
        }
 
        /* Check if flash pin is set */
index 521f6fef0b9f681f1a3fe9d8da92392edcd664c9..aae01120dc5224cbe87e0298e371d73c01cc4158 100644 (file)
@@ -380,7 +380,7 @@ static void stmfx_pinconf_dbg_show(struct pinctrl_dev *pctldev,
                seq_printf(s, "input %s ", str_high_low(val));
                if (type)
                        seq_printf(s, "with internal pull-%s ",
-                                  pupd ? "up" : "down");
+                                  str_up_down(pupd));
                else
                        seq_printf(s, "%s ", pupd ? "floating" : "analog");
        }
index ec913c2e200f5fa584806667b9552b7e284e4fae..47daa47153c970190b0d469dc8d245b3cbeace5e 100644 (file)
@@ -19,6 +19,7 @@
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/string_choices.h>
 
 #include <linux/pinctrl/machine.h>
 #include <linux/pinctrl/pinconf-generic.h>
@@ -714,7 +715,7 @@ static void msm_gpio_dbg_show_one(struct seq_file *s,
        }
 
        seq_printf(s, " %-8s: %-3s", g->grp.name, is_out ? "out" : "in");
-       seq_printf(s, " %-4s func%d", val ? "high" : "low", func);
+       seq_printf(s, " %-4s func%d", str_high_low(val), func);
        seq_printf(s, " %dmA", msm_regval_to_drive(drive));
        if (pctrl->soc->pull_no_keeper)
                seq_printf(s, " %s", pulls_no_keeper[pull]);
index 0c806b8128b63713aeb49863018b655e6f55ec52..c8ce6106607095ef69a9b16e8a740cec4664eed3 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/spmi.h>
+#include <linux/string_choices.h>
 #include <linux/types.h>
 
 #include <linux/pinctrl/pinconf-generic.h>
@@ -702,7 +703,7 @@ static void pmic_gpio_config_dbg_show(struct pinctrl_dev *pctldev,
                else
                        seq_printf(s, " %-4s",
                                        pad->output_enabled ? "out" : "in");
-               seq_printf(s, " %-4s", pad->out_value ? "high" : "low");
+               seq_printf(s, " %-4s", str_high_low(pad->out_value));
                seq_printf(s, " %-7s", pmic_gpio_functions[function]);
                seq_printf(s, " vin-%d", pad->power_source);
                seq_printf(s, " %-27s", biases[pad->pullup]);
index 84de584cf7ebbd35dd3e7aa89d4b971645b02f82..7b28c5fb24029126271078b1f15b598336781b68 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/regmap.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 #include <linux/types.h>
 
 #include <linux/pinctrl/pinconf-generic.h>
@@ -544,7 +545,7 @@ static void pmic_mpp_config_dbg_show(struct pinctrl_dev *pctldev,
                seq_printf(s, " %d", pad->aout_level);
                if (pad->has_pullup)
                        seq_printf(s, " %-8s", biases[pad->pullup]);
-               seq_printf(s, " %-4s", pad->out_value ? "high" : "low");
+               seq_printf(s, " %-4s", str_high_low(pad->out_value));
                if (pad->dtest)
                        seq_printf(s, " dtest%d", pad->dtest);
                if (pad->paired)
index 2225dc49d477c12c0f5e1cbba4f751d8abfcbb4c..82679417e25f39e532a3865775d87e42ce464937 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/regmap.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 
 #include <linux/pinctrl/pinconf-generic.h>
 #include <linux/pinctrl/pinconf.h>
@@ -569,7 +570,7 @@ static void pm8xxx_gpio_dbg_show_one(struct seq_file *s,
                seq_printf(s, " VIN%d", pin->power_source);
                seq_printf(s, " %-27s", biases[pin->bias]);
                seq_printf(s, " %-10s", buffer_types[pin->open_drain]);
-               seq_printf(s, " %-4s", pin->output_value ? "high" : "low");
+               seq_printf(s, " %-4s", str_high_low(pin->output_value));
                seq_printf(s, " %-7s", strengths[pin->output_strength]);
                if (pin->inverted)
                        seq_puts(s, " inverted");
index 9b1039c08aa6d71ff7c60747bfc9162561bfa068..4841bbfe4864dcb5b843c8e4fff952801425e8b8 100644 (file)
@@ -13,6 +13,7 @@
 #include <linux/regmap.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 
 #include <linux/pinctrl/pinconf-generic.h>
 #include <linux/pinctrl/pinconf.h>
@@ -576,8 +577,7 @@ static void pm8xxx_mpp_dbg_show_one(struct seq_file *s,
                        seq_puts(s, "out ");
 
                        if (!pin->paired) {
-                               seq_puts(s, pin->output_value ?
-                                        "high" : "low");
+                               seq_puts(s, str_high_low(pin->output_value));
                        } else {
                                seq_puts(s, pin->output_value ?
                                         "inverted" : "follow");
@@ -589,8 +589,7 @@ static void pm8xxx_mpp_dbg_show_one(struct seq_file *s,
                if (pin->output) {
                        seq_printf(s, "out %s ", aout_lvls[pin->aout_level]);
                        if (!pin->paired) {
-                               seq_puts(s, pin->output_value ?
-                                        "high" : "low");
+                               seq_puts(s, str_high_low(pin->output_value));
                        } else {
                                seq_puts(s, pin->output_value ?
                                         "inverted" : "follow");
@@ -605,8 +604,7 @@ static void pm8xxx_mpp_dbg_show_one(struct seq_file *s,
                        seq_printf(s, "dtest%d", pin->dtest);
                } else {
                        if (!pin->paired) {
-                               seq_puts(s, pin->output_value ?
-                                        "high" : "low");
+                               seq_puts(s, str_high_low(pin->output_value));
                        } else {
                                seq_puts(s, pin->output_value ?
                                         "inverted" : "follow");
index ac6dc22b37c98ed5b7fca3335764f19abb2f71cc..42093bae8bb79390f3c0ee7d387220b297af812b 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/of_irq.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
+#include <linux/string_choices.h>
 #include <linux/regmap.h>
 #include <linux/err.h>
 #include <linux/soc/samsung/exynos-pmu.h>
@@ -442,7 +443,7 @@ static int exynos_wkup_irq_set_wake(struct irq_data *irqd, unsigned int on)
        struct samsung_pin_bank *bank = irq_data_get_irq_chip_data(irqd);
        unsigned long bit = 1UL << (2 * bank->eint_offset + irqd->hwirq);
 
-       pr_info("wake %s for irq %u (%s-%lu)\n", on ? "enabled" : "disabled",
+       pr_info("wake %s for irq %u (%s-%lu)\n", str_enabled_disabled(on),
                irqd->irq, bank->name, irqd->hwirq);
 
        if (!on)
index 03f3f707d27555e660b783bc042efe85dcbe6c9a..cc0b4d1d7cfff0dd996a35b9320bce8c9bfe850d 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/reset.h>
 #include <linux/seq_file.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 
 #include <linux/pinctrl/consumer.h>
 #include <linux/pinctrl/machine.h>
@@ -1217,7 +1218,7 @@ static void stm32_pconf_dbg_show(struct pinctrl_dev *pctldev,
        case 0:
                val = stm32_pconf_get(bank, offset, true);
                seq_printf(s, "- %s - %s",
-                          val ? "high" : "low",
+                          str_high_low(val),
                           biasing[bias]);
                break;
 
@@ -1227,7 +1228,7 @@ static void stm32_pconf_dbg_show(struct pinctrl_dev *pctldev,
                speed = stm32_pconf_get_speed(bank, offset);
                val = stm32_pconf_get(bank, offset, false);
                seq_printf(s, "- %s - %s - %s - %s %s",
-                          val ? "high" : "low",
+                          str_high_low(val),
                           drive ? "open drain" : "push pull",
                           biasing[bias],
                           speeds[speed], "speed");