public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 1/2] mtd: bcm47xxpart: simplify size calculation to one loop
@ 2013-01-06 15:08 Rafał Miłecki
  2013-01-06 15:08 ` [PATCH 2/2] mtd: bcm47xxpart: register extra "firmware" partition Rafał Miłecki
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Rafał Miłecki @ 2013-01-06 15:08 UTC (permalink / raw)
  To: linux-mtd, Artem Bityutskiy, David Woodhouse
  Cc: Hauke Mehrtens, Rafał Miłecki


Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
I've checked this patch and got:
> Successfully built configuration "mips-bcm47xx_defconfig,mips,mips-linux-", no issues
---
 drivers/mtd/bcm47xxpart.c |   11 ++++++-----
 1 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c
index e06d782..06125eb 100644
--- a/drivers/mtd/bcm47xxpart.c
+++ b/drivers/mtd/bcm47xxpart.c
@@ -169,11 +169,12 @@ static int bcm47xxpart_parse(struct mtd_info *master,
 	 * Assume that partitions end at the beginning of the one they are
 	 * followed by.
 	 */
-	for (i = 0; i < curr_part - 1; i++)
-		parts[i].size = parts[i + 1].offset - parts[i].offset;
-	if (curr_part > 0)
-		parts[curr_part - 1].size =
-				master->size - parts[curr_part - 1].offset;
+	for (i = 0; i < curr_part; i++) {
+		u64 next_part_offset = (i < curr_part - 1) ?
+				       parts[i + 1].offset : master->size;
+
+		parts[i].size = next_part_offset - parts[i].offset;
+	}
 
 	*pparts = parts;
 	return curr_part;
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] mtd: bcm47xxpart: register extra "firmware" partition
  2013-01-06 15:08 [PATCH 1/2] mtd: bcm47xxpart: simplify size calculation to one loop Rafał Miłecki
@ 2013-01-06 15:08 ` Rafał Miłecki
  2013-01-17 12:38 ` [PATCH 1/2] mtd: bcm47xxpart: simplify size calculation to one loop Artem Bityutskiy
  2013-01-17 13:22 ` Artem Bityutskiy
  2 siblings, 0 replies; 6+ messages in thread
From: Rafał Miłecki @ 2013-01-06 15:08 UTC (permalink / raw)
  To: linux-mtd, Artem Bityutskiy, David Woodhouse
  Cc: Hauke Mehrtens, Rafał Miłecki

It's required for accessing trx header (usually re-calculating a
checksum) and for writing a new firmware.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
---
I've checked this patch and got:
> Successfully built configuration "mips-bcm47xx_defconfig,mips,mips-linux-", no issues

I've also succesfully installed new firmware using
mtd -r write /tmp/openwrt-brcm47xx-squashfs-noloader-wndr4500.trx firmware
---
 drivers/mtd/bcm47xxpart.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c
