* [U-Boot] [PATCH] Decreases code size of the nand_spl
@ 2011-05-04 13:10 Alex Waterman
2011-05-04 13:47 ` Stefan Roese
2011-05-13 16:16 ` [U-Boot] [PATCH] " Scott Wood
0 siblings, 2 replies; 12+ messages in thread
From: Alex Waterman @ 2011-05-04 13:10 UTC (permalink / raw)
To: u-boot
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH] Decreases code size of the nand_spl
2011-05-04 13:10 [U-Boot] [PATCH] Decreases code size of the nand_spl Alex Waterman
@ 2011-05-04 13:47 ` Stefan Roese
2011-05-04 14:03 ` Alex Waterman
2011-05-04 17:46 ` Scott Wood
2011-05-13 16:16 ` [U-Boot] [PATCH] " Scott Wood
1 sibling, 2 replies; 12+ messages in thread
From: Stefan Roese @ 2011-05-04 13:47 UTC (permalink / raw)
To: u-boot
Hi Alex,
On Wednesday 04 May 2011 15:10:15 Alex Waterman wrote:
> From b59f1e5b0bc3684615756c12fd5c5f9fcaa4c812 Mon Sep 17 00:00:00 2001
> From: Alex Waterman <awaterman@dawning.com>
> Date: Tue, 3 May 2011 15:00:23 -0400
> Subject: [PATCH] Decreases code size of the nand_spl
>
> The canyonland boards nand_spl size is just under the maximum 4KByte size.
> This patch decreases the size of the nand_spl to make a previous commit -
> commit 65a9db7be0868be91ba81b9b5bf821de82e6d9b0 - fit in the nand_spl.
>
> Signed-off-by: Alex Waterman <awaterman@dawning.com>
> ---
> This patch uses a function pointer declared as a local variable; checkpatch
> didn't mind but this seems like it could be (stylistically) a very bad
> idea. Any thoughts?
Please see my patches sent a few hours ago:
"nand_spl: nand_boot.c: Init nand_chip.options to 0"
"nand_spl: nand_boot.c: Remove CONFIG_SYS_NAND_READ_DELAY"
The 2nd patch fixes the size problem as well. So no need for your patch any
more.
But thanks anyway.
BTW: What platform/SoC are you using?
Cheers,
Stefan
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH] Decreases code size of the nand_spl
2011-05-04 13:47 ` Stefan Roese
@ 2011-05-04 14:03 ` Alex Waterman
2011-05-04 17:46 ` Scott Wood
1 sibling, 0 replies; 12+ messages in thread
From: Alex Waterman @ 2011-05-04 14:03 UTC (permalink / raw)
To: u-boot
Stefan,
> The 2nd patch fixes the size problem as well. So no need for your patch any
> more.
Ahh, I saw the first but missed the second I guess.
> BTW: What platform/SoC are you using?
I am using a custom board based on the AMCC sequoia board. At some point I
plan to try and mainline our port for that board if possible. But I have
more work to go on that.
- Alex
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH] Decreases code size of the nand_spl
2011-05-04 13:47 ` Stefan Roese
2011-05-04 14:03 ` Alex Waterman
@ 2011-05-04 17:46 ` Scott Wood
2011-05-04 18:24 ` Alex Waterman
1 sibling, 1 reply; 12+ messages in thread
From: Scott Wood @ 2011-05-04 17:46 UTC (permalink / raw)
To: u-boot
On Wed, 4 May 2011 15:47:27 +0200
Stefan Roese <sr@denx.de> wrote:
> Hi Alex,
>
> On Wednesday 04 May 2011 15:10:15 Alex Waterman wrote:
> > From b59f1e5b0bc3684615756c12fd5c5f9fcaa4c812 Mon Sep 17 00:00:00 2001
> > From: Alex Waterman <awaterman@dawning.com>
> > Date: Tue, 3 May 2011 15:00:23 -0400
> > Subject: [PATCH] Decreases code size of the nand_spl
> >
> > The canyonland boards nand_spl size is just under the maximum 4KByte size.
> > This patch decreases the size of the nand_spl to make a previous commit -
> > commit 65a9db7be0868be91ba81b9b5bf821de82e6d9b0 - fit in the nand_spl.
> >
> > Signed-off-by: Alex Waterman <awaterman@dawning.com>
> > ---
> > This patch uses a function pointer declared as a local variable; checkpatch
> > didn't mind but this seems like it could be (stylistically) a very bad
> > idea. Any thoughts?
I don't see what's wrong with a local function pointer.
> Please see my patches sent a few hours ago:
>
> "nand_spl: nand_boot.c: Init nand_chip.options to 0"
> "nand_spl: nand_boot.c: Remove CONFIG_SYS_NAND_READ_DELAY"
>
> The 2nd patch fixes the size problem as well. So no need for your patch any
> more.
Or we could apply both and save even more space, delaying the next time we
run into trouble. :-)
-Scott
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH] Decreases code size of the nand_spl
2011-05-04 17:46 ` Scott Wood
@ 2011-05-04 18:24 ` Alex Waterman
2011-05-04 18:43 ` Scott Wood
0 siblings, 1 reply; 12+ messages in thread
From: Alex Waterman @ 2011-05-04 18:24 UTC (permalink / raw)
To: u-boot
Scott,
> Or we could apply both and save even more space, delaying the next time we
> run into trouble. :-)
Since the spl is so limited in space, would it be worth making every function
in the spl use a local function pointer instead of lots of dereferences?
- Alex
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH] Decreases code size of the nand_spl
2011-05-04 18:24 ` Alex Waterman
@ 2011-05-04 18:43 ` Scott Wood
2011-05-04 19:24 ` [U-Boot] [PATCH v2] " Alex Waterman
0 siblings, 1 reply; 12+ messages in thread
From: Scott Wood @ 2011-05-04 18:43 UTC (permalink / raw)
To: u-boot
On Wed, 4 May 2011 14:24:15 -0400
Alex Waterman <awaterman@dawning.com> wrote:
>
> Scott,
>
> > Or we could apply both and save even more space, delaying the next time we
> > run into trouble. :-)
>
> Since the spl is so limited in space, would it be worth making every function
> in the spl use a local function pointer instead of lots of dereferences?
It'll only help when the same pointer is called more than once in the
function, but I'd be fine with doing it in those cases.
-Scott
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH v2] Decreases code size of the nand_spl
2011-05-04 18:43 ` Scott Wood
@ 2011-05-04 19:24 ` Alex Waterman
2011-05-12 21:49 ` Wolfgang Denk
0 siblings, 1 reply; 12+ messages in thread
From: Alex Waterman @ 2011-05-04 19:24 UTC (permalink / raw)
To: u-boot
This patch decreases the code size of the nand_spl by turning multiple function
pointer dereferences in a single function into a single local function pointer.
Signed-off-by: Alex Waterman <awaterman@dawning.com>
Cc: Scott Wood <scottwood@freescale.com>
Cc: Stefan Roese <sr@denx.de>
---
This works on my local board but I haven't tested it on anything else since I
do not have access to any other hardware. I did make sure the canyonlands board
still builds.
nand_spl/nand_boot.c | 50 ++++++++++++++++++++++++++++----------------------
1 files changed, 28 insertions(+), 22 deletions(-)
diff --git a/nand_spl/nand_boot.c b/nand_spl/nand_boot.c
index 4a96878..dd7f3b2 100644
--- a/nand_spl/nand_boot.c
+++ b/nand_spl/nand_boot.c
@@ -35,34 +35,37 @@ static int nand_command(struct mtd_info *mtd, int block, int page, int offs, u8
{
struct nand_chip *this = mtd->priv;
int page_addr = page + block * CONFIG_SYS_NAND_PAGE_COUNT;
+ void (*cmd_ctrl)(struct mtd_info *mtd, int cmd,
+ unsigned int ctrl) = this->cmd_ctrl;
+ int (*dev_ready)(struct mtd_info *mtd) = this->dev_ready;
- if (this->dev_ready)
- while (!this->dev_ready(mtd))
+ if (dev_ready != NULL)
+ while (!dev_ready(mtd))
;
else
CONFIG_SYS_NAND_READ_DELAY;
/* Begin command latch cycle */
- this->cmd_ctrl(mtd, cmd, NAND_CTRL_CLE | NAND_CTRL_CHANGE);
+ cmd_ctrl(mtd, cmd, NAND_CTRL_CLE | NAND_CTRL_CHANGE);
/* Set ALE and clear CLE to start address cycle */
/* Column address */
- this->cmd_ctrl(mtd, offs, NAND_CTRL_ALE | NAND_CTRL_CHANGE);
- this->cmd_ctrl(mtd, page_addr & 0xff, NAND_CTRL_ALE); /* A[16:9] */
- this->cmd_ctrl(mtd, (page_addr >> 8) & 0xff,
+ cmd_ctrl(mtd, offs, NAND_CTRL_ALE | NAND_CTRL_CHANGE);
+ cmd_ctrl(mtd, page_addr & 0xff, NAND_CTRL_ALE); /* A[16:9] */
+ cmd_ctrl(mtd, (page_addr >> 8) & 0xff,
NAND_CTRL_ALE); /* A[24:17] */
#ifdef CONFIG_SYS_NAND_4_ADDR_CYCLE
/* One more address cycle for devices > 32MiB */
- this->cmd_ctrl(mtd, (page_addr >> 16) & 0x0f,
+ cmd_ctrl(mtd, (page_addr >> 16) & 0x0f,
NAND_CTRL_ALE); /* A[28:25] */
#endif
/* Latch in address */
- this->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE);
+ cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE);
/*
* Wait a while for the data to be ready
*/
- if (this->dev_ready)
- while (!this->dev_ready(mtd))
+ if (dev_ready != NULL)
+ while (!dev_ready(mtd))
;
else
CONFIG_SYS_NAND_READ_DELAY;
@@ -77,9 +80,12 @@ static int nand_command(struct mtd_info *mtd, int block, int page, int offs, u8
{
struct nand_chip *this = mtd->priv;
int page_addr = page + block * CONFIG_SYS_NAND_PAGE_COUNT;
+ void (*cmd_ctrl)(struct mtd_info *mtd, int cmd,
+ unsigned int ctrl) = this->cmd_ctrl;
+ int (*dev_ready)(struct mtd_info *mtd) = this->dev_ready;
- if (this->dev_ready)
- while (!this->dev_ready(mtd))
+ if (dev_ready != NULL)
+ while (!dev_ready(mtd))
;
else
CONFIG_SYS_NAND_READ_DELAY;
@@ -95,31 +101,31 @@ static int nand_command(struct mtd_info *mtd, int block, int page, int offs, u8
offs >>= 1;
/* Begin command latch cycle */
- this->cmd_ctrl(mtd, cmd, NAND_CTRL_CLE | NAND_CTRL_CHANGE);
+ cmd_ctrl(mtd, cmd, NAND_CTRL_CLE | NAND_CTRL_CHANGE);
/* Set ALE and clear CLE to start address cycle */
/* Column address */
- this->cmd_ctrl(mtd, offs & 0xff,
+ cmd_ctrl(mtd, offs & 0xff,
NAND_CTRL_ALE | NAND_CTRL_CHANGE); /* A[7:0] */
- this->cmd_ctrl(mtd, (offs >> 8) & 0xff, NAND_CTRL_ALE); /* A[11:9] */
+ cmd_ctrl(mtd, (offs >> 8) & 0xff, NAND_CTRL_ALE); /* A[11:9] */
/* Row address */
- this->cmd_ctrl(mtd, (page_addr & 0xff), NAND_CTRL_ALE); /* A[19:12] */
- this->cmd_ctrl(mtd, ((page_addr >> 8) & 0xff),
+ cmd_ctrl(mtd, (page_addr & 0xff), NAND_CTRL_ALE); /* A[19:12] */
+ cmd_ctrl(mtd, ((page_addr >> 8) & 0xff),
NAND_CTRL_ALE); /* A[27:20] */
#ifdef CONFIG_SYS_NAND_5_ADDR_CYCLE
/* One more address cycle for devices > 128MiB */
- this->cmd_ctrl(mtd, (page_addr >> 16) & 0x0f,
+ cmd_ctrl(mtd, (page_addr >> 16) & 0x0f,
NAND_CTRL_ALE); /* A[31:28] */
#endif
/* Latch in address */
- this->cmd_ctrl(mtd, NAND_CMD_READSTART,
+ cmd_ctrl(mtd, NAND_CMD_READSTART,
NAND_CTRL_CLE | NAND_CTRL_CHANGE);
- this->cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE);
+ cmd_ctrl(mtd, NAND_CMD_NONE, NAND_NCE | NAND_CTRL_CHANGE);
/*
* Wait a while for the data to be ready
*/
- if (this->dev_ready)
- while (!this->dev_ready(mtd))
+ if (dev_ready != NULL)
+ while (!dev_ready(mtd))
;
else
CONFIG_SYS_NAND_READ_DELAY;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH v2] Decreases code size of the nand_spl
2011-05-04 19:24 ` [U-Boot] [PATCH v2] " Alex Waterman
@ 2011-05-12 21:49 ` Wolfgang Denk
2011-05-12 21:57 ` Scott Wood
2011-05-13 6:20 ` Stefan Roese
0 siblings, 2 replies; 12+ messages in thread
From: Wolfgang Denk @ 2011-05-12 21:49 UTC (permalink / raw)
To: u-boot
Dear Scott,
In message <4DC1A7F1.7000001@dawning.com> Alex Waterman wrote:
> This patch decreases the code size of the nand_spl by turning multiple function
> pointer dereferences in a single function into a single local function pointer.
>
> Signed-off-by: Alex Waterman <awaterman@dawning.com>
> Cc: Scott Wood <scottwood@freescale.com>
> Cc: Stefan Roese <sr@denx.de>
> ---
> This works on my local board but I haven't tested it on anything else since I
> do not have access to any other hardware. I did make sure the canyonlands board
> still builds.
>
> nand_spl/nand_boot.c | 50 ++++++++++++++++++++++++++++----------------------
> 1 files changed, 28 insertions(+), 22 deletions(-)
Can this patch go in, please? I would like to see the build problems
fixed.
Stefan, eventually you want to add your Tested-by: and/or Acked-by: ?
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
I think it's a new feature. Don't tell anyone it was an accident. :-)
-- Larry Wall on s/foo/bar/eieio in <10911@jpl-devvax.JPL.NASA.GOV>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH v2] Decreases code size of the nand_spl
2011-05-12 21:49 ` Wolfgang Denk
@ 2011-05-12 21:57 ` Scott Wood
2011-05-12 22:00 ` Wolfgang Denk
2011-05-13 6:20 ` Stefan Roese
1 sibling, 1 reply; 12+ messages in thread
From: Scott Wood @ 2011-05-12 21:57 UTC (permalink / raw)
To: u-boot
On Thu, 12 May 2011 23:49:40 +0200
Wolfgang Denk <wd@denx.de> wrote:
> Dear Scott,
>
> In message <4DC1A7F1.7000001@dawning.com> Alex Waterman wrote:
> > This patch decreases the code size of the nand_spl by turning multiple function
> > pointer dereferences in a single function into a single local function pointer.
> >
> > Signed-off-by: Alex Waterman <awaterman@dawning.com>
> > Cc: Scott Wood <scottwood@freescale.com>
> > Cc: Stefan Roese <sr@denx.de>
> > ---
> > This works on my local board but I haven't tested it on anything else since I
> > do not have access to any other hardware. I did make sure the canyonlands board
> > still builds.
> >
> > nand_spl/nand_boot.c | 50 ++++++++++++++++++++++++++++----------------------
> > 1 files changed, 28 insertions(+), 22 deletions(-)
>
> Can this patch go in, please? I would like to see the build problems
> fixed.
Yes, sorry for the delay -- I'll try to get to it tomorrow.
-Scott
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH v2] Decreases code size of the nand_spl
2011-05-12 21:57 ` Scott Wood
@ 2011-05-12 22:00 ` Wolfgang Denk
0 siblings, 0 replies; 12+ messages in thread
From: Wolfgang Denk @ 2011-05-12 22:00 UTC (permalink / raw)
To: u-boot
Dear Scott,
In message <20110512165759.0692384d@schlenkerla.am.freescale.net> you wrote:
>
> > Can this patch go in, please? I would like to see the build problems
> > fixed.
>
> Yes, sorry for the delay -- I'll try to get to it tomorrow.
Thanks. Guess you guys are as busy as evryone else ;-)
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
The use of COBOL cripples the mind; its teaching should, therefore,
be regarded as a criminal offense. - E. W. Dijkstra
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH v2] Decreases code size of the nand_spl
2011-05-12 21:49 ` Wolfgang Denk
2011-05-12 21:57 ` Scott Wood
@ 2011-05-13 6:20 ` Stefan Roese
1 sibling, 0 replies; 12+ messages in thread
From: Stefan Roese @ 2011-05-13 6:20 UTC (permalink / raw)
To: u-boot
On Thursday 12 May 2011 23:49:40 Wolfgang Denk wrote:
> > This patch decreases the code size of the nand_spl by turning multiple
> > function pointer dereferences in a single function into a single local
> > function pointer.
> >
> > Signed-off-by: Alex Waterman <awaterman@dawning.com>
> > Cc: Scott Wood <scottwood@freescale.com>
> > Cc: Stefan Roese <sr@denx.de>
> > ---
> > This works on my local board but I haven't tested it on anything else
> > since I do not have access to any other hardware. I did make sure the
> > canyonlands board still builds.
> >
> > nand_spl/nand_boot.c | 50
> > ++++++++++++++++++++++++++++---------------------- 1 files changed, 28
> > insertions(+), 22 deletions(-)
>
> Can this patch go in, please? I would like to see the build problems
> fixed.
>
> Stefan, eventually you want to add your Tested-by: and/or Acked-by: ?
Sure:
Acked-by: Stefan Roese <sr@denx.de>
Thanks,
Stefan
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-0 Fax: (+49)-8142-66989-80 Email: office at denx.de
^ permalink raw reply [flat|nested] 12+ messages in thread
* [U-Boot] [PATCH] Decreases code size of the nand_spl
2011-05-04 13:10 [U-Boot] [PATCH] Decreases code size of the nand_spl Alex Waterman
2011-05-04 13:47 ` Stefan Roese
@ 2011-05-13 16:16 ` Scott Wood
1 sibling, 0 replies; 12+ messages in thread
From: Scott Wood @ 2011-05-13 16:16 UTC (permalink / raw)
To: u-boot
On Wed, May 04, 2011 at 09:10:15AM -0400, Alex Waterman wrote:
> From b59f1e5b0bc3684615756c12fd5c5f9fcaa4c812 Mon Sep 17 00:00:00 2001
> From: Alex Waterman <awaterman@dawning.com>
> Date: Tue, 3 May 2011 15:00:23 -0400
> Subject: [PATCH] Decreases code size of the nand_spl
>
> The canyonland boards nand_spl size is just under the maximum 4KByte size. This
> patch decreases the size of the nand_spl to make a previous commit - commit
> 65a9db7be0868be91ba81b9b5bf821de82e6d9b0 - fit in the nand_spl.
>
> Signed-off-by: Alex Waterman <awaterman@dawning.com>
> ---
> This patch uses a function pointer declared as a local variable; checkpatch didn't
> mind but this seems like it could be (stylistically) a very bad idea. Any thoughts?
>
> nand_spl/nand_boot.c | 18 ++++++++++--------
> 1 files changed, 10 insertions(+), 8 deletions(-)
Applied to u-boot-nand-flash
-Scott
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2011-05-13 16:16 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-04 13:10 [U-Boot] [PATCH] Decreases code size of the nand_spl Alex Waterman
2011-05-04 13:47 ` Stefan Roese
2011-05-04 14:03 ` Alex Waterman
2011-05-04 17:46 ` Scott Wood
2011-05-04 18:24 ` Alex Waterman
2011-05-04 18:43 ` Scott Wood
2011-05-04 19:24 ` [U-Boot] [PATCH v2] " Alex Waterman
2011-05-12 21:49 ` Wolfgang Denk
2011-05-12 21:57 ` Scott Wood
2011-05-12 22:00 ` Wolfgang Denk
2011-05-13 6:20 ` Stefan Roese
2011-05-13 16:16 ` [U-Boot] [PATCH] " Scott Wood
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox