summaryrefslogtreecommitdiff
path: root/arch/microblaze/lib/memset.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/microblaze/lib/memset.c')
-rw-r--r--arch/microblaze/lib/memset.c35
1 files changed, 16 insertions, 19 deletions
diff --git a/arch/microblaze/lib/memset.c b/arch/microblaze/lib/memset.c
index 04ea72c8a81d..7c2352d56bb0 100644
--- a/arch/microblaze/lib/memset.c
+++ b/arch/microblaze/lib/memset.c
@@ -30,22 +30,7 @@
#include <linux/compiler.h>
#include <linux/string.h>
-#ifdef __HAVE_ARCH_MEMSET
-#ifndef CONFIG_OPT_LIB_FUNCTION
-void *memset(void *v_src, int c, __kernel_size_t n)
-{
- char *src = v_src;
-
- /* Truncate c to 8 bits */
- c = (c & 0xFF);
-
- /* Simple, byte oriented memset or the rest of count. */
- while (n--)
- *src++ = c;
-
- return v_src;
-}
-#else /* CONFIG_OPT_LIB_FUNCTION */
+#ifdef CONFIG_OPT_LIB_FUNCTION
void *memset(void *v_src, int c, __kernel_size_t n)
{
char *src = v_src;
@@ -69,9 +54,11 @@ void *memset(void *v_src, int c, __kernel_size_t n)
case 1:
*src++ = c;
--n;
+ fallthrough;
case 2:
*src++ = c;
--n;
+ fallthrough;
case 3:
*src++ = c;
--n;
@@ -87,11 +74,21 @@ void *memset(void *v_src, int c, __kernel_size_t n)
}
/* Simple, byte oriented memset or the rest of count. */
- while (n--)
+ switch (n) {
+ case 3:
+ *src++ = c;
+ fallthrough;
+ case 2:
*src++ = c;
+ fallthrough;
+ case 1:
+ *src++ = c;
+ break;
+ default:
+ break;
+ }
return v_src;
}
-#endif /* CONFIG_OPT_LIB_FUNCTION */
EXPORT_SYMBOL(memset);
-#endif /* __HAVE_ARCH_MEMSET */
+#endif /* CONFIG_OPT_LIB_FUNCTION */