]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
mfd: ipaq-micro/tps65010: Use str_enable_disable-like helpers
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tue, 14 Jan 2025 19:25:38 +0000 (20:25 +0100)
committerLee Jones <lee@kernel.org>
Fri, 14 Mar 2025 08:59:05 +0000 (08:59 +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://lore.kernel.org/r/20250114192538.911970-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/mfd/ipaq-micro.c
drivers/mfd/tps65010.c

index 2370b44e2214489ac305402f3ea097da47c3b014..4b757d8472825121a0323da289f5176e25135fd0 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/mfd/core.h>
 #include <linux/mfd/ipaq-micro.h>
 #include <linux/string.h>
+#include <linux/string_choices.h>
 #include <linux/random.h>
 #include <linux/slab.h>
 #include <linux/list.h>
@@ -267,7 +268,7 @@ static void __init ipaq_micro_eeprom_dump(struct ipaq_micro *micro)
        dev_info(micro->dev, "page mode: %u\n", ipaq_micro_to_u16(dump+84));
        dev_info(micro->dev, "country ID: %u\n", ipaq_micro_to_u16(dump+86));
        dev_info(micro->dev, "color display: %s\n",
-                ipaq_micro_to_u16(dump+88) ? "yes" : "no");
+                str_yes_no(ipaq_micro_to_u16(dump + 88)));
        dev_info(micro->dev, "ROM size: %u MiB\n", ipaq_micro_to_u16(dump+90));
        dev_info(micro->dev, "RAM size: %u KiB\n", ipaq_micro_to_u16(dump+92));
        dev_info(micro->dev, "screen: %u x %u\n",
index 710364435b6b9e7f7872e9ec70655aef902570b1..00fb12c4f491f4b803e140bfd1f741ac2a761338 100644 (file)
@@ -16,6 +16,7 @@
 #include <linux/workqueue.h>
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
+#include <linux/string_choices.h>
 #include <linux/mutex.h>
 #include <linux/platform_device.h>
 
@@ -250,7 +251,7 @@ static int dbg_show(struct seq_file *s, void *_)
        v2 = i2c_smbus_read_byte_data(tps->client, TPS_LED1_PER);
        seq_printf(s, "led1 %s, on=%02x, per=%02x, %d/%d msec\n",
                (value & 0x80)
-                       ? ((v2 & 0x80) ? "on" : "off")
+                       ? str_on_off(v2 & 0x80)
                        : ((v2 & 0x80) ? "blink" : "(nPG)"),
                value, v2,
                (value & 0x7f) * 10, (v2 & 0x7f) * 100);
@@ -259,7 +260,7 @@ static int dbg_show(struct seq_file *s, void *_)
        v2 = i2c_smbus_read_byte_data(tps->client, TPS_LED2_PER);
        seq_printf(s, "led2 %s, on=%02x, per=%02x, %d/%d msec\n",
                (value & 0x80)
-                       ? ((v2 & 0x80) ? "on" : "off")
+                       ? str_on_off(v2 & 0x80)
                        : ((v2 & 0x80) ? "blink" : "off"),
                value, v2,
                (value & 0x7f) * 10, (v2 & 0x7f) * 100);
@@ -738,7 +739,7 @@ int tps65010_set_gpio_out_value(unsigned gpio, unsigned value)
                TPS_DEFGPIO, defgpio);
 
        pr_debug("%s: gpio%dout = %s, defgpio 0x%02x\n", DRIVER_NAME,
-               gpio, value ? "high" : "low",
+               gpio, str_high_low(value),
                i2c_smbus_read_byte_data(the_tps->client, TPS_DEFGPIO));
 
        mutex_unlock(&the_tps->lock);
@@ -850,7 +851,7 @@ int tps65010_set_vib(unsigned value)
        status = i2c_smbus_write_byte_data(the_tps->client,
                TPS_VDCDC2, vdcdc2);
 
-       pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off");
+       pr_debug("%s: vibrator %s\n", DRIVER_NAME, str_on_off(value));
 
        mutex_unlock(&the_tps->lock);
        return status;
@@ -872,7 +873,7 @@ int tps65010_set_low_pwr(unsigned mode)
        mutex_lock(&the_tps->lock);
 
        pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME,
-               mode ? "enable" : "disable",
+               str_enable_disable(mode),
                i2c_smbus_read_byte_data(the_tps->client, TPS_VDCDC1));
 
        vdcdc1 = i2c_smbus_read_byte_data(the_tps->client, TPS_VDCDC1);
@@ -984,7 +985,7 @@ int tps65013_set_low_pwr(unsigned mode)
 
        pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n",
                DRIVER_NAME,
-               mode ? "enable" : "disable",
+               str_enable_disable(mode),
                i2c_smbus_read_byte_data(the_tps->client, TPS_CHGCONFIG),
                i2c_smbus_read_byte_data(the_tps->client, TPS_VDCDC1));