diff mbox

[U-Boot,2/2] board_init.c: Always use memset()

Message ID 1484244963-11937-2-git-send-email-trini@konsulko.com
State Accepted
Commit c67c8c604b6cea341055140cbfa9e6949fcacb7f
Delegated to: Tom Rini
Headers show

Commit Message

Tom Rini Jan. 12, 2017, 6:16 p.m. UTC
We can make the code read more easily here by simply using memset()
always as when we don't have an optimized version of the function we
will still have a version of this function around anyhow.

Cc: Simon Glass <sjg@chromium.org>
Signed-off-by: Tom Rini <trini@konsulko.com>
---
 common/init/board_init.c | 18 ------------------
 1 file changed, 18 deletions(-)

Comments

Simon Glass Jan. 19, 2017, 1:57 p.m. UTC | #1
On 12 January 2017 at 11:16, Tom Rini <trini@konsulko.com> wrote:
> We can make the code read more easily here by simply using memset()
> always as when we don't have an optimized version of the function we
> will still have a version of this function around anyhow.
>
> Cc: Simon Glass <sjg@chromium.org>
> Signed-off-by: Tom Rini <trini@konsulko.com>
> ---
>  common/init/board_init.c | 18 ------------------
>  1 file changed, 18 deletions(-)

I recall this didn't work before, but I'm pleased it now does.

Reviewed-by: Simon Glass <sjg@chromium.org>
Tom Rini Jan. 19, 2017, 2:25 p.m. UTC | #2
On Thu, Jan 19, 2017 at 06:57:51AM -0700, Simon Glass wrote:
> On 12 January 2017 at 11:16, Tom Rini <trini@konsulko.com> wrote:
> > We can make the code read more easily here by simply using memset()
> > always as when we don't have an optimized version of the function we
> > will still have a version of this function around anyhow.
> >
> > Cc: Simon Glass <sjg@chromium.org>
> > Signed-off-by: Tom Rini <trini@konsulko.com>
> > ---
> >  common/init/board_init.c | 18 ------------------
> >  1 file changed, 18 deletions(-)
> 
> I recall this didn't work before, but I'm pleased it now does.

Do you recall where, if it was a runtime rather than build time failure?
There was a case or two of build-time failure I had to address.
Tom Rini Jan. 21, 2017, 3:37 a.m. UTC | #3
On Thu, Jan 12, 2017 at 01:16:03PM -0500, Tom Rini wrote:

> We can make the code read more easily here by simply using memset()
> always as when we don't have an optimized version of the function we
> will still have a version of this function around anyhow.
> 
> Cc: Simon Glass <sjg@chromium.org>
> Signed-off-by: Tom Rini <trini@konsulko.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>

Applied to u-boot/master, thanks!
Simon Glass Jan. 21, 2017, 3:50 a.m. UTC | #4
Hi Tom,

On 19 January 2017 at 07:25, Tom Rini <trini@konsulko.com> wrote:
>
> On Thu, Jan 19, 2017 at 06:57:51AM -0700, Simon Glass wrote:
> > On 12 January 2017 at 11:16, Tom Rini <trini@konsulko.com> wrote:
> > > We can make the code read more easily here by simply using memset()
> > > always as when we don't have an optimized version of the function we
> > > will still have a version of this function around anyhow.
> > >
> > > Cc: Simon Glass <sjg@chromium.org>
> > > Signed-off-by: Tom Rini <trini@konsulko.com>
> > > ---
> > >  common/init/board_init.c | 18 ------------------
> > >  1 file changed, 18 deletions(-)
> >
> > I recall this didn't work before, but I'm pleased it now does.
>
> Do you recall where, if it was a runtime rather than build time failure?
> There was a case or two of build-time failure I had to address.

Yes it was just a build failure, so we should be fine.

Regards,
Simon
diff mbox

Patch

diff --git a/common/init/board_init.c b/common/init/board_init.c
index 193d8180a9c5..bf4255b4aeba 100644
--- a/common/init/board_init.c
+++ b/common/init/board_init.c
@@ -11,16 +11,6 @@ 
 
 DECLARE_GLOBAL_DATA_PTR;
 
-/*
- * It isn't trivial to figure out whether memcpy() exists. The arch-specific
- * memcpy() is not normally available in SPL due to code size.
- */
-#if !defined(CONFIG_SPL_BUILD) || \
-		(defined(CONFIG_SPL_LIBGENERIC_SUPPORT) && \
-		!defined(CONFIG_SPL_USE_ARCH_MEMCPY))
-#define _USE_MEMCPY
-#endif
-
 /* Unfortunately x86 or ARM can't compile this code as gd cannot be assigned */
 #if !defined(CONFIG_X86) && !defined(CONFIG_ARM)
 __weak void arch_setup_gd(struct global_data *gd_ptr)
@@ -110,9 +100,6 @@  ulong board_init_f_alloc_reserve(ulong top)
 void board_init_f_init_reserve(ulong base)
 {
 	struct global_data *gd_ptr;
-#ifndef _USE_MEMCPY
-	int *ptr;
-#endif
 
 	/*
 	 * clear GD entirely and set it up.
@@ -121,12 +108,7 @@  void board_init_f_init_reserve(ulong base)
 
 	gd_ptr = (struct global_data *)base;
 	/* zero the area */
-#ifdef _USE_MEMCPY
 	memset(gd_ptr, '\0', sizeof(*gd));
-#else
-	for (ptr = (int *)gd_ptr; ptr < (int *)(gd_ptr + 1); )
-		*ptr++ = 0;
-#endif
 	/* set GD unless architecture did it already */
 #if !defined(CONFIG_ARM)
 	arch_setup_gd(gd_ptr);