index 06125eb..3411bc2 100644
--- a/drivers/mtd/bcm47xxpart.c
+++ b/drivers/mtd/bcm47xxpart.c
@@ -61,6 +61,8 @@ static int bcm47xxpart_parse(struct mtd_info *master,
 	uint32_t offset;
 	uint32_t blocksize = 0x10000;
 	struct trx_header *trx;
+	int trx_part = -1;
+	int last_trx_part = -1;
 
 	/* Alloc */
 	parts = kzalloc(sizeof(struct mtd_partition) * BCM47XXPART_MAX_PARTS,
@@ -131,6 +133,10 @@ static int bcm47xxpart_parse(struct mtd_info *master,
 		if (buf[0x000 / 4] == TRX_MAGIC) {
 			trx = (struct trx_header *)buf;
 
+			trx_part = curr_part;
+			bcm47xxpart_add_part(&parts[curr_part++], "firmware",
+					     offset, 0);
+
 			i = 0;
 			/* We have LZMA loader if offset[2] points to sth */
 			if (trx->offset[2]) {
@@ -154,6 +160,8 @@ static int bcm47xxpart_parse(struct mtd_info *master,
 					     offset + trx->offset[i], 0);
 			i++;
 
+			last_trx_part = curr_part - 1;
+
 			/*
 			 * We have whole TRX scanned, skip to the next part. Use
 			 * roundown (not roundup), as the loop will increase
@@ -174,6 +182,9 @@ static int bcm47xxpart_parse(struct mtd_info *master,
 				       parts[i + 1].offset : master->size;
 
 		parts[i].size = next_part_offset - parts[i].offset;
+		if (i == last_trx_part && trx_part >= 0)
+			parts[trx_part].size = next_part_offset -
+					       parts[trx_part].offset;
 	}
 
 	*pparts = parts;
-- 
1.7.7

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] mtd: bcm47xxpart: simplify size calculation to one loop
  2013-01-06 15:08 [PATCH 1/2] mtd: bcm47xxpart: simplify size calculation to one loop Rafał Miłecki
  2013-01-06 15:08 ` [PATCH 2/2] mtd: bcm47xxpart: register extra "firmware" partition Rafał Miłecki
@ 2013-01-17 12:38 ` Artem Bityutskiy
  2013-01-17 12:51   ` Hauke Mehrtens
  2013-01-17 13:22 ` Artem Bityutskiy
  2 siblings, 1 reply; 6+ messages in thread
From: Artem Bityutskiy @ 2013-01-17 12:38 UTC (permalink / raw)
  To: Rafał Miłecki; +Cc: Hauke Mehrtens, linux-mtd, David Woodhouse

[-- Attachment #1: Type: text/plain, Size: 950 bytes --]

On Sun, 2013-01-06 at 16:08 +0100, Rafał Miłecki wrote:
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
> ---
> I've checked this patch and got:
> > Successfully built configuration "mips-bcm47xx_defconfig,mips,mips-linux-", no issues

There is some breakage in upstream and aiaia cannot compile the bcm47xx
configuration. Any idea?

init/calibrate.c:257:47: warning: no previous prototype for 'calibrate_delay_is_known' [-Wmissing-prototypes]
In file included from arch/mips/bcm47xx/nvram.c:17:0:
include/linux/ssb/ssb.h:440:19: error: field 'gpio' has incomplete type
In file included from include/linux/bcma/bcma.h:7:0,
                 from arch/mips/include/asm/mach-bcm47xx/bcm47xx.h:23,
                 from arch/mips/bcm47xx/nvram.c:22:
include/linux/bcma/bcma_driver_chipcommon.h:582:19: error: field 'gpio' has incomplete type
make[3]: *** [arch/mips/bcm47xx/nvram.o] Error 1

-- 
Best Regards,
Artem Bityutskiy

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] mtd: bcm47xxpart: simplify size calculation to one loop
  2013-01-17 12:38 ` [PATCH 1/2] mtd: bcm47xxpart: simplify size calculation to one loop Artem Bityutskiy
@ 2013-01-17 12:51   ` Hauke Mehrtens
  2013-01-17 13:06     ` Artem Bityutskiy
  0 siblings, 1 reply; 6+ messages in thread
From: Hauke Mehrtens @ 2013-01-17 12:51 UTC (permalink / raw)
  To: dedekind1; +Cc: Rafał Miłecki, linux-mtd, David Woodhouse

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 01/17/2013 01:38 PM, Artem Bityutskiy wrote:
> On Sun, 2013-01-06 at 16:08 +0100, Rafał Miłecki wrote:
>> Signed-off-by: Rafał Miłecki <zajec5@gmail.com> --- I've checked
>> this patch and got:
>>> Successfully built configuration
>>> "mips-bcm47xx_defconfig,mips,mips-linux-", no issues
> 
> There is some breakage in upstream and aiaia cannot compile the
> bcm47xx configuration. Any idea?
> 
> init/calibrate.c:257:47: warning: no previous prototype for
> 'calibrate_delay_is_known' [-Wmissing-prototypes] In file included
> from arch/mips/bcm47xx/nvram.c:17:0: 
> include/linux/ssb/ssb.h:440:19: error: field 'gpio' has incomplete
> type In file included from include/linux/bcma/bcma.h:7:0, from
> arch/mips/include/asm/mach-bcm47xx/bcm47xx.h:23, from
> arch/mips/bcm47xx/nvram.c:22: 
> include/linux/bcma/bcma_driver_chipcommon.h:582:19: error: field
> 'gpio' has incomplete type make[3]: *** [arch/mips/bcm47xx/nvram.o]
> Error 1

This is a unrelated problem. There is a fix [0] in the mips tree on
its way into linus tree. As a workaround activate CONFIG_GPIOLIB.

Hauke

[0]: https://patchwork.linux-mips.org/patch/4759/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)
Comment: Using GnuPG with undefined - http://www.enigmail.net/

iQIcBAEBAgAGBQJQ9/PmAAoJEIZ0px9YPRMy1zoP/Ajkm1OL0gsuLkQ0GAoUIHkA
oVrST3hb3Nj1XRjiwst0AZBe6qm6Nc0lO2AXDKf9lxGTr7runNkrOi/ygeIL7x2S
sYqJQrGATLPv+6IWfI0INRCAvwDRTX8apAnf0hhUNDv72fIdby1M5OCGwePLCnC/
UJBLgPGOIDny5OSwj5idByoKbLrZUvmWIPNihj9Yqwneb3jOzklxbGnzf6rocU3v
rQkxVuI4nyOu8vEtpZqMiQBFfvlGMr2UmCOlKpxaRvXYm5R4LWJvErKVF3ADMqe5
UCLn6ZQHcnHnh1yOEpxxigAblYMSHxdsFzYmqzBHc8jdKW/PhnOoSxirSL5NGINc
oQFJ0hlsXe7trcRRPNUMpUiWFCfMUgxGnkoq56eNLxAFBYaR/oBBJDIX0nHlzjA1
MfdwGMfAprI8jiFPgEyFvBUUewCeCAnHOkKX06a7Fn3aoWEqVV2+2qmlzUrnpx4f
Hb0X9pNAJ5fkvwtzx6fDhPRNKKFpgiAdLpiGisndiSf5e2JIhO2hQU3ed9PWgGUN
Vx93EyVQbWkhg7ZY2Tlh157cUHcjzNA2X8v1fWC/atimoKGrl3ECBksmWnazXiHb
HqXPhk1oxgGz1wjtz/AkDEpfQvIK3y+Oixd4YQBar+askFyLHLK02Ab5CLves3E+
ZPZYXHPoAOg5uLkbO83c
=RL+q
-----END PGP SIGNATURE-----

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] mtd: bcm47xxpart: simplify size calculation to one loop
  2013-01-17 12:51   ` Hauke Mehrtens
@ 2013-01-17 13:06     ` Artem Bityutskiy
  0 siblings, 0 replies; 6+ messages in thread
From: Artem Bityutskiy @ 2013-01-17 13:06 UTC (permalink / raw)
  To: Hauke Mehrtens; +Cc: Rafał Miłecki, linux-mtd, David Woodhouse

[-- Attachment #1: Type: text/plain, Size: 377 bytes --]

On Thu, 2013-01-17 at 13:51 +0100, Hauke Mehrtens wrote:
> This is a unrelated problem. There is a fix [0] in the mips tree on
> its way into linus tree. As a workaround activate CONFIG_GPIOLIB.
> 
> Hauke
> 
> [0]: https://patchwork.linux-mips.org/patch/4759/

Thanks Hauke,

I've added your patch to my quick-fixes, thanks!

-- 
Best Regards,
Artem Bityutskiy

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] mtd: bcm47xxpart: simplify size calculation to one loop
  2013-01-06 15:08 [PATCH 1/2] mtd: bcm47xxpart: simplify size calculation to one loop Rafał Miłecki
  2013-01-06 15:08 ` [PATCH 2/2] mtd: bcm47xxpart: register extra "firmware" partition Rafał Miłecki
  2013-01-17 12:38 ` [PATCH 1/2] mtd: bcm47xxpart: simplify size calculation to one loop Artem Bityutskiy
@ 2013-01-17 13:22 ` Artem Bityutskiy
  2 siblings, 0 replies; 6+ messages in thread
From: Artem Bityutskiy @ 2013-01-17 13:22 UTC (permalink / raw)
  To: Rafał Miłecki; +Cc: Hauke Mehrtens, linux-mtd, David Woodhouse

[-- Attachment #1: Type: text/plain, Size: 190 bytes --]

On Sun, 2013-01-06 at 16:08 +0100, Rafał Miłecki wrote:
> Signed-off-by: Rafał Miłecki <zajec5@gmail.com>

Pushed both to l2-mtd.git, thanks!

-- 
Best Regards,
Artem Bityutskiy

[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-01-17 13:21 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-06 15:08 [PATCH 1/2] mtd: bcm47xxpart: simplify size calculation to one loop Rafał Miłecki
2013-01-06 15:08 ` [PATCH 2/2] mtd: bcm47xxpart: register extra "firmware" partition Rafał Miłecki
2013-01-17 12:38 ` [PATCH 1/2] mtd: bcm47xxpart: simplify size calculation to one loop Artem Bityutskiy
2013-01-17 12:51   ` Hauke Mehrtens
2013-01-17 13:06     ` Artem Bityutskiy
2013-01-17 13:22 ` Artem Bityutskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox