Skip to content

Commit fca7607

Browse files
committed
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>
1 parent 27896ff commit fca7607

File tree

3 files changed

+34
-25
lines changed

3 files changed

+34
-25
lines changed

MAINTAINERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8672,6 +8672,7 @@ GENERIC STRING LIBRARY
86728672
R: Andy Shevchenko <andy@kernel.org>
86738673
S: Maintained
86748674
F: include/linux/string.h
8675+
F: include/linux/string_choices.h
86758676
F: include/linux/string_helpers.h
86768677
F: lib/string.c
86778678
F: lib/string_helpers.c

include/linux/string_choices.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* SPDX-License-Identifier: GPL-2.0 */
2+
#ifndef _LINUX_STRING_CHOICES_H_
3+
#define _LINUX_STRING_CHOICES_H_
4+
5+
#include <linux/types.h>
6+
7+
static inline const char *str_enable_disable(bool v)
8+
{
9+
return v ? "enable" : "disable";
10+
}
11+
12+
static inline const char *str_enabled_disabled(bool v)
13+
{
14+
return v ? "enabled" : "disabled";
15+
}
16+
17+
static inline const char *str_read_write(bool v)
18+
{
19+
return v ? "read" : "write";
20+
}
21+
22+
static inline const char *str_on_off(bool v)
23+
{
24+
return v ? "on" : "off";
25+
}
26+
27+
static inline const char *str_yes_no(bool v)
28+
{
29+
return v ? "yes" : "no";
30+
}
31+
32+
#endif

include/linux/string_helpers.h

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#include <linux/bits.h>
66
#include <linux/ctype.h>
7+
#include <linux/string_choices.h>
78
#include <linux/string.h>
89
#include <linux/types.h>
910

@@ -113,29 +114,4 @@ void kfree_strarray(char **array, size_t n);
113114

114115
char **devm_kasprintf_strarray(struct device *dev, const char *prefix, size_t n);
115116

116-
static inline const char *str_yes_no(bool v)
117-
{
118-
return v ? "yes" : "no";
119-
}
120-
121-
static inline const char *str_on_off(bool v)
122-
{
123-
return v ? "on" : "off";
124-
}
125-
126-
static inline const char *str_enable_disable(bool v)
127-
{
128-
return v ? "enable" : "disable";
129-
}
130-
131-
static inline const char *str_enabled_disabled(bool v)
132-
{
133-
return v ? "enabled" : "disabled";
134-
}
135-
136-
static inline const char *str_read_write(bool v)
137-
{
138-
return v ? "read" : "write";
139-
}
140-
141117
#endif

0 commit comments

Comments
 (0)