Skip to content

Commit 7ef9bde

Browse files
krzkdtor
authored andcommitted
Input: 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 <krzysztof.kozlowski@linaro.org> Link: https://lore.kernel.org/r/20250114192701.912430-1-krzysztof.kozlowski@linaro.org Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent 21d8dd0 commit 7ef9bde

6 files changed

Lines changed: 12 additions & 6 deletions

File tree

drivers/input/keyboard/dlink-dir685-touchkeys.c

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

1920
struct dir685_touchkeys {
@@ -48,7 +49,7 @@ static irqreturn_t dir685_tk_irq_thread(int irq, void *data)
4849
changed = tk->cur_key ^ key;
4950
for_each_set_bit(i, &changed, num_bits) {
5051
dev_dbg(tk->dev, "key %d is %s\n", i,
51-
test_bit(i, &key) ? "down" : "up");
52+
str_down_up(test_bit(i, &key)));
5253
input_report_key(tk->input, tk->codes[i], test_bit(i, &key));
5354
}
5455

drivers/input/keyboard/lm8323.c

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

2526
/* Commands to send to the chip. */
2627
#define LM8323_CMD_READ_ID 0x80 /* Read chip ID. */
@@ -269,7 +270,7 @@ static void process_keys(struct lm8323_chip *lm)
269270
unsigned short keycode = lm->keymap[key];
270271

271272
dev_vdbg(&lm->client->dev, "key 0x%02x %s\n",
272-
key, isdown ? "down" : "up");
273+
key, str_down_up(isdown));
273274

274275
if (lm->kp_enabled) {
275276
input_event(lm->idev, EV_MSC, MSC_SCAN, key);

drivers/input/misc/max77693-haptic.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
#include <linux/platform_device.h>
1919
#include <linux/pwm.h>
2020
#include <linux/slab.h>
21+
#include <linux/string_choices.h>
2122
#include <linux/workqueue.h>
2223
#include <linux/regulator/consumer.h>
2324
#include <linux/mfd/max77693.h>
@@ -94,7 +95,7 @@ static int max77843_haptic_bias(struct max77693_haptic *haptic, bool on)
9495
on << MAINCTRL1_BIASEN_SHIFT);
9596
if (error) {
9697
dev_err(haptic->dev, "failed to %s bias: %d\n",
97-
on ? "enable" : "disable", error);
98+
str_enable_disable(on), error);
9899
return error;
99100
}
100101

drivers/input/misc/regulator-haptic.c

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

1819
#define MAX_MAGNITUDE_SHIFT 16
1920

@@ -44,7 +45,7 @@ static int regulator_haptic_toggle(struct regulator_haptic *haptic, bool on)
4445
if (error) {
4546
dev_err(haptic->dev,
4647
"failed to switch regulator %s: %d\n",
47-
on ? "on" : "off", error);
48+
str_on_off(on), error);
4849
return error;
4950
}
5051

drivers/input/mouse/elan_i2c_core.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include <linux/slab.h>
2929
#include <linux/kernel.h>
3030
#include <linux/sched.h>
31+
#include <linux/string_choices.h>
3132
#include <linux/input.h>
3233
#include <linux/uaccess.h>
3334
#include <linux/jiffies.h>
@@ -199,7 +200,7 @@ static int elan_set_power(struct elan_tp_data *data, bool on)
199200
} while (--repeat > 0);
200201

201202
dev_err(&data->client->dev, "failed to set power %s: %d\n",
202-
on ? "on" : "off", error);
203+
str_on_off(on), error);
203204
return error;
204205
}
205206

drivers/input/touchscreen/egalax_ts.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/gpio/consumer.h>
2424
#include <linux/delay.h>
2525
#include <linux/slab.h>
26+
#include <linux/string_choices.h>
2627
#include <linux/bitops.h>
2728
#include <linux/input/mt.h>
2829

@@ -102,7 +103,7 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
102103
input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, down);
103104

104105
dev_dbg(&client->dev, "%s id:%d x:%d y:%d z:%d",
105-
down ? "down" : "up", id, x, y, z);
106+
str_down_up(down), id, x, y, z);
106107

107108
if (down) {
108109
input_report_abs(input_dev, ABS_MT_POSITION_X, x);

0 commit comments

Comments
 (0)