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

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>

authored by

Krzysztof Kozlowski and committed by
Dmitry Torokhov
7ef9bdec 21d8dd0d

+12 -6
+2 -1
drivers/input/keyboard/lm8323.c
··· 21 21 #include <linux/platform_data/lm8323.h> 22 22 #include <linux/pm.h> 23 23 #include <linux/slab.h> 24 + #include <linux/string_choices.h> 24 25 25 26 /* Commands to send to the chip. */ 26 27 #define LM8323_CMD_READ_ID 0x80 /* Read chip ID. */ ··· 270 269 unsigned short keycode = lm->keymap[key]; 271 270 272 271 dev_vdbg(&lm->client->dev, "key 0x%02x %s\n", 273 - key, isdown ? "down" : "up"); 272 + key, str_down_up(isdown)); 274 273 275 274 if (lm->kp_enabled) { 276 275 input_event(lm->idev, EV_MSC, MSC_SCAN, key);
+2 -1
drivers/input/misc/max77693-haptic.c
··· 18 18 #include <linux/platform_device.h> 19 19 #include <linux/pwm.h> 20 20 #include <linux/slab.h> 21 + #include <linux/string_choices.h> 21 22 #include <linux/workqueue.h> 22 23 #include <linux/regulator/consumer.h> 23 24 #include <linux/mfd/max77693.h> ··· 95 94 on << MAINCTRL1_BIASEN_SHIFT); 96 95 if (error) { 97 96 dev_err(haptic->dev, "failed to %s bias: %d\n", 98 - on ? "enable" : "disable", error); 97 + str_enable_disable(on), error); 99 98 return error; 100 99 } 101 100
+2 -1
drivers/input/misc/regulator-haptic.c
··· 14 14 #include <linux/platform_device.h> 15 15 #include <linux/regulator/consumer.h> 16 16 #include <linux/slab.h> 17 + #include <linux/string_choices.h> 17 18 18 19 #define MAX_MAGNITUDE_SHIFT 16 19 20 ··· 45 44 if (error) { 46 45 dev_err(haptic->dev, 47 46 "failed to switch regulator %s: %d\n", 48 - on ? "on" : "off", error); 47 + str_on_off(on), error); 49 48 return error; 50 49 } 51 50
+2 -1
drivers/input/mouse/elan_i2c_core.c
··· 28 28 #include <linux/slab.h> 29 29 #include <linux/kernel.h> 30 30 #include <linux/sched.h> 31 + #include <linux/string_choices.h> 31 32 #include <linux/input.h> 32 33 #include <linux/uaccess.h> 33 34 #include <linux/jiffies.h> ··· 200 199 } while (--repeat > 0); 201 200 202 201 dev_err(&data->client->dev, "failed to set power %s: %d\n", 203 - on ? "on" : "off", error); 202 + str_on_off(on), error); 204 203 return error; 205 204 } 206 205
+2 -1
drivers/input/touchscreen/egalax_ts.c
··· 23 23 #include <linux/gpio/consumer.h> 24 24 #include <linux/delay.h> 25 25 #include <linux/slab.h> 26 + #include <linux/string_choices.h> 26 27 #include <linux/bitops.h> 27 28 #include <linux/input/mt.h> 28 29 ··· 103 102 input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, down); 104 103 105 104 dev_dbg(&client->dev, "%s id:%d x:%d y:%d z:%d", 106 - down ? "down" : "up", id, x, y, z); 105 + str_down_up(down), id, x, y, z); 107 106 108 107 if (down) { 109 108 input_report_abs(input_dev, ABS_MT_POSITION_X, x);