Skip to content

Commit 9675c05

Browse files
krzklag-linaro
authored andcommitted
mfd: ipaq-micro/tps65010: 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: Lee Jones <[email protected]>
1 parent 7dc0ddd commit 9675c05

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

drivers/mfd/ipaq-micro.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/mfd/core.h>
2323
#include <linux/mfd/ipaq-micro.h>
2424
#include <linux/string.h>
25+
#include <linux/string_choices.h>
2526
#include <linux/random.h>
2627
#include <linux/slab.h>
2728
#include <linux/list.h>
@@ -267,7 +268,7 @@ static void __init ipaq_micro_eeprom_dump(struct ipaq_micro *micro)
267268
dev_info(micro->dev, "page mode: %u\n", ipaq_micro_to_u16(dump+84));
268269
dev_info(micro->dev, "country ID: %u\n", ipaq_micro_to_u16(dump+86));
269270
dev_info(micro->dev, "color display: %s\n",
270-
ipaq_micro_to_u16(dump+88) ? "yes" : "no");
271+
str_yes_no(ipaq_micro_to_u16(dump + 88)));
271272
dev_info(micro->dev, "ROM size: %u MiB\n", ipaq_micro_to_u16(dump+90));
272273
dev_info(micro->dev, "RAM size: %u KiB\n", ipaq_micro_to_u16(dump+92));
273274
dev_info(micro->dev, "screen: %u x %u\n",

drivers/mfd/tps65010.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/workqueue.h>
1717
#include <linux/debugfs.h>
1818
#include <linux/seq_file.h>
19+
#include <linux/string_choices.h>
1920
#include <linux/mutex.h>
2021
#include <linux/platform_device.h>
2122

@@ -250,7 +251,7 @@ static int dbg_show(struct seq_file *s, void *_)
250251
v2 = i2c_smbus_read_byte_data(tps->client, TPS_LED1_PER);
251252
seq_printf(s, "led1 %s, on=%02x, per=%02x, %d/%d msec\n",
252253
(value & 0x80)
253-
? ((v2 & 0x80) ? "on" : "off")
254+
? str_on_off(v2 & 0x80)
254255
: ((v2 & 0x80) ? "blink" : "(nPG)"),
255256
value, v2,
256257
(value & 0x7f) * 10, (v2 & 0x7f) * 100);
@@ -259,7 +260,7 @@ static int dbg_show(struct seq_file *s, void *_)
259260
v2 = i2c_smbus_read_byte_data(tps->client, TPS_LED2_PER);
260261
seq_printf(s, "led2 %s, on=%02x, per=%02x, %d/%d msec\n",
261262
(value & 0x80)
262-
? ((v2 & 0x80) ? "on" : "off")
263+
? str_on_off(v2 & 0x80)
263264
: ((v2 & 0x80) ? "blink" : "off"),
264265
value, v2,
265266
(value & 0x7f) * 10, (v2 & 0x7f) * 100);
@@ -738,7 +739,7 @@ int tps65010_set_gpio_out_value(unsigned gpio, unsigned value)
738739
TPS_DEFGPIO, defgpio);
739740

740741
pr_debug("%s: gpio%dout = %s, defgpio 0x%02x\n", DRIVER_NAME,
741-
gpio, value ? "high" : "low",
742+
gpio, str_high_low(value),
742743
i2c_smbus_read_byte_data(the_tps->client, TPS_DEFGPIO));
743744

744745
mutex_unlock(&the_tps->lock);
@@ -850,7 +851,7 @@ int tps65010_set_vib(unsigned value)
850851
status = i2c_smbus_write_byte_data(the_tps->client,
851852
TPS_VDCDC2, vdcdc2);
852853

853-
pr_debug("%s: vibrator %s\n", DRIVER_NAME, value ? "on" : "off");
854+
pr_debug("%s: vibrator %s\n", DRIVER_NAME, str_on_off(value));
854855

855856
mutex_unlock(&the_tps->lock);
856857
return status;
@@ -872,7 +873,7 @@ int tps65010_set_low_pwr(unsigned mode)
872873
mutex_lock(&the_tps->lock);
873874

874875
pr_debug("%s: %s low_pwr, vdcdc1 0x%02x\n", DRIVER_NAME,
875-
mode ? "enable" : "disable",
876+
str_enable_disable(mode),
876877
i2c_smbus_read_byte_data(the_tps->client, TPS_VDCDC1));
877878

878879
vdcdc1 = i2c_smbus_read_byte_data(the_tps->client, TPS_VDCDC1);
@@ -984,7 +985,7 @@ int tps65013_set_low_pwr(unsigned mode)
984985

985986
pr_debug("%s: %s low_pwr, chgconfig 0x%02x vdcdc1 0x%02x\n",
986987
DRIVER_NAME,
987-
mode ? "enable" : "disable",
988+
str_enable_disable(mode),
988989
i2c_smbus_read_byte_data(the_tps->client, TPS_CHGCONFIG),
989990
i2c_smbus_read_byte_data(the_tps->client, TPS_VDCDC1));
990991

0 commit comments

Comments
 (0)