Commit 3f36bffa authored by Krzysztof Kozlowski's avatar Krzysztof Kozlowski Committed by Linus Walleij
Browse files

pinctrl: 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.

Signed-off-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Reviewed-by: default avatarFlorian Fainelli <florian.fainelli@broadcom.com>
Reviewed-by: default avatarAntonio Borneo <antonio.borneo@foss.st.com>
Reviewed-by: default avatarCharles Keepax <ckeepax@opensource.cirrus.com>
Link: https://lore.kernel.org/20250114203602.1013275-1-krzysztof.kozlowski@linaro.org


Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 33f32a06
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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;
}

+2 −1
Original line number Diff line number Diff line
@@ -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:
+3 −2
Original line number Diff line number Diff line
@@ -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 */
+4 −3
Original line number Diff line number Diff line
@@ -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)
+2 −1
Original line number Diff line number Diff line
@@ -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;
}
Loading