Skip to content

Commit 836c8a2

Browse files
krzkvinodkoul
authored andcommitted
soundwire: 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 <krzysztof.kozlowski@linaro.org> Reviewed-by: Bard Liao <yung-chuan.liao@linux.intel.com> Link: https://lore.kernel.org/r/20250114200726.969501-1-krzysztof.kozlowski@linaro.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent 3df7528 commit 836c8a2

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

drivers/soundwire/bus.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/soundwire/sdw_registers.h>
99
#include <linux/soundwire/sdw.h>
1010
#include <linux/soundwire/sdw_type.h>
11+
#include <linux/string_choices.h>
1112
#include "bus.h"
1213
#include "irq.h"
1314
#include "sysfs_local.h"
@@ -277,7 +278,7 @@ static int sdw_transfer_unlocked(struct sdw_bus *bus, struct sdw_msg *msg)
277278
if (ret != 0 && ret != -ENODATA)
278279
dev_err(bus->dev, "trf on Slave %d failed:%d %s addr %x count %d\n",
279280
msg->dev_num, ret,
280-
(msg->flags & SDW_MSG_FLAG_WRITE) ? "write" : "read",
281+
str_write_read(msg->flags & SDW_MSG_FLAG_WRITE),
281282
msg->addr, msg->len);
282283

283284
return ret;
@@ -1263,7 +1264,7 @@ int sdw_configure_dpn_intr(struct sdw_slave *slave,
12631264

12641265
if (slave->bus->params.s_data_mode != SDW_PORT_DATA_MODE_NORMAL) {
12651266
dev_dbg(&slave->dev, "TEST FAIL interrupt %s\n",
1266-
enable ? "on" : "off");
1267+
str_on_off(enable));
12671268
mask |= SDW_DPN_INT_TEST_FAIL;
12681269
}
12691270

drivers/soundwire/debugfs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <linux/slab.h>
1111
#include <linux/soundwire/sdw.h>
1212
#include <linux/soundwire/sdw_registers.h>
13+
#include <linux/string_choices.h>
1314
#include "bus.h"
1415

1516
static struct dentry *sdw_debugfs_root;
@@ -153,7 +154,7 @@ static int set_command(void *data, u64 value)
153154
/* Userspace changed the hardware state behind the kernel's back */
154155
add_taint(TAINT_USER, LOCKDEP_STILL_OK);
155156

156-
dev_dbg(&slave->dev, "command: %s\n", value ? "read" : "write");
157+
dev_dbg(&slave->dev, "command: %s\n", str_read_write(value));
157158
cmd = value;
158159

159160
return 0;

drivers/soundwire/stream.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <linux/soundwire/sdw_registers.h>
1515
#include <linux/soundwire/sdw.h>
1616
#include <linux/soundwire/sdw_type.h>
17+
#include <linux/string_choices.h>
1718
#include <sound/soc.h>
1819
#include "bus.h"
1920

@@ -358,7 +359,7 @@ static int sdw_enable_disable_master_ports(struct sdw_master_runtime *m_rt,
358359
} else {
359360
dev_err(bus->dev,
360361
"dpn_port_enable_ch not supported, %s failed\n",
361-
en ? "enable" : "disable");
362+
str_enable_disable(en));
362363
return -EINVAL;
363364
}
364365

0 commit comments

Comments
 (0)