R Sundar
b56e601afb
lib/string_choices: Rearrange functions in sorted order
...
Rearrange misplaced functions in sorted order.
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com >
Signed-off-by: R Sundar <prosunofficial@gmail.com >
Reviewed-by: Larysa Zaremba <larysa.zaremba@intel.com >
Link: https://lore.kernel.org/r/20241119021719.7659-2-prosunofficial@gmail.com
Signed-off-by: Kees Cook <kees@kernel.org >
2025-03-03 09:35:50 -08:00
Hongbo Li
c121d5cc3a
lib/string_choices: Add some comments to make more clear for string choices helpers.
...
Add some comments to explain why we should use string_choices helpers.
Signed-off-by: Hongbo Li <lihongbo22@huawei.com >
Acked-by: Andy Shevchenko <andy@kernel.org >
Link: https://lore.kernel.org/r/20240905092540.2962122-3-lihongbo22@huawei.com
Signed-off-by: Kees Cook <kees@kernel.org >
2024-09-05 09:50:16 -07:00
Hongbo Li
c2708ba91c
lib/string_choices: Introduce several opposite string choice helpers
...
Similar to the exists helper: str_enable_disable/
str_enabled_disabled/str_on_off/str_yes_no helpers, we can
add the opposite helpers. That's str_disable_enable,
str_disabled_enabled, str_off_on and str_no_yes.
There are more than 10 cases currently (expect
str_disable_enable now has 3 use cases) exist in the code
can be replaced with these helper.
Signed-off-by: Hongbo Li <lihongbo22@huawei.com >
Acked-by: Andy Shevchenko <andy@kernel.org >
Link: https://lore.kernel.org/r/20240905092540.2962122-2-lihongbo22@huawei.com
Signed-off-by: Kees Cook <kees@kernel.org >
2024-09-05 09:50:15 -07:00
Hongbo Li
6ff4cd1160
lib/string_choices: Add str_true_false()/str_false_true() helper
...
Add str_true_false()/str_false_true() helper to return "true" or
"false" string literal.
Signed-off-by: Hongbo Li <lihongbo22@huawei.com >
Link: https://lore.kernel.org/r/20240827024517.914100-2-lihongbo22@huawei.com
Signed-off-by: Kees Cook <kees@kernel.org >
2024-09-05 09:48:40 -07:00
Kees Cook
f5c1ca3a15
string_choices: Add wrapper for str_down_up()
...
The string choice functions which are not clearly true/false synonyms
also have inverted wrappers. Add this for str_down_up() as well.
Suggested-by: Andy Shevchenko <andy.shevchenko@gmail.com >
Link: https://lore.kernel.org/r/20240812182939.work.424-kees@kernel.org
Reviewed-by: Andy Shevchenko <andy@kernel.org >
Signed-off-by: Kees Cook <kees@kernel.org >
2024-08-15 09:26:02 -07:00
Michal Wajdeczko
a98ae7f045
lib/string_choices: Add str_up_down() helper
...
Add str_up_down() helper to return "up" or "down" string literal.
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com >
Link: https://lore.kernel.org/r/20240725101841.574-1-michal.wajdeczko@intel.com
Signed-off-by: Kees Cook <kees@kernel.org >
2024-08-15 09:26:02 -07:00
Michal Wajdeczko
9ca5facd04
lib/string_choices: Add str_plural() helper
...
Add str_plural() helper to replace existing open implementations
used by many drivers and help improve future user facing messages.
Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com >
Link: https://lore.kernel.org/r/20240214165015.1656-1-michal.wajdeczko@intel.com
Signed-off-by: Kees Cook <keescook@chromium.org >
2024-02-29 13:38:01 -08:00
Andy Shevchenko
81e4fc6741
lib/string_choices: Add str_write_read() helper
...
Add an inversed variant of str_read_write(), i.e. str_write_read().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com >
Link: https://lore.kernel.org/r/20230703185222.50554-2-andriy.shevchenko@linux.intel.com
Signed-off-by: Benjamin Tissoires <bentiss@kernel.org >
2023-07-28 17:05:47 +02:00
Andy Shevchenko
a9fc76645c
lib/string_choices: Add str_high_low() helper
...
Add str_high_low() helper to return 'high' or 'low' string literal.
Also add an inversed variant, i.e. str_low_high().
All the same for str_hi_low().
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com >
2023-06-12 20:14:22 +03:00
Andy Shevchenko
fca76071ba
lib/string_helpers: Split out string_choices.h
...
Some users may only need the string choice APIs. Split
the respective header, i.e. string_choices.h. Include
it in the string_helpers.h for backward compatibility.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com >
2023-06-12 20:14:21 +03:00