diff options
Diffstat (limited to 'arch/microblaze/lib')
-rw-r--r-- | arch/microblaze/lib/memcpy.c | 22 | ||||
-rw-r--r-- | arch/microblaze/lib/memmove.c | 36 | ||||
-rw-r--r-- | arch/microblaze/lib/memset.c | 35 | ||||
-rw-r--r-- | arch/microblaze/lib/uaccess_old.S | 92 |
4 files changed, 31 insertions, 154 deletions
diff --git a/arch/microblaze/lib/memcpy.c b/arch/microblaze/lib/memcpy.c index f536e81b8168..9966dce55619 100644 --- a/arch/microblaze/lib/memcpy.c +++ b/arch/microblaze/lib/memcpy.c @@ -31,20 +31,7 @@ #include <linux/string.h> -#ifdef __HAVE_ARCH_MEMCPY -#ifndef CONFIG_OPT_LIB_FUNCTION -void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c) -{ - const char *src = v_src; - char *dst = v_dst; - - /* Simple, byte oriented memcpy. */ - while (c--) - *dst++ = *src++; - - return v_dst; -} -#else /* CONFIG_OPT_LIB_FUNCTION */ +#ifdef CONFIG_OPT_LIB_FUNCTION void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c) { const char *src = v_src; @@ -68,9 +55,11 @@ void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c) case 1: *dst++ = *src++; --c; + fallthrough; case 2: *dst++ = *src++; --c; + fallthrough; case 3: *dst++ = *src++; --c; @@ -176,14 +165,15 @@ void *memcpy(void *v_dst, const void *v_src, __kernel_size_t c) switch (c) { case 3: *dst++ = *src++; + fallthrough; case 2: *dst++ = *src++; + fallthrough; case 1: *dst++ = *src++; } return v_dst; } -#endif /* CONFIG_OPT_LIB_FUNCTION */ EXPORT_SYMBOL(memcpy); -#endif /* __HAVE_ARCH_MEMCPY */ +#endif /* CONFIG_OPT_LIB_FUNCTION */ diff --git a/arch/microblaze/lib/memmove.c b/arch/microblaze/lib/memmove.c index 3611ce70415b..c1f08c484e20 100644 --- a/arch/microblaze/lib/memmove.c +++ b/arch/microblaze/lib/memmove.c @@ -30,31 +30,7 @@ #include <linux/compiler.h> #include <linux/string.h> -#ifdef __HAVE_ARCH_MEMMOVE -#ifndef CONFIG_OPT_LIB_FUNCTION -void *memmove(void *v_dst, const void *v_src, __kernel_size_t c) -{ - const char *src = v_src; - char *dst = v_dst; - - if (!c) - return v_dst; - - /* Use memcpy when source is higher than dest */ - if (v_dst <= v_src) - return memcpy(v_dst, v_src, c); - - /* copy backwards, from end to beginning */ - src += c; - dst += c; - - /* Simple, byte oriented memmove. */ - while (c--) - *--dst = *--src; - - return v_dst; -} -#else /* CONFIG_OPT_LIB_FUNCTION */ +#ifdef CONFIG_OPT_LIB_FUNCTION void *memmove(void *v_dst, const void *v_src, __kernel_size_t c) { const char *src = v_src; @@ -90,9 +66,11 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c) case 3: *--dst = *--src; --c; + fallthrough; case 2: *--dst = *--src; --c; + fallthrough; case 1: *--dst = *--src; --c; @@ -100,7 +78,7 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c) i_dst = (void *)dst; /* Choose a copy scheme based on the source */ - /* alignment relative to dstination. */ + /* alignment relative to destination. */ switch ((unsigned long)src & 3) { case 0x0: /* Both byte offsets are aligned */ @@ -201,15 +179,17 @@ void *memmove(void *v_dst, const void *v_src, __kernel_size_t c) switch (c) { case 4: *--dst = *--src; + fallthrough; case 3: *--dst = *--src; + fallthrough; case 2: *--dst = *--src; + fallthrough; case 1: *--dst = *--src; } return v_dst; } -#endif /* CONFIG_OPT_LIB_FUNCTION */ EXPORT_SYMBOL(memmove); -#endif /* __HAVE_ARCH_MEMMOVE */ +#endif /* CONFIG_OPT_LIB_FUNCTION */ 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 */ diff --git a/arch/microblaze/lib/uaccess_old.S b/arch/microblaze/lib/uaccess_old.S index 0e8cc2710c27..dd5f3bfbc2c5 100644 --- a/arch/microblaze/lib/uaccess_old.S +++ b/arch/microblaze/lib/uaccess_old.S @@ -12,96 +12,6 @@ #include <linux/linkage.h> #include <asm/page.h> -/* - * int __strncpy_user(char *to, char *from, int len); - * - * Returns: - * -EFAULT for an exception - * len if we hit the buffer limit - * bytes copied - */ - - .text -.globl __strncpy_user; -.type __strncpy_user, @function -.align 4; -__strncpy_user: - - /* - * r5 - to - * r6 - from - * r7 - len - * r3 - temp count - * r4 - temp val - */ - beqid r7,3f - addik r3,r7,0 /* temp_count = len */ -1: - lbu r4,r6,r0 - beqid r4,2f - sb r4,r5,r0 - - addik r5,r5,1 - addik r6,r6,1 /* delay slot */ - - addik r3,r3,-1 - bnei r3,1b /* break on len */ -2: - rsubk r3,r3,r7 /* temp_count = len - temp_count */ -3: - rtsd r15,8 - nop - .size __strncpy_user, . - __strncpy_user - - .section .fixup, "ax" - .align 2 -4: - brid 3b - addik r3,r0, -EFAULT - - .section __ex_table, "a" - .word 1b,4b - -/* - * int __strnlen_user(char __user *str, int maxlen); - * - * Returns: - * 0 on error - * maxlen + 1 if no NUL byte found within maxlen bytes - * size of the string (including NUL byte) - */ - - .text -.globl __strnlen_user; -.type __strnlen_user, @function -.align 4; -__strnlen_user: - beqid r6,3f - addik r3,r6,0 -1: - lbu r4,r5,r0 - beqid r4,2f /* break on NUL */ - addik r3,r3,-1 /* delay slot */ - - bneid r3,1b - addik r5,r5,1 /* delay slot */ - - addik r3,r3,-1 /* for break on len */ -2: - rsubk r3,r3,r6 -3: - rtsd r15,8 - nop - .size __strnlen_user, . - __strnlen_user - - .section .fixup,"ax" -4: - brid 3b - addk r3,r0,r0 - - .section __ex_table,"a" - .word 1b,4b - /* Loop unrolling for __copy_tofrom_user */ #define COPY(offset) \ 1: lwi r4 , r6, 0x0000 + offset; \ @@ -188,7 +98,7 @@ w2: sw r4, r5, r3 .text .align 4 /* Alignment is important to keep icache happy */ -page: /* Create room on stack and save registers for storign values */ +page: /* Create room on stack and save registers for storing values */ addik r1, r1, -40 swi r5, r1, 0 swi r6, r1, 4 |