Skip to content

Commit 3f36bff

Browse files
krzklinusw
authored andcommitted
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: Krzysztof Kozlowski <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Reviewed-by: Antonio Borneo <[email protected]> Reviewed-by: Charles Keepax <[email protected]> Link: https://lore.kernel.org/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 33f32a0 commit 3f36bff

14 files changed

+37
-27
lines changed

drivers/pinctrl/bcm/pinctrl-nsp-gpio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/pinctrl/pinctrl.h>
2222
#include <linux/platform_device.h>
2323
#include <linux/slab.h>
24+
#include <linux/string_choices.h>
2425

2526
#include "../pinctrl-utils.h"
2627

@@ -254,7 +255,7 @@ static int nsp_gpio_irq_set_type(struct irq_data *d, unsigned int type)
254255
raw_spin_unlock_irqrestore(&chip->lock, flags);
255256

256257
dev_dbg(chip->dev, "gpio:%u level_low:%s falling:%s\n", gpio,
257-
level_low ? "true" : "false", falling ? "true" : "false");
258+
str_true_false(level_low), str_true_false(falling));
258259
return 0;
259260
}
260261

drivers/pinctrl/cirrus/pinctrl-lochnagar.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/of.h>
1616
#include <linux/platform_device.h>
1717
#include <linux/regmap.h>
18+
#include <linux/string_choices.h>
1819

1920
#include <linux/pinctrl/consumer.h>
2021
#include <linux/pinctrl/pinconf-generic.h>
@@ -1068,7 +1069,7 @@ static void lochnagar_gpio_set(struct gpio_chip *chip,
10681069
value = !!value;
10691070

10701071
dev_dbg(priv->dev, "Set GPIO %s to %s\n",
1071-
pin->name, value ? "high" : "low");
1072+
pin->name, str_high_low(value));
10721073

10731074
switch (pin->type) {
10741075
case LN_PTYPE_MUX:

drivers/pinctrl/nomadik/pinctrl-abx500.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/property.h>
2323
#include <linux/seq_file.h>
2424
#include <linux/slab.h>
25+
#include <linux/string_choices.h>
2526
#include <linux/types.h>
2627

2728
#include <linux/mfd/abx500.h>
@@ -496,7 +497,7 @@ static void abx500_gpio_dbg_show_one(struct seq_file *s,
496497

497498
seq_printf(s, " %-9s", pull_up_down[pd]);
498499
} else
499-
seq_printf(s, " %-9s", chip->get(chip, offset) ? "hi" : "lo");
500+
seq_printf(s, " %-9s", str_hi_lo(chip->get(chip, offset)));
500501

501502
mode = abx500_get_mode(pctldev, chip, offset);
502503

@@ -865,7 +866,7 @@ static int abx500_pin_config_set(struct pinctrl_dev *pctldev,
865866
pin, configs[i],
866867
(param == PIN_CONFIG_OUTPUT) ? "output " : "input",
867868
(param == PIN_CONFIG_OUTPUT) ?
868-
(argument ? "high" : "low") :
869+
str_high_low(argument) :
869870
(argument ? "pull up" : "pull down"));
870871

871872
/* on ABx500, there is no GPIO0, so adjust the offset */

drivers/pinctrl/nomadik/pinctrl-nomadik.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/seq_file.h>
2929
#include <linux/slab.h>
3030
#include <linux/spinlock.h>
31+
#include <linux/string_choices.h>
3132
#include <linux/types.h>
3233

3334
/* Since we request GPIOs from ourself */
@@ -1125,15 +1126,15 @@ static int nmk_pin_config_set(struct pinctrl_dev *pctldev, unsigned int pin,
11251126
slpm_pull ? pullnames[pull] : "same",
11261127
slpm_output ? (output ? "output" : "input")
11271128
: "same",
1128-
slpm_val ? (val ? "high" : "low") : "same");
1129+
slpm_val ? str_high_low(val) : "same");
11291130
}
11301131

11311132
dev_dbg(nmk_chip->chip.parent,
11321133
"pin %d [%#lx]: pull %s, slpm %s (%s%s), lowemi %s\n",
11331134
pin, cfg, pullnames[pull], slpmnames[slpm],
11341135
output ? "output " : "input",
1135-
output ? (val ? "high" : "low") : "",
1136-
lowemi ? "on" : "off");
1136+
output ? str_high_low(val) : "",
1137+
str_on_off(lowemi));
11371138

11381139
ret = clk_enable(nmk_chip->clk);
11391140
if (ret)

drivers/pinctrl/pinctrl-amd.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <linux/pinctrl/pinconf.h>
3131
#include <linux/pinctrl/pinconf-generic.h>
3232
#include <linux/pinctrl/pinmux.h>
33+
#include <linux/string_choices.h>
3334
#include <linux/suspend.h>
3435

3536
#include "core.h"
@@ -458,7 +459,7 @@ static int amd_gpio_irq_set_wake(struct irq_data *d, unsigned int on)
458459

459460
if (err)
460461
dev_err(&gpio_dev->pdev->dev, "failed to %s wake-up interrupt\n",
461-
on ? "enable" : "disable");
462+
str_enable_disable(on));
462463

463464
return 0;
464465
}

drivers/pinctrl/pinctrl-gemini.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/regmap.h>
1515
#include <linux/seq_file.h>
1616
#include <linux/slab.h>
17+
#include <linux/string_choices.h>
1718

