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>
#include <linux/soundwire/sdw_registers.h>
#include <linux/soundwire/sdw.h>
#include <linux/soundwire/sdw_type.h>
+#include <linux/string_choices.h>
#include "bus.h"
#include "irq.h"
#include "sysfs_local.h"
if (ret != 0 && ret != -ENODATA)
dev_err(bus->dev, "trf on Slave %d failed:%d %s addr %x count %d\n",
msg->dev_num, ret,
- (msg->flags & SDW_MSG_FLAG_WRITE) ? "write" : "read",
+ str_write_read(msg->flags & SDW_MSG_FLAG_WRITE),
msg->addr, msg->len);
return ret;
if (slave->bus->params.s_data_mode != SDW_PORT_DATA_MODE_NORMAL) {
dev_dbg(&slave->dev, "TEST FAIL interrupt %s\n",
- enable ? "on" : "off");
+ str_on_off(enable));
mask |= SDW_DPN_INT_TEST_FAIL;
}
#include <linux/slab.h>
#include <linux/soundwire/sdw.h>
#include <linux/soundwire/sdw_registers.h>
+#include <linux/string_choices.h>
#include "bus.h"
static struct dentry *sdw_debugfs_root;
/* Userspace changed the hardware state behind the kernel's back */
add_taint(TAINT_USER, LOCKDEP_STILL_OK);
- dev_dbg(&slave->dev, "command: %s\n", value ? "read" : "write");
+ dev_dbg(&slave->dev, "command: %s\n", str_read_write(value));
cmd = value;
return 0;
#include <linux/soundwire/sdw_registers.h>
#include <linux/soundwire/sdw.h>
#include <linux/soundwire/sdw_type.h>
+#include <linux/string_choices.h>
#include <sound/soc.h>
#include "bus.h"
} else {
dev_err(bus->dev,
"dpn_port_enable_ch not supported, %s failed\n",
- en ? "enable" : "disable");
+ str_enable_disable(en));
return -EINVAL;
}