]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
Input: Use str_enable_disable-like helpers
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tue, 14 Jan 2025 21:40:22 +0000 (13:40 -0800)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Tue, 14 Jan 2025 21:41:41 +0000 (13:41 -0800)
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>
drivers/input/keyboard/dlink-dir685-touchkeys.c
drivers/input/keyboard/lm8323.c
drivers/input/misc/max77693-haptic.c
drivers/input/misc/regulator-haptic.c
drivers/input/mouse/elan_i2c_core.c
drivers/input/touchscreen/egalax_ts.c

index 993cdbda509e6cb3fafe3598ac3f6d775e02421d..4184dd2eaeebedf02039fb0b4f17f42ebafbea52 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/delay.h>
 #include <linux/input.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 #include <linux/bitops.h>
 
 struct dir685_touchkeys {
@@ -48,7 +49,7 @@ static irqreturn_t dir685_tk_irq_thread(int irq, void *data)
        changed = tk->cur_key ^ key;
        for_each_set_bit(i, &changed, num_bits) {
                dev_dbg(tk->dev, "key %d is %s\n", i,
-                       test_bit(i, &key) ? "down" : "up");
+                       str_down_up(test_bit(i, &key)));
                input_report_key(tk->input, tk->codes[i], test_bit(i, &key));
        }
 
index e26bf2956344675fb3ea5bd6b871ee8ef226fe87..e19442c6f80f569099f34e09799175dbe90fecb9 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/platform_data/lm8323.h>
 #include <linux/pm.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 
 /* Commands to send to the chip. */
 #define LM8323_CMD_READ_ID             0x80 /* Read chip ID. */
@@ -269,7 +270,7 @@ static void process_keys(struct lm8323_chip *lm)
                unsigned short keycode = lm->keymap[key];
 
                dev_vdbg(&lm->client->dev, "key 0x%02x %s\n",
-                        key, isdown ? "down" : "up");
+                        key, str_down_up(isdown));
 
                if (lm->kp_enabled) {
                        input_event(lm->idev, EV_MSC, MSC_SCAN, key);
index 0e646f1b257b8fefd21057c31806d82150b4f4db..cdb9be737e48122f4609f50dd15935efaa6bcd96 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/platform_device.h>
 #include <linux/pwm.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 #include <linux/workqueue.h>
 #include <linux/regulator/consumer.h>
 #include <linux/mfd/max77693.h>
@@ -94,7 +95,7 @@ static int max77843_haptic_bias(struct max77693_haptic *haptic, bool on)
                                   on << MAINCTRL1_BIASEN_SHIFT);
        if (error) {
                dev_err(haptic->dev, "failed to %s bias: %d\n",
-                       on ? "enable" : "disable", error);
+                       str_enable_disable(on), error);
                return error;
        }
 
index 3666ba6d1f307f72e95058eb1274dc7a188dfa01..9711f5c7c78a93934b2815f13cf73c1f2c42e656 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 
 #define MAX_MAGNITUDE_SHIFT    16
 
@@ -44,7 +45,7 @@ static int regulator_haptic_toggle(struct regulator_haptic *haptic, bool on)
                if (error) {
                        dev_err(haptic->dev,
                                "failed to switch regulator %s: %d\n",
-                               on ? "on" : "off", error);
+                               str_on_off(on), error);
                        return error;
                }
 
index a841883660fb826b85311fbb8c1e5f4ad0cb8fae..fee1796da3d08449f1e43d098d5bafef7533af6b 100644 (file)
@@ -28,6 +28,7 @@
 #include <linux/slab.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
+#include <linux/string_choices.h>
 #include <linux/input.h>
 #include <linux/uaccess.h>
 #include <linux/jiffies.h>
@@ -199,7 +200,7 @@ static int elan_set_power(struct elan_tp_data *data, bool on)
        } while (--repeat > 0);
 
        dev_err(&data->client->dev, "failed to set power %s: %d\n",
-               on ? "on" : "off", error);
+               str_on_off(on), error);
        return error;
 }
 
index f4e950920e8490511359519b278d135ed4602b35..eb3cc2befcdf455ed3f90bd3589399528f882625 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/gpio/consumer.h>
 #include <linux/delay.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 #include <linux/bitops.h>
 #include <linux/input/mt.h>
 
@@ -102,7 +103,7 @@ static irqreturn_t egalax_ts_interrupt(int irq, void *dev_id)
        input_mt_report_slot_state(input_dev, MT_TOOL_FINGER, down);
 
        dev_dbg(&client->dev, "%s id:%d x:%d y:%d z:%d",
-               down ? "down" : "up", id, x, y, z);
+               str_down_up(down), id, x, y, z);
 
        if (down) {
                input_report_abs(input_dev, ABS_MT_POSITION_X, x);