diff mbox series

[24/27] kconfig: move strhash() to a header

Message ID 20240202155825.314567-25-masahiroy@kernel.org (mailing list archive)
State New
Headers show
Series kconfig: refactor lexer and parser code | expand

Commit Message

Masahiro Yamada Feb. 2, 2024, 3:58 p.m. UTC
Move strhash() to a header, so it can be used from other files.

Signed-off-by: Masahiro Yamada <masahiroy@kernel.org>
---

 scripts/kconfig/symbol.c | 10 +---------
 scripts/kconfig/util.h   | 15 +++++++++++++++
 2 files changed, 16 insertions(+), 9 deletions(-)
 create mode 100644 scripts/kconfig/util.h
diff mbox series

Patch

diff --git a/scripts/kconfig/symbol.c b/scripts/kconfig/symbol.c
index dae630a74e50..518977c525de 100644
--- a/scripts/kconfig/symbol.c
+++ b/scripts/kconfig/symbol.c
@@ -10,6 +10,7 @@ 
 #include <regex.h>
 
 #include "lkc.h"
+#include "util.h"
 
 struct symbol symbol_yes = {
 	.name = "y",
@@ -803,15 +804,6 @@  bool sym_is_changeable(struct symbol *sym)
 	return sym->visible > sym->rev_dep.tri;
 }
 
-static unsigned strhash(const char *s)
-{
-	/* fnv32 hash */
-	unsigned hash = 2166136261U;
-	for (; *s; s++)
-		hash = (hash ^ *s) * 0x01000193;
-	return hash;
-}
-
 struct symbol *sym_lookup(const char *name, int flags)
 {
 	struct symbol *symbol;
diff --git a/scripts/kconfig/util.h b/scripts/kconfig/util.h
new file mode 100644
index 000000000000..d4e35bee6450
--- /dev/null
+++ b/scripts/kconfig/util.h
@@ -0,0 +1,15 @@ 
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef UTIL_H
+#define UTIL_H
+
+static unsigned int strhash(const char *s)
+{
+	/* fnv32 hash */
+	unsigned int hash = 2166136261U;
+
+	for (; *s; s++)
+		hash = (hash ^ *s) * 0x01000193;
+	return hash;
+}
+
+#endif /* UTIL_H */