]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
iio: Use str_enable_disable-like helpers
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tue, 14 Jan 2025 19:27:16 +0000 (20:27 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 3 Feb 2025 19:15:37 +0000 (19:15 +0000)
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://patch.msgid.link/20250114192716.912476-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/humidity/dht11.c
drivers/iio/proximity/irsd200.c

index c97e2544877296b0a5705c3d76262cf68453d490..48c59d09eea7a8c46197cfe12039e3c7dca6d1dc 100644 (file)
@@ -11,6 +11,7 @@
 #include <linux/kernel.h>
 #include <linux/printk.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 #include <linux/sysfs.h>
 #include <linux/io.h>
 #include <linux/mod_devicetable.h>
@@ -99,7 +100,7 @@ static void dht11_edges_print(struct dht11 *dht11)
        for (i = 1; i < dht11->num_edges; ++i) {
                dev_dbg(dht11->dev, "%d: %lld ns %s\n", i,
                        dht11->edges[i].ts - dht11->edges[i - 1].ts,
-                       dht11->edges[i - 1].value ? "high" : "low");
+                       str_high_low(dht11->edges[i - 1].value));
        }
 }
 #endif /* CONFIG_DYNAMIC_DEBUG */
index b09d15230111e6e5bbaae189adc26059a5a19f7a..b0ffd357401360c10b7e0fc2c3577bf0473b1582 100644 (file)
@@ -10,6 +10,7 @@
 #include <linux/i2c.h>
 #include <linux/module.h>
 #include <linux/regmap.h>
+#include <linux/string_choices.h>
 
 #include <linux/iio/buffer.h>
 #include <linux/iio/events.h>
@@ -783,7 +784,7 @@ static int irsd200_set_trigger_state(struct iio_trigger *trig, bool state)
        ret = regmap_field_write(data->regfields[IRS_REGF_INTR_DATA], state);
        if (ret) {
                dev_err(data->dev, "Could not %s data interrupt source (%d)\n",
-                       state ? "enable" : "disable", ret);
+                       str_enable_disable(state), ret);
        }
 
        return ret;