Patchwork [U-Boot,v1,2/2] nand/spl: Assuming a static nand page size to reduce code size

login
register
mail settings
Submitter Matthew McClintock
Date April 5, 2011, 7:39 p.m.
Message ID <1302032374-28857-2-git-send-email-msm@freescale.com>
Download mbox | patch
Permalink /patch/89923/
State Accepted
Commit 62974546888c1f9abfdb4ba9f66465a5d102d4d3
Headers show

Comments

Matthew McClintock - April 5, 2011, 7:39 p.m.
Change variables to const to reduce code size, these values are
hardcoded via defines anyways so we might as well assume they
are constants

Signed-off-by: Matthew McClintock <msm@freescale.com>
cc: Scott Wood <scottwood@freescale.com>
---
With this change we can reduce the size of the nand_spl by
148 bytes with my particular board/compiler

v1: Add prior patch to correct naming of CONFIG_SYS_NAND_*_PRELIM

 nand_spl/nand_boot_fsl_elbc.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
Kumar Gala - April 9, 2011, 3:53 p.m.
On Apr 5, 2011, at 2:39 PM, Matthew McClintock wrote:

> Change variables to const to reduce code size, these values are
> hardcoded via defines anyways so we might as well assume they
> are constants
> 
> Signed-off-by: Matthew McClintock <msm@freescale.com>
> cc: Scott Wood <scottwood@freescale.com>
> ---
> With this change we can reduce the size of the nand_spl by
> 148 bytes with my particular board/compiler
> 
> v1: Add prior patch to correct naming of CONFIG_SYS_NAND_*_PRELIM
> 
> nand_spl/nand_boot_fsl_elbc.c |   10 +++++-----
> 1 files changed, 5 insertions(+), 5 deletions(-)

Scott, do you want this to go via nand tree or 85xx ok?  if 85xx ok please ack.

- k
Scott Wood - April 11, 2011, 4:36 p.m.
On Sat, 9 Apr 2011 10:53:34 -0500
Kumar Gala <galak@kernel.crashing.org> wrote:

> 
> On Apr 5, 2011, at 2:39 PM, Matthew McClintock wrote:
> 
> > Change variables to const to reduce code size, these values are
> > hardcoded via defines anyways so we might as well assume they
> > are constants
> > 
> > Signed-off-by: Matthew McClintock <msm@freescale.com>
> > cc: Scott Wood <scottwood@freescale.com>
> > ---
> > With this change we can reduce the size of the nand_spl by
> > 148 bytes with my particular board/compiler
> > 
> > v1: Add prior patch to correct naming of CONFIG_SYS_NAND_*_PRELIM
> > 
> > nand_spl/nand_boot_fsl_elbc.c |   10 +++++-----
> > 1 files changed, 5 insertions(+), 5 deletions(-)
> 
> Scott, do you want this to go via nand tree or 85xx ok?  if 85xx ok please ack.

I'll take it.

-Scott
Scott Wood - April 11, 2011, 6:56 p.m.
On Tue, Apr 05, 2011 at 02:39:34PM -0500, Matthew McClintock wrote:
> Change variables to const to reduce code size, these values are
> hardcoded via defines anyways so we might as well assume they
> are constants
> 
> Signed-off-by: Matthew McClintock <msm@freescale.com>
> cc: Scott Wood <scottwood@freescale.com>
> ---
> With this change we can reduce the size of the nand_spl by
> 148 bytes with my particular board/compiler
> 
> v1: Add prior patch to correct naming of CONFIG_SYS_NAND_*_PRELIM

Applied to u-boot-nand-flash

-Scott

Patch

diff --git a/nand_spl/nand_boot_fsl_elbc.c b/nand_spl/nand_boot_fsl_elbc.c
index 9547d44..502605b 100644
--- a/nand_spl/nand_boot_fsl_elbc.c
+++ b/nand_spl/nand_boot_fsl_elbc.c
@@ -51,11 +51,11 @@  static void nand_load(unsigned int offs, int uboot_size, uchar *dst)
 {
 	fsl_lbc_t *regs = LBC_BASE_ADDR;
 	uchar *buf = (uchar *)CONFIG_SYS_NAND_BASE;
-	int large = in_be32(&regs->bank[0].or) & OR_FCM_PGS;
-	int block_shift = large ? 17 : 14;
-	int block_size = 1 << block_shift;
-	int page_size = large ? 2048 : 512;
-	int bad_marker = large ? page_size + 0 : page_size + 5;
+	const int large = CONFIG_SYS_NAND_OR_PRELIM & OR_FCM_PGS;
+	const int block_shift = large ? 17 : 14;
+	const int block_size = 1 << block_shift;
+	const int page_size = large ? 2048 : 512;
+	const int bad_marker = large ? page_size + 0 : page_size + 5;
 	int fmr = (15 << FMR_CWTO_SHIFT) | (2 << FMR_AL_SHIFT) | 2;
 	int pos = 0;