From 60c03a0448c7144d01ef437aae0a1c7e2367b4ba Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Thu, 1 Mar 2018 09:18:22 -0600 Subject: ARM: boot: add strrchr function libfdt gained a new dependency on strrchr, so copy the implementation from lib/string.c. Cc: Russell King Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Rob Herring --- arch/arm/boot/compressed/string.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'arch') diff --git a/arch/arm/boot/compressed/string.c b/arch/arm/boot/compressed/string.c index 13c90abc68d6..ade5079bebbf 100644 --- a/arch/arm/boot/compressed/string.c +++ b/arch/arm/boot/compressed/string.c @@ -121,6 +121,16 @@ char *strchr(const char *s, int c) return (char *)s; } +char *strrchr(const char *s, int c) +{ + const char *last = NULL; + do { + if (*s == (char)c) + last = s; + } while (*s++); + return (char *)last; +} + #undef memset void *memset(void *s, int c, size_t count) -- cgit v1.2.3 From fdfb69a72522e97f9105a6d39a5be0a465951ed8 Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Thu, 1 Mar 2018 10:12:07 -0600 Subject: arm64/efi: Make strrchr() available to the EFI namespace libfdt gained a new dependency on strrchr, so make it available to the EFI namespace before we update libfdt. Thanks to Ard for providing this fix. Cc: Catalin Marinas Acked-by: Ard Biesheuvel Acked-by: Will Deacon Signed-off-by: Rob Herring --- arch/arm64/kernel/image.h | 1 + arch/arm64/lib/strrchr.S | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'arch') diff --git a/arch/arm64/kernel/image.h b/arch/arm64/kernel/image.h index c7fcb232fe47..a820ed07fb80 100644 --- a/arch/arm64/kernel/image.h +++ b/arch/arm64/kernel/image.h @@ -103,6 +103,7 @@ __efistub_strlen = KALLSYMS_HIDE(__pi_strlen); __efistub_strnlen = KALLSYMS_HIDE(__pi_strnlen); __efistub_strcmp = KALLSYMS_HIDE(__pi_strcmp); __efistub_strncmp = KALLSYMS_HIDE(__pi_strncmp); +__efistub_strrchr = KALLSYMS_HIDE(__pi_strrchr); __efistub___flush_dcache_area = KALLSYMS_HIDE(__pi___flush_dcache_area); #ifdef CONFIG_KASAN diff --git a/arch/arm64/lib/strrchr.S b/arch/arm64/lib/strrchr.S index 61eabd9a289a..f8e2784d5752 100644 --- a/arch/arm64/lib/strrchr.S +++ b/arch/arm64/lib/strrchr.S @@ -40,4 +40,4 @@ ENTRY(strrchr) b 1b 2: mov x0, x3 ret -ENDPROC(strrchr) +ENDPIPROC(strrchr) -- cgit v1.2.3 From a54b81ea242309a098162c3284ed964074bee72a Mon Sep 17 00:00:00 2001 From: Rob Herring Date: Thu, 1 Mar 2018 08:57:40 -0600 Subject: powerpc: boot: add strrchr function libfdt gained a new dependency on strrchr, so copy the implementation from lib/string.c. Most of the string functions are in assembly, but stdio.c already has strnlen, so add strrchr there. Cc: Benjamin Herrenschmidt Cc: Paul Mackerras Acked-by: Michael Ellerman Signed-off-by: Rob Herring --- arch/powerpc/boot/stdio.c | 10 ++++++++++ arch/powerpc/boot/string.h | 1 + 2 files changed, 11 insertions(+) (limited to 'arch') diff --git a/arch/powerpc/boot/stdio.c b/arch/powerpc/boot/stdio.c index a701261b1781..98042eff7b26 100644 --- a/arch/powerpc/boot/stdio.c +++ b/arch/powerpc/boot/stdio.c @@ -21,6 +21,16 @@ size_t strnlen(const char * s, size_t count) return sc - s; } +char *strrchr(const char *s, int c) +{ + const char *last = NULL; + do { + if (*s == (char)c) + last = s; + } while (*s++); + return (char *)last; +} + #ifdef __powerpc64__ # define do_div(n, base) ({ \ diff --git a/arch/powerpc/boot/string.h b/arch/powerpc/boot/string.h index 3fb71171da49..8c2ec0c05e4e 100644 --- a/arch/powerpc/boot/string.h +++ b/arch/powerpc/boot/string.h @@ -7,6 +7,7 @@ extern char *strcpy(char *dest, const char *src); extern char *strncpy(char *dest, const char *src, size_t n); extern char *strcat(char *dest, const char *src); extern char *strchr(const char *s, int c); +extern char *strrchr(const char *s, int c); extern int strcmp(const char *s1, const char *s2); extern int strncmp(const char *s1, const char *s2, size_t n); extern size_t strlen(const char *s); -- cgit v1.2.3