Skip to content

Commit 2d678e3

Browse files
krzksre
authored andcommitted
power: supply: 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 <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sebastian Reichel <[email protected]>
1 parent a3a8799 commit 2d678e3

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

drivers/power/supply/88pm860x_battery.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/mutex.h>
1515
#include <linux/string.h>
1616
#include <linux/power_supply.h>
17+
#include <linux/string_choices.h>
1718
#include <linux/mfd/88pm860x.h>
1819
#include <linux/delay.h>
1920

@@ -503,8 +504,7 @@ static void pm860x_init_battery(struct pm860x_battery_info *info)
503504
data = pm860x_reg_read(info->i2c, PM8607_POWER_UP_LOG);
504505
bat_remove = data & BAT_WU_LOG;
505506

506-
dev_dbg(info->dev, "battery wake up? %s\n",
507-
bat_remove != 0 ? "yes" : "no");
507+
dev_dbg(info->dev, "battery wake up? %s\n", str_yes_no(bat_remove));
508508

509509
/* restore SOC from RTC domain register */
510510
if (bat_remove == 0) {

drivers/power/supply/charger-manager.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/platform_device.h>
2323
#include <linux/power/charger-manager.h>
2424
#include <linux/regulator/consumer.h>
25+
#include <linux/string_choices.h>
2526
#include <linux/sysfs.h>
2627
#include <linux/of.h>
2728
#include <linux/thermal.h>
@@ -1088,7 +1089,7 @@ static ssize_t charger_state_show(struct device *dev,
10881089
if (!charger->externally_control)
10891090
state = regulator_is_enabled(charger->consumer);
10901091

1091-
return sysfs_emit(buf, "%s\n", state ? "enabled" : "disabled");
1092+
return sysfs_emit(buf, "%s\n", str_enabled_disabled(state));
10921093
}
10931094

10941095
static ssize_t charger_externally_control_show(struct device *dev,

drivers/power/supply/cpcap-charger.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/init.h>
1515
#include <linux/module.h>
1616
#include <linux/slab.h>
17+
#include <linux/string_choices.h>
1718
#include <linux/err.h>
1819
#include <linux/interrupt.h>
1920
#include <linux/notifier.h>
@@ -515,7 +516,7 @@ static void cpcap_charger_vbus_work(struct work_struct *work)
515516
out_err:
516517
cpcap_charger_update_state(ddata, POWER_SUPPLY_STATUS_UNKNOWN);
517518
dev_err(ddata->dev, "%s could not %s vbus: %i\n", __func__,
518-
ddata->vbus_enabled ? "enable" : "disable", error);
519+
str_enable_disable(ddata->vbus_enabled), error);
519520
}
520521

521522
static int cpcap_charger_set_vbus(struct phy_companion *comparator,

drivers/power/supply/da9030_battery.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <linux/module.h>
1616
#include <linux/platform_device.h>
1717
#include <linux/power_supply.h>
18+
#include <linux/string_choices.h>
1819
#include <linux/mfd/da903x.h>
1920

2021
#include <linux/debugfs.h>
@@ -138,7 +139,7 @@ static int bat_debug_show(struct seq_file *s, void *data)
138139
{
139140
struct da9030_charger *charger = s->private;
140141

141-
seq_printf(s, "charger is %s\n", charger->is_on ? "on" : "off");
142+
seq_printf(s, "charger is %s\n", str_on_off(charger->is_on));
142143
if (charger->chdet) {
143144
seq_printf(s, "iset = %dmA, vset = %dmV\n",
144145
charger->mA, charger->mV);

drivers/power/supply/sbs-battery.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/power_supply.h>
2222
#include <linux/slab.h>
2323
#include <linux/stat.h>
24+
#include <linux/string_choices.h>
2425

2526
enum {
2627
REG_MANUFACTURER_DATA,
@@ -320,8 +321,8 @@ static int sbs_update_presence(struct sbs_info *chip, bool is_present)
320321
client->flags &= ~I2C_CLIENT_PEC;
321322
}
322323

323-
dev_dbg(&client->dev, "PEC: %s\n", (client->flags & I2C_CLIENT_PEC) ?
324-
"enabled" : "disabled");
324+
dev_dbg(&client->dev, "PEC: %s\n",
325+
str_enabled_disabled(client->flags & I2C_CLIENT_PEC));
325326

326327
if (!chip->is_present && is_present && !chip->charger_broadcasts)
327328
sbs_disable_charger_broadcasts(chip);

0 commit comments

Comments
 (0)