]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
power: supply: Use str_enable_disable-like helpers
authorKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tue, 14 Jan 2025 20:36:11 +0000 (21:36 +0100)
committerSebastian Reichel <sebastian.reichel@collabora.com>
Wed, 15 Jan 2025 20:41:22 +0000 (21:41 +0100)
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/20250114203611.1013324-1-krzysztof.kozlowski@linaro.org
Signed-off-by: Sebastian Reichel <sebastian.reichel@collabora.com>
drivers/power/supply/88pm860x_battery.c
drivers/power/supply/charger-manager.c
drivers/power/supply/cpcap-charger.c
drivers/power/supply/da9030_battery.c
drivers/power/supply/sbs-battery.c

index b7938fbb24a51f46a4865f05983a138e3e84b04a..edae1e843c515fed331d92a80004e57a130d4615 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/mutex.h>
 #include <linux/string.h>
 #include <linux/power_supply.h>
+#include <linux/string_choices.h>
 #include <linux/mfd/88pm860x.h>
 #include <linux/delay.h>
 
@@ -503,8 +504,7 @@ static void pm860x_init_battery(struct pm860x_battery_info *info)
        data = pm860x_reg_read(info->i2c, PM8607_POWER_UP_LOG);
        bat_remove = data & BAT_WU_LOG;
 
-       dev_dbg(info->dev, "battery wake up? %s\n",
-               bat_remove != 0 ? "yes" : "no");
+       dev_dbg(info->dev, "battery wake up? %s\n", str_yes_no(bat_remove));
 
        /* restore SOC from RTC domain register */
        if (bat_remove == 0) {
index a69faef444c042b45f7e8db63da3c11aff643071..c49e0e4d02f77a4576bba7eede54e45cbb4eab75 100644 (file)
@@ -22,6 +22,7 @@
 #include <linux/platform_device.h>
 #include <linux/power/charger-manager.h>
 #include <linux/regulator/consumer.h>
+#include <linux/string_choices.h>
 #include <linux/sysfs.h>
 #include <linux/of.h>
 #include <linux/thermal.h>
@@ -1088,7 +1089,7 @@ static ssize_t charger_state_show(struct device *dev,
        if (!charger->externally_control)
                state = regulator_is_enabled(charger->consumer);
 
-       return sysfs_emit(buf, "%s\n", state ? "enabled" : "disabled");
+       return sysfs_emit(buf, "%s\n", str_enabled_disabled(state));
 }
 
 static ssize_t charger_externally_control_show(struct device *dev,
index 7781b45a67a7d2d7d60597033ebbf7d256e98cc4..6625d539d9ae76e63cf6539f7fade727956c39b5 100644 (file)
@@ -14,6 +14,7 @@
 #include <linux/init.h>
 #include <linux/module.h>
 #include <linux/slab.h>
+#include <linux/string_choices.h>
 #include <linux/err.h>
 #include <linux/interrupt.h>
 #include <linux/notifier.h>
@@ -515,7 +516,7 @@ static void cpcap_charger_vbus_work(struct work_struct *work)
 out_err:
        cpcap_charger_update_state(ddata, POWER_SUPPLY_STATUS_UNKNOWN);
        dev_err(ddata->dev, "%s could not %s vbus: %i\n", __func__,
-               ddata->vbus_enabled ? "enable" : "disable", error);
+               str_enable_disable(ddata->vbus_enabled), error);
 }
 
 static int cpcap_charger_set_vbus(struct phy_companion *comparator,
index 34328f5d556e21233c3a0d201ae23e211d7c5016..ac2e319e95179039279dacaed1744136f679fbac 100644 (file)
@@ -15,6 +15,7 @@
 #include <linux/module.h>
 #include <linux/platform_device.h>
 #include <linux/power_supply.h>
+#include <linux/string_choices.h>
 #include <linux/mfd/da903x.h>
 
 #include <linux/debugfs.h>
@@ -138,7 +139,7 @@ static int bat_debug_show(struct seq_file *s, void *data)
 {
        struct da9030_charger *charger = s->private;
 
-       seq_printf(s, "charger is %s\n", charger->is_on ? "on" : "off");
+       seq_printf(s, "charger is %s\n", str_on_off(charger->is_on));
        if (charger->chdet) {
                seq_printf(s, "iset = %dmA, vset = %dmV\n",
                           charger->mA, charger->mV);
index a6c204c08232a5fe999ff230194279f03834a100..6f3d0413b1c127fc4c5a16728d71be8ae340d05d 100644 (file)
@@ -21,6 +21,7 @@
 #include <linux/power_supply.h>
 #include <linux/slab.h>
 #include <linux/stat.h>
+#include <linux/string_choices.h>
 
 enum {
        REG_MANUFACTURER_DATA,
@@ -320,8 +321,8 @@ static int sbs_update_presence(struct sbs_info *chip, bool is_present)
                client->flags &= ~I2C_CLIENT_PEC;
        }
 
-       dev_dbg(&client->dev, "PEC: %s\n", (client->flags & I2C_CLIENT_PEC) ?
-               "enabled" : "disabled");
+       dev_dbg(&client->dev, "PEC: %s\n",
+               str_enabled_disabled(client->flags & I2C_CLIENT_PEC));
 
        if (!chip->is_present && is_present && !chip->charger_broadcasts)
                sbs_disable_charger_broadcasts(chip);