[PATCH 1/6] lib/string_choices: add few more convenient choice helpers

From: Dmitry Antipov

Date: Thu Aug 20 2026 - 02:12:32 EST


Looking over a few kernel subsystems I'm currently working
on, I suppose that 'str_pass_fail()', 'str_passed_failed()',
'str_lock_unlock()' and 'str_locked_unlocked()' with their
opposite counterpart macros may be useful as well.

Signed-off-by: Dmitry Antipov <dmantipov@xxxxxxxxx>
---
include/linux/string_choices.h | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)

diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h
index ee84087d4b26..8cdfc24dd4e1 100644
--- a/include/linux/string_choices.h
+++ b/include/linux/string_choices.h
@@ -53,12 +53,36 @@ static inline const char *str_input_output(bool v)
}
#define str_output_input(v) str_input_output(!(v))

+static inline const char *str_lock_unlock(bool v)
+{
+ return v ? "lock" : "unlock";
+}
+#define str_unlock_lock(v) str_lock_unlock(!(v))
+
+static inline const char *str_locked_unlocked(bool v)
+{
+ return v ? "locked" : "unlocked";
+}
+#define str_unlocked_locked(v) str_locked_unlocked(!(v))
+
static inline const char *str_on_off(bool v)
{
return v ? "on" : "off";
}
#define str_off_on(v) str_on_off(!(v))

+static inline const char *str_pass_fail(bool v)
+{
+ return v ? "pass" : "fail";
+}
+#define str_fail_pass(v) str_pass_fail(!(v))
+
+static inline const char *str_passed_failed(bool v)
+{
+ return v ? "passed" : "failed";
+}
+#define str_failed_passed(v) str_passed_failed(!(v))
+
static inline const char *str_read_write(bool v)
{
return v ? "read" : "write";
--
2.55.0