public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 1/3] lib/string_helpers: Add missing header files to MAINTAINERS database
@ 2022-11-30 11:50 Andy Shevchenko
  2022-11-30 11:50 ` [PATCH v1 2/3] lib/string_helpers: Add str_high_low() helper Andy Shevchenko
  2022-11-30 11:50 ` [PATCH v1 3/3] lib/string_helpers: Split out string_choices.h Andy Shevchenko
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2022-11-30 11:50 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel
  Cc: Andy Shevchenko, Hans de Goede, platform-driver-x86

The header files string.h and string_helpers.h are missing in
the MAINTAINERS. Add them.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 MAINTAINERS | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 331dc0e3e5f9..c1f0310dae18 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8721,6 +8721,8 @@ F:	drivers/input/touchscreen/resistive-adc-touch.c
 GENERIC STRING LIBRARY
 R:	Andy Shevchenko <andy@kernel.org>
 S:	Maintained
+F:	include/linux/string.h
+F:	include/linux/string_helpers.h
 F:	lib/string.c
 F:	lib/string_helpers.c
 F:	lib/test_string.c
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v1 2/3] lib/string_helpers: Add str_high_low() helper
  2022-11-30 11:50 [PATCH v1 1/3] lib/string_helpers: Add missing header files to MAINTAINERS database Andy Shevchenko
@ 2022-11-30 11:50 ` Andy Shevchenko
  2022-11-30 11:50 ` [PATCH v1 3/3] lib/string_helpers: Split out string_choices.h Andy Shevchenko
  1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2022-11-30 11:50 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel
  Cc: Andy Shevchenko, Hans de Goede, platform-driver-x86

Add str_high_low() helper to return 'high' or 'low' string literal.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 include/linux/string_helpers.h | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h
index 8530c7328269..fd72393e7975 100644
--- a/include/linux/string_helpers.h
+++ b/include/linux/string_helpers.h
@@ -128,6 +128,11 @@ static inline const char *str_enabled_disabled(bool v)
 	return v ? "enabled" : "disabled";
 }
 
+static inline const char *str_high_low(bool v)
+{
+	return v ? "high" : "low";
+}
+
 static inline const char *str_read_write(bool v)
 {
 	return v ? "read" : "write";
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v1 3/3] lib/string_helpers: Split out string_choices.h
  2022-11-30 11:50 [PATCH v1 1/3] lib/string_helpers: Add missing header files to MAINTAINERS database Andy Shevchenko
  2022-11-30 11:50 ` [PATCH v1 2/3] lib/string_helpers: Add str_high_low() helper Andy Shevchenko
@ 2022-11-30 11:50 ` Andy Shevchenko
  2022-11-30 11:51   ` Andy Shevchenko
  1 sibling, 1 reply; 4+ messages in thread
From: Andy Shevchenko @ 2022-11-30 11:50 UTC (permalink / raw)
  To: Andy Shevchenko, linux-kernel
  Cc: Andy Shevchenko, Hans de Goede, platform-driver-x86

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.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 MAINTAINERS                    |  1 +
 include/linux/string_choices.h | 37 ++++++++++++++++++++++++++++++++++
 include/linux/string_helpers.h | 31 +---------------------------
 3 files changed, 39 insertions(+), 30 deletions(-)
 create mode 100644 include/linux/string_choices.h

diff --git a/MAINTAINERS b/MAINTAINERS
index c1f0310dae18..b16c2488f05a 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8722,6 +8722,7 @@ GENERIC STRING LIBRARY
 R:	Andy Shevchenko <andy@kernel.org>
 S:	Maintained
 F:	include/linux/string.h
+F:	include/linux/string_choices.h
 F:	include/linux/string_helpers.h
 F:	lib/string.c
 F:	lib/string_helpers.c
diff --git a/include/linux/string_choices.h b/include/linux/string_choices.h
new file mode 100644
index 000000000000..ff7e202808a9
--- /dev/null
+++ b/include/linux/string_choices.h
@@ -0,0 +1,37 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+#ifndef _LINUX_STRING_CHOICES_H_
+#define _LINUX_STRING_CHOICES_H_
+
+#include <linux/types.h>
+
+static inline const char *str_enable_disable(bool v)
+{
+	return v ? "enable" : "disable";
+}
+
+static inline const char *str_enabled_disabled(bool v)
+{
+	return v ? "enabled" : "disabled";
+}
+
+static inline const char *str_high_low(bool v)
+{
+	return v ? "high" : "low";
+}
+
+static inline const char *str_read_write(bool v)
+{
+	return v ? "read" : "write";
+}
+
+static inline const char *str_on_off(bool v)
+{
+	return v ? "on" : "off";
+}
+
+static inline const char *str_yes_no(bool v)
+{
+	return v ? "yes" : "no";
+}
+
+#endif
diff --git a/include/linux/string_helpers.h b/include/linux/string_helpers.h
index fd72393e7975..88fb8e1d0421 100644
--- a/include/linux/string_helpers.h
+++ b/include/linux/string_helpers.h
@@ -5,6 +5,7 @@
 #include <linux/bits.h>
 #include <linux/ctype.h>
 #include <linux/string.h>
+#include <linux/string_choices.h>
 #include <linux/types.h>
 
 struct device;
@@ -108,34 +109,4 @@ void kfree_strarray(char **array, size_t n);
 
 char **devm_kasprintf_strarray(struct device *dev, const char *prefix, size_t n);
 
-static inline const char *str_yes_no(bool v)
-{
-	return v ? "yes" : "no";
-}
-
-static inline const char *str_on_off(bool v)
-{
-	return v ? "on" : "off";
-}
-
-static inline const char *str_enable_disable(bool v)
-{
-	return v ? "enable" : "disable";
-}
-
-static inline const char *str_enabled_disabled(bool v)
-{
-	return v ? "enabled" : "disabled";
-}
-
-static inline const char *str_high_low(bool v)
-{
-	return v ? "high" : "low";
-}
-
-static inline const char *str_read_write(bool v)
-{
-	return v ? "read" : "write";
-}
-
 #endif
-- 
2.35.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 3/3] lib/string_helpers: Split out string_choices.h
  2022-11-30 11:50 ` [PATCH v1 3/3] lib/string_helpers: Split out string_choices.h Andy Shevchenko
@ 2022-11-30 11:51   ` Andy Shevchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2022-11-30 11:51 UTC (permalink / raw)
  To: linux-kernel; +Cc: Hans de Goede, platform-driver-x86

On Wed, Nov 30, 2022 at 01:50:22PM +0200, Andy Shevchenko wrote:
> 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.

This one can be skipped for now, can be considered just an idea.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-30 11:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-30 11:50 [PATCH v1 1/3] lib/string_helpers: Add missing header files to MAINTAINERS database Andy Shevchenko
2022-11-30 11:50 ` [PATCH v1 2/3] lib/string_helpers: Add str_high_low() helper Andy Shevchenko
2022-11-30 11:50 ` [PATCH v1 3/3] lib/string_helpers: Split out string_choices.h Andy Shevchenko
2022-11-30 11:51   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox