mtd: bcm47xxpart: simplify size calculation to one loop
PATCH 1/2 mtd: bcm47xxpart: simplify size calculation to one loop
---
I've checked this patch and got:
Quoted 1 line
Successfully built configuration "mips-bcm47xx_defconfig,mips,mips-linux-", no issues
--- drivers/mtd/bcm47xxpart.c | 11 ++++++----- 1 files changed, 6 insertions(+), 5 deletions(-)
drivers/mtd/bcm47xxpart.c +6 -5
@@ -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;
Signature · 1 line
1.7.7
PATCH 2/2 mtd: bcm47xxpart: register extra "firmware" partition
It's required for accessing trx header (usually re-calculating a checksum) and for writing a new firmware.
---
I've checked this patch and got:
Quoted 1 line
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(-)
drivers/mtd/bcm47xxpart.c +11 -0
@@ -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;
Signature · 1 line
1.7.7
Quoted 4 lines · Rafał Miłecki
Signed-off-by Rafał Miłecki <[email protected]>---
I've checked this patch and got:Quoted 1 line
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
Signature · 2 lines
Best Regards, Artem Bityutskiy
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Quoted 9 lines · Artem Bityutskiy
Quoted 4 lines · Rafał Miłecki
Signed-off-by Rafał Miłecki <[email protected]> --- I've checkedthis patch and got:
Quoted 2 lines
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?
Quoted 10 lines
init/calibrate.c:257:47: warning: no previous prototype for 'calibrate_delay_is_known' [-Wmissing-prototypes] In file included fromarch/mips/bcm47xx/nvram.c:17:0:include/linux/ssb/ssb.h:440:19: error: field 'gpio' has incomplete type In file included frominclude/linux/bcma/bcma.h:7:0, fromarch/mips/include/asm/mach-bcm47xx/bcm47xx.h:23, fromarch/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-----
Quoted 6 lines · Hauke Mehrtens
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
Thanks Hauke,
I've added your patch to my quick-fixes, thanks!
Signature · 2 lines
Best Regards, Artem Bityutskiy
Quoted 1 line · Rafał Miłecki
Signed-off-by Rafał Miłecki <[email protected]>
Pushed both to l2-mtd.git, thanks!
Signature · 2 lines
Best Regards, Artem Bityutskiy