[PATCH v4 11/12] lib/string_choices: Add str_input_output() helper

Thomas Richard posted 12 patches 9 months, 2 weeks ago
There is a newer version of this series
[PATCH v4 11/12] lib/string_choices: Add str_input_output() helper
Posted by Thomas Richard 9 months, 2 weeks ago
Add str_input_output() helper to return 'input' or 'output' string literal.
Also add the inversed variant str_output_input().

Signed-off-by: Thomas Richard <thomas.richard@bootlin.com>
---
 include/linux/string_choices.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h
index f3ba4f52ff26..ca2f37fa1b84 100644
--- a/include/linux/string_choices.h
+++ b/include/linux/string_choices.h
@@ -41,6 +41,12 @@ static inline const char *str_high_low(bool v)
 }
 #define str_low_high(v)		str_high_low(!(v))
 
+static inline const char *str_input_output(bool v)
+{
+	return v ? "input" : "output";
+}
+#define str_output_input	str_input_output(!(v))
+
 static inline const char *str_on_off(bool v)
 {
 	return v ? "on" : "off";

-- 
2.39.5
Re: [PATCH v4 11/12] lib/string_choices: Add str_input_output() helper
Posted by Andy Shevchenko 9 months, 2 weeks ago
On Tue, Apr 29, 2025 at 5:08 PM Thomas Richard
<thomas.richard@bootlin.com> wrote:
>
> Add str_input_output() helper to return 'input' or 'output' string literal.
> Also add the inversed variant str_output_input().

...

> +static inline const char *str_input_output(bool v)
> +{
> +       return v ? "input" : "output";
> +}
> +#define str_output_input       str_input_output(!(v))

Missing argument in the definition of a new macro.

With that being addressed,
Reviewed-by: Andy Shevchenko <andy@kernel.org>

-- 
With Best Regards,
Andy Shevchenko