On Mon, 20 Jun 2011 11:54:45 -0700
David Hendricks <[email protected]> wrote:

> On Tue, Jun 7, 2011 at 7:55 PM, Stefan Tauner <
> [email protected]> wrote:
> 
> > +static uint32_t ich_hwseq_get_erase_block_size(unsigned int addr)
> > +{
> > +       REGWRITE32(ICH9_REG_FADDR, (addr & 0x00FFFFFF));
> > +       uint8_t enc_berase = (REGREAD16(ICH9_REG_HSFS) & HSFS_BERASE) >>
> > +                                  HSFS_BERASE_OFF;
> > +       const uint32_t dec_berase[4] = {
> > +               256,
> > +               4 * 1024,
> > +               8 * 1024,
> > +               64 * 1024
> > +       };
> >
> +       return dec_berase[enc_berase];
> >
> 
> Others might want to comment, but I think you should avoid doing all that
> work in the variable declaration area.

no need. you are correct, i have revamped it. thanks

> 
> > +}
> > +
> > +int ich_hwseq_probe(struct flashchip *flash)
> > +{
> > +       uint32_t total_size, boundary;
> > +       uint32_t erase_size_low, size_low, erase_size_high, size_high;
> > +       struct block_eraser eraser;
> >
> 
> This should be a pointer, right? I am assuming you intended to directly
> update the flash->block_erasers[0] member later in this function.

inderdaad! :)

thanks a lot, fixup! patch attached.

-- 
Kind regards/Mit freundlichen Grüßen, Stefan Tauner
>From 702b088037f77008beb9fcf5ff8f317d753827f7 Mon Sep 17 00:00:00 2001
From: Stefan Tauner <[email protected]>
Date: Mon, 20 Jun 2011 22:25:10 +0200
Subject: [PATCH] fixup! add support for Intel Hardware Sequencing

- variable declaration in ich_hwseq_get_erase_block_size
- really update the first eraser and not its copy on the stack

Signed-off-by: Stefan Tauner <[email protected]>
---
 ichspi.c |   24 +++++++++++++-----------
 1 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/ichspi.c b/ichspi.c
index f6b1bbe..4988c9b 100644
--- a/ichspi.c
+++ b/ichspi.c
@@ -1126,15 +1126,17 @@ static uint32_t ich_hwseq_get_flash_boundary(void)
  * of the block containing this address. */
 static uint32_t ich_hwseq_get_erase_block_size(unsigned int addr)
 {
-	REGWRITE32(ICH9_REG_FADDR, (addr & 0x00FFFFFF));
-	uint8_t enc_berase = (REGREAD16(ICH9_REG_HSFS) & HSFS_BERASE) >>
-				   HSFS_BERASE_OFF;
+	uint8_t enc_berase;
 	const uint32_t dec_berase[4] = {
 		256,
 		4 * 1024,
 		8 * 1024,
 		64 * 1024
 	};
+
+	REGWRITE32(ICH9_REG_FADDR, (addr & 0x00FFFFFF));
+	enc_berase = (REGREAD16(ICH9_REG_HSFS) & HSFS_BERASE) >>
+		     HSFS_BERASE_OFF;
 	return dec_berase[enc_berase];
 }
 
@@ -1180,7 +1182,7 @@ int ich_hwseq_probe(struct flashchip *flash)
 {
 	uint32_t total_size, boundary;
 	uint32_t erase_size_low, size_low, erase_size_high, size_high;
-	struct block_eraser eraser;
+	struct block_eraser *eraser;
 	extern struct flash_descriptor fdbar;
 
 	if (flash->manufacture_id != INTEL_ID ||
@@ -1210,7 +1212,7 @@ int ich_hwseq_probe(struct flashchip *flash)
 	msg_cdbg(" density of %d kB.\n", total_size / 1024);
 	flash->total_size = total_size / 1024;
 
-	eraser = flash->block_erasers[0];
+	eraser = &(flash->block_erasers[0]);
 	boundary = ich_hwseq_get_flash_boundary();
 	size_high = total_size - boundary;
 	erase_size_high = ich_hwseq_get_erase_block_size(boundary);
@@ -1218,8 +1220,8 @@ int ich_hwseq_probe(struct flashchip *flash)
 	if (boundary == 0) {
 		msg_cdbg("There is only one partition containing the whole "
 			 "address space (0x%06x - 0x%06x).\n", 0, size_high-1);
-		eraser.eraseblocks[0].size = erase_size_high;
-		eraser.eraseblocks[0].count = size_high / erase_size_high;
+		eraser->eraseblocks[0].size = erase_size_high;
+		eraser->eraseblocks[0].count = size_high / erase_size_high;
 		msg_cdbg("There are %d erase blocks with %d B each.\n",
 			 size_high / erase_size_high, erase_size_high);
 	} else {
@@ -1229,15 +1231,15 @@ int ich_hwseq_probe(struct flashchip *flash)
 		size_low = total_size - size_high;
 		erase_size_low = ich_hwseq_get_erase_block_size(0);
 
-		eraser.eraseblocks[0].size = erase_size_low;
-		eraser.eraseblocks[0].count = size_low / erase_size_low;
+		eraser->eraseblocks[0].size = erase_size_low;
+		eraser->eraseblocks[0].count = size_low / erase_size_low;
 		msg_cdbg("The first partition ranges from 0x%06x to 0x%06x.\n",
 			 0, size_low-1);
 		msg_cdbg("In that range are %d erase blocks with %d B each.\n",
 			 size_low / erase_size_low, erase_size_low);
 
-		eraser.eraseblocks[1].size = erase_size_high;
-		eraser.eraseblocks[1].count = size_high / erase_size_high;
+		eraser->eraseblocks[1].size = erase_size_high;
+		eraser->eraseblocks[1].count = size_high / erase_size_high;
 		msg_cdbg("The second partition ranges from 0x%06x to 0x%06x.\n",
 			 boundary, size_high-1);
 		msg_cdbg("In that range are %d erase blocks with %d B each.\n",
-- 
1.7.1

_______________________________________________
flashrom mailing list
[email protected]
http://www.flashrom.org/mailman/listinfo/flashrom

Reply via email to