MIPS: ZBOOT: gather string functions into string.c
PATCH v2 1/1 MIPS: ZBOOT: gather string functions into string.c
In the worst case this adds less then 128 bytes of code but on the other hand this makes code organization more clear.
Signed-off-by Antony Pavlov <[email protected]>
Cc Ralf Baechle <[email protected]>
Cc Florian Fainelli <[email protected]>
--- arch/mips/boot/compressed/Makefile | 4 ++-- arch/mips/boot/compressed/decompress.c | 22 ---------------------- arch/mips/boot/compressed/string.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 24 deletions(-) create mode 100644 arch/mips/boot/compressed/string.c
arch/mips/boot/compressed/Makefile +2 -2
@@ -27,10 +27,10 @@ KBUILD_AFLAGS := $(LINUXINCLUDE) $(KBUILD_AFLAGS) -D__ASSEMBLY__ \ -DBOOT_HEAP_SIZE=$(BOOT_HEAP_SIZE) \ -DKERNEL_ENTRY=$(VMLINUX_ENTRY_ADDRESS) -targets := head.o decompress.o dbg.o uart-16550.o uart-alchemy.o +targets := head.o decompress.o string.o dbg.o uart-16550.o uart-alchemy.o # decompressor objects (linked with vmlinuz) -vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/dbg.o +vmlinuzobjs-y := $(obj)/head.o $(obj)/decompress.o $(obj)/string.o $(obj)/dbg.o ifdef CONFIG_DEBUG_ZBOOT vmlinuzobjs-$(CONFIG_SYS_SUPPORTS_ZBOOT_UART16550) += $(obj)/uart-16550.o
arch/mips/boot/compressed/decompress.c +0 -22
@@ -43,33 +43,11 @@ void error(char *x)/* activate the code for pre-boot environment */ #define STATIC static -#if defined(CONFIG_KERNEL_GZIP ) || defined(CONFIG_KERNEL_XZ ) || \ - defined(CONFIG_KERNEL_LZ4 ) -void *memcpy (void *dest,const void *src,size_t n) -{ -int i; -const char *s = src; -char *d = dest; - -for (i =0 ; i < n; i++) - d[i] = s[i]; -return dest; -} -#endif #ifdef CONFIG_KERNEL_GZIP #include "../../../../lib/decompress_inflate.c" #endif #ifdef CONFIG_KERNEL_BZIP2 -void *memset (void *s,int c,size_t n) -{ -int i; -char *ss = s; - -for (i =0 ; i < n; i++) - ss[i] = c; -return s; -}#include "../../../../lib/decompress_bunzip2.c" #endif
arch/mips/boot/compressed/string.c new file +28 -0
@@ -0,0 +1,28 @@ +/* +* arch/mips/boot/compressed/string.c +* +* Very small subset of simple string routines +*/ + +#include <linux/string.h> + +void *memcpy (void *dest,const void *src,size_t n) +{ +int i; +const char *s = src; +char *d = dest; + +for (i =0 ; i < n; i++) + d[i] = s[i]; +return dest; +} + +void *memset (void *s,int c,size_t n) +{ +int i; +char *ss = s; + +for (i =0 ; i < n; i++) + ss[i] = c; +return s; +}
Signature · 1 line
1.8.4.rc3
2013/9/29 Antony Pavlov <[email protected]>:
Quoted 4 lines
In the worst case this adds less then 128 bytes of code but on the other hand this makes code organization more clear.
Signed-off-by Antony Pavlov <[email protected]>
Just one minor comment below, but not a big problem.
Reviewed-by Florian Fainelli <[email protected]>
[snip]
arch/mips/boot/compressed/string.c line 7
Quoted 7 lines
arch/mips/boot/compressed/string.c new file +7
-0+/* +* arch/mips/boot/compressed/string.c +* +* Very small subset of simple string routines +*/ + +#include <linux/string.h>
Nitpick: only linux/types.h is actually required for size_t, but this is not a big deal.
Quoted 24 lines
arch/mips/boot/compressed/string.c new file +21
-1+ +void *memcpy (void *dest,const void *src,size_t n) +{ +int i; +const char *s = src; +char *d = dest; + +for (i =0 ; i < n; i++) + d[i] = s[i]; +return dest; +} + +void *memset (void *s,int c,size_t n) +{ +int i; +char *ss = s; + +for (i =0 ; i < n; i++) + ss[i] = c; +return s; +} --1.8.4.rc3
Signature · 1 line
Florian