diff mbox series

[07/10] lib/string_choices: Add str_to_from() helper

Message ID 87o6yp6ze7.wl-kuninori.morimoto.gx@renesas.com (mailing list archive)
State Superseded
Headers show
Series lib/string_choices: Add new helpers | expand

Commit Message

Kuninori Morimoto Feb. 26, 2025, 5:36 a.m. UTC
Add str_to_from() helper to return "to" or "from" string literal.

Signed-off-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>
---
 include/linux/string_choices.h | 6 ++++++
 1 file changed, 6 insertions(+)
diff mbox series

Patch

diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h
index d52ced93e21e..e07a9a5e403e 100644
--- a/include/linux/string_choices.h
+++ b/include/linux/string_choices.h
@@ -107,6 +107,12 @@  static inline const char *str_pass_fail(bool v)
 }
 #define str_fail_pass(v)	str_pass_fail(!(v))
 
+static inline const char *str_to_from(bool v)
+{
+	return v ? "to" : "from";
+}
+#define str_from_to(v)		str_to_from(!(v))
+
 /**
  * str_plural - Return the simple pluralization based on English counts
  * @num: Number used for deciding pluralization