Add str_alloc_free() helper to return "alloc" or "free"
string literal depending on the boolean argument. Also add the
inversed variant str_free_alloc().

Tested-by: mingzhu.wang <[email protected]>
Signed-off-by: Jiazi Li <[email protected]>
---
 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 ee84087d4b26..65f346db95ba 100644
--- a/include/linux/string_choices.h
+++ b/include/linux/string_choices.h
@@ -17,6 +17,12 @@
 
 #include <linux/types.h>
 
+static inline const char *str_alloc_free(bool v)
+{
+       return v ? "alloc" : "free";
+}
+#define str_free_alloc(v)              str_alloc_free(!(v))
+
 static inline const char *str_assert_deassert(bool v)
 {
        return v ? "assert" : "deassert";
-- 
2.49.0


Reply via email to