1819
#include <linux/pinctrl/machine.h>
1920
#include <linux/pinctrl/pinconf-generic.h>
@@ -2237,15 +2238,15 @@ static int gemini_pmx_set_mux(struct pinctrl_dev *pctldev,
22372238
"pin group %s could not be %s: "
22382239
"probably a hardware limitation\n",
22392240
gemini_padgroups[i],
2240-
enabled ? "enabled" : "disabled");
2241+
str_enabled_disabled(enabled));
22412242
dev_err(pmx->dev,
22422243
"GLOBAL MISC CTRL before: %08x, after %08x, expected %08x\n",
22432244
before, after, expected);
22442245
} else {
22452246
dev_dbg(pmx->dev,
22462247
"padgroup %s %s\n",
22472248
gemini_padgroups[i],
2248-
enabled ? "enabled" : "disabled");
2249+
str_enabled_disabled(enabled));
22492250
}
22502251
}
22512252

@@ -2259,15 +2260,15 @@ static int gemini_pmx_set_mux(struct pinctrl_dev *pctldev,
22592260
"pin group %s could not be %s: "
22602261
"probably a hardware limitation\n",
22612262
gemini_padgroups[i],
2262-
enabled ? "enabled" : "disabled");
2263+
str_enabled_disabled(enabled));
22632264
dev_err(pmx->dev,
22642265
"GLOBAL MISC CTRL before: %08x, after %08x, expected %08x\n",
22652266
before, after, expected);
22662267
} else {
22672268
dev_dbg(pmx->dev,
22682269
"padgroup %s %s\n",
22692270
gemini_padgroups[i],
2270-
enabled ? "enabled" : "disabled");
2271+
str_enabled_disabled(enabled));
22712272
}
22722273
}
22732274

@@ -2588,7 +2589,7 @@ static int gemini_pmx_probe(struct platform_device *pdev)
25882589
tmp = val;
25892590
for_each_set_bit(i, &tmp, PADS_MAXBIT) {
25902591
dev_dbg(dev, "pad group %s %s\n", gemini_padgroups[i],
2591-
(val & BIT(i)) ? "enabled" : "disabled");
2592+
str_enabled_disabled(val & BIT(i)));
25922593
}
25932594

25942595
/* Check if flash pin is set */

drivers/pinctrl/pinctrl-stmfx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ static void stmfx_pinconf_dbg_show(struct pinctrl_dev *pctldev,
380380
seq_printf(s, "input %s ", str_high_low(val));
381381
if (type)
382382
seq_printf(s, "with internal pull-%s ",
383-
pupd ? "up" : "down");
383+
str_up_down(pupd));
384384
else
385385
seq_printf(s, "%s ", pupd ? "floating" : "analog");
386386
}

drivers/pinctrl/qcom/pinctrl-msm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
#include <linux/seq_file.h>
2020
#include <linux/slab.h>
2121
#include <linux/spinlock.h>
22+
#include <linux/string_choices.h>
2223

2324
#include <linux/pinctrl/machine.h>
2425
#include <linux/pinctrl/pinconf-generic.h>
@@ -714,7 +715,7 @@ static void msm_gpio_dbg_show_one(struct seq_file *s,
714715
}
715716

716717
seq_printf(s, " %-8s: %-3s", g->grp.name, is_out ? "out" : "in");
717-
seq_printf(s, " %-4s func%d", val ? "high" : "low", func);
718+
seq_printf(s, " %-4s func%d", str_high_low(val), func);
718719
seq_printf(s, " %dmA", msm_regval_to_drive(drive));
719720
if (pctrl->soc->pull_no_keeper)
720721
seq_printf(s, " %s", pulls_no_keeper[pull]);

drivers/pinctrl/qcom/pinctrl-spmi-gpio.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/seq_file.h>
1515
#include <linux/slab.h>
1616
#include <linux/spmi.h>
17+
#include <linux/string_choices.h>
1718
#include <linux/types.h>
1819

1920
#include <linux/pinctrl/pinconf-generic.h>
@@ -702,7 +703,7 @@ static void pmic_gpio_config_dbg_show(struct pinctrl_dev *pctldev,
702703
else
703704
seq_printf(s, " %-4s",
704705
pad->output_enabled ? "out" : "in");
705-
seq_printf(s, " %-4s", pad->out_value ? "high" : "low");
706+
seq_printf(s, " %-4s", str_high_low(pad->out_value));
706707
seq_printf(s, " %-7s", pmic_gpio_functions[function]);
707708
seq_printf(s, " vin-%d", pad->power_source);
708709
seq_printf(s, " %-27s", biases[pad->pullup]);

drivers/pinctrl/qcom/pinctrl-spmi-mpp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/regmap.h>
1212
#include <linux/seq_file.h>
1313
#include <linux/slab.h>
14+
#include <linux/string_choices.h>
1415
#include <linux/types.h>
1516

1617
#include <linux/pinctrl/pinconf-generic.h>
@@ -544,7 +545,7 @@ static void pmic_mpp_config_dbg_show(struct pinctrl_dev *pctldev,
544545
seq_printf(s, " %d", pad->aout_level);
545546
if (pad->has_pullup)
546547
seq_printf(s, " %-8s", biases[pad->pullup]);
547-
seq_printf(s, " %-4s", pad->out_value ? "high" : "low");
548+
seq_printf(s, " %-4s", str_high_low(pad->out_value));
548549
if (pad->dtest)
549550
seq_printf(s, " dtest%d", pad->dtest);
550551
if (pad->paired)

0 commit comments

Comments
 (0)