* [PATCH 0/5] MTD: bcm63xxpart: small code cleanup
@ 2012-11-12 9:52 Jonas Gorski
2012-11-12 9:52 ` [PATCH 1/5] MTD: bcm63xxpart: remove unused variable Jonas Gorski
` (6 more replies)
0 siblings, 7 replies; 8+ messages in thread
From: Jonas Gorski @ 2012-11-12 9:52 UTC (permalink / raw)
To: linux-mtd
Cc: Maxime Bizon, Kevin Cernekee, David Woodhouse, Florian Fainelli,
Artem Bityutskiy
Here is a bunch of small code cleanups. No functional changes.
Jonas Gorski (5):
MTD: bcm63xxpart: remove unused variable
MTD: bcm63xxpart: merge sparelen calculation
MTD: bcm63xxpart: make fixed part length calculation more generic
MTD: bcm63xxpart: move the last curpart++ to its correct place
MTD: bcm63xxpart: use correct printk format for partitions
drivers/mtd/bcm63xxpart.c | 32 ++++++++++++++------------------
1 files changed, 14 insertions(+), 18 deletions(-)
--
1.7.2.5
^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/5] MTD: bcm63xxpart: remove unused variable
2012-11-12 9:52 [PATCH 0/5] MTD: bcm63xxpart: small code cleanup Jonas Gorski
@ 2012-11-12 9:52 ` Jonas Gorski
2012-11-12 9:52 ` [PATCH 2/5] MTD: bcm63xxpart: merge sparelen calculation Jonas Gorski
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Jonas Gorski @ 2012-11-12 9:52 UTC (permalink / raw)
To: linux-mtd
Cc: Maxime Bizon, Kevin Cernekee, David Woodhouse, Florian Fainelli,
Artem Bityutskiy
namelen is never used, so drop it.
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
drivers/mtd/bcm63xxpart.c | 11 +++--------
1 files changed, 3 insertions(+), 8 deletions(-)
diff --git a/drivers/mtd/bcm63xxpart.c b/drivers/mtd/bcm63xxpart.c
index 63d2a64..1eb1416 100644
--- a/drivers/mtd/bcm63xxpart.c
+++ b/drivers/mtd/bcm63xxpart.c
@@ -79,7 +79,6 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,
unsigned int rootfsaddr, kerneladdr, spareaddr;
unsigned int rootfslen, kernellen, sparelen, totallen;
unsigned int cfelen, nvramlen;
- int namelen = 0;
int i;
u32 computed_crc;
bool rootfs_first = false;
@@ -143,15 +142,11 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,
}
/* Determine number of partitions */
- namelen = 8;
- if (rootfslen > 0) {
+ if (rootfslen > 0)
nrparts++;
- namelen += 6;
- }
- if (kernellen > 0) {
+
+ if (kernellen > 0)
nrparts++;
- namelen += 6;
- }
/* Ask kernel for more memory */
parts = kzalloc(sizeof(*parts) * nrparts + 10 * nrparts, GFP_KERNEL);
--
1.7.2.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/5] MTD: bcm63xxpart: merge sparelen calculation
2012-11-12 9:52 [PATCH 0/5] MTD: bcm63xxpart: small code cleanup Jonas Gorski
2012-11-12 9:52 ` [PATCH 1/5] MTD: bcm63xxpart: remove unused variable Jonas Gorski
@ 2012-11-12 9:52 ` Jonas Gorski
2012-11-12 9:52 ` [PATCH 3/5] MTD: bcm63xxpart: make fixed part length calculation more generic Jonas Gorski
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Jonas Gorski @ 2012-11-12 9:52 UTC (permalink / raw)
To: linux-mtd
Cc: Maxime Bizon, Kevin Cernekee, David Woodhouse, Florian Fainelli,
Artem Bityutskiy
The length of the spare part is calculated the same way in both branches
so move to a common place.
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
drivers/mtd/bcm63xxpart.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/drivers/mtd/bcm63xxpart.c b/drivers/mtd/bcm63xxpart.c
index 1eb1416..ba7eeb8 100644
--- a/drivers/mtd/bcm63xxpart.c
+++ b/drivers/mtd/bcm63xxpart.c
@@ -120,7 +120,6 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,
kerneladdr = kerneladdr - BCM63XX_EXTENDED_SIZE;
rootfsaddr = rootfsaddr - BCM63XX_EXTENDED_SIZE;
spareaddr = roundup(totallen, master->erasesize) + cfelen;
- sparelen = master->size - spareaddr - nvramlen;
if (rootfsaddr < kerneladdr) {
/* default Broadcom layout */
@@ -138,8 +137,8 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,
rootfslen = 0;
rootfsaddr = 0;
spareaddr = cfelen;
- sparelen = master->size - cfelen - nvramlen;
}
+ sparelen = master->size - spareaddr - nvramlen;
/* Determine number of partitions */
if (rootfslen > 0)
--
1.7.2.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/5] MTD: bcm63xxpart: make fixed part length calculation more generic
2012-11-12 9:52 [PATCH 0/5] MTD: bcm63xxpart: small code cleanup Jonas Gorski
2012-11-12 9:52 ` [PATCH 1/5] MTD: bcm63xxpart: remove unused variable Jonas Gorski
2012-11-12 9:52 ` [PATCH 2/5] MTD: bcm63xxpart: merge sparelen calculation Jonas Gorski
@ 2012-11-12 9:52 ` Jonas Gorski
2012-11-12 9:52 ` [PATCH 4/5] MTD: bcm63xxpart: move the last curpart++ to its correct place Jonas Gorski
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Jonas Gorski @ 2012-11-12 9:52 UTC (permalink / raw)
To: linux-mtd
Cc: Maxime Bizon, Kevin Cernekee, David Woodhouse, Florian Fainelli,
Artem Bityutskiy
The CFE does not use 4K sectors even if the flash supports it, so
for the fixed partitions like CFE itself or NVRAM the erase block
size is always 64k or bigger.
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
drivers/mtd/bcm63xxpart.c | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/drivers/mtd/bcm63xxpart.c b/drivers/mtd/bcm63xxpart.c
index ba7eeb8..b3db8e3 100644
--- a/drivers/mtd/bcm63xxpart.c
+++ b/drivers/mtd/bcm63xxpart.c
@@ -37,8 +37,7 @@
#define BCM63XX_EXTENDED_SIZE 0xBFC00000 /* Extended flash address */
-#define BCM63XX_MIN_CFE_SIZE 0x10000 /* always at least 64KiB */
-#define BCM63XX_MIN_NVRAM_SIZE 0x10000 /* always at least 64KiB */
+#define BCM63XX_CFE_BLOCK_SIZE 0x10000 /* always at least 64KiB */
#define BCM63XX_CFE_MAGIC_OFFSET 0x4e0
@@ -79,6 +78,7 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,
unsigned int rootfsaddr, kerneladdr, spareaddr;
unsigned int rootfslen, kernellen, sparelen, totallen;
unsigned int cfelen, nvramlen;
+ unsigned int cfe_erasesize;
int i;
u32 computed_crc;
bool rootfs_first = false;
@@ -86,8 +86,11 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,
if (bcm63xx_detect_cfe(master))
return -EINVAL;
- cfelen = max_t(uint32_t, master->erasesize, BCM63XX_MIN_CFE_SIZE);
- nvramlen = max_t(uint32_t, master->erasesize, BCM63XX_MIN_NVRAM_SIZE);
+ cfe_erasesize = max_t(uint32_t, master->erasesize,
+ BCM63XX_CFE_BLOCK_SIZE);
+
+ cfelen = cfe_erasesize;
+ nvramlen = cfe_erasesize;
/* Allocate memory for buffer */
buf = vmalloc(sizeof(struct bcm_tag));
--
1.7.2.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 4/5] MTD: bcm63xxpart: move the last curpart++ to its correct place
2012-11-12 9:52 [PATCH 0/5] MTD: bcm63xxpart: small code cleanup Jonas Gorski
` (2 preceding siblings ...)
2012-11-12 9:52 ` [PATCH 3/5] MTD: bcm63xxpart: make fixed part length calculation more generic Jonas Gorski
@ 2012-11-12 9:52 ` Jonas Gorski
2012-11-12 9:52 ` [PATCH 5/5] MTD: bcm63xxpart: use correct printk format for partitions Jonas Gorski
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Jonas Gorski @ 2012-11-12 9:52 UTC (permalink / raw)
To: linux-mtd
Cc: Maxime Bizon, Kevin Cernekee, David Woodhouse, Florian Fainelli,
Artem Bityutskiy
The line belongs above the comment, not below it.
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
drivers/mtd/bcm63xxpart.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/mtd/bcm63xxpart.c b/drivers/mtd/bcm63xxpart.c
index b3db8e3..44cba4e 100644
--- a/drivers/mtd/bcm63xxpart.c
+++ b/drivers/mtd/bcm63xxpart.c
@@ -190,9 +190,9 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,
parts[curpart].name = "nvram";
parts[curpart].offset = master->size - nvramlen;
parts[curpart].size = nvramlen;
+ curpart++;
/* Global partition "linux" to make easy firmware upgrade */
- curpart++;
parts[curpart].name = "linux";
parts[curpart].offset = cfelen;
parts[curpart].size = master->size - cfelen - nvramlen;
--
1.7.2.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 5/5] MTD: bcm63xxpart: use correct printk format for partitions
2012-11-12 9:52 [PATCH 0/5] MTD: bcm63xxpart: small code cleanup Jonas Gorski
` (3 preceding siblings ...)
2012-11-12 9:52 ` [PATCH 4/5] MTD: bcm63xxpart: move the last curpart++ to its correct place Jonas Gorski
@ 2012-11-12 9:52 ` Jonas Gorski
2012-11-12 9:59 ` [PATCH 0/5] MTD: bcm63xxpart: small code cleanup Florian Fainelli
2012-11-21 15:15 ` Artem Bityutskiy
6 siblings, 0 replies; 8+ messages in thread
From: Jonas Gorski @ 2012-11-12 9:52 UTC (permalink / raw)
To: linux-mtd
Cc: Maxime Bizon, Kevin Cernekee, David Woodhouse, Florian Fainelli,
Artem Bityutskiy
Use ll to be able to remove the casts.
Signed-off-by: Jonas Gorski <jonas.gorski@gmail.com>
---
drivers/mtd/bcm63xxpart.c | 5 ++---
1 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/mtd/bcm63xxpart.c b/drivers/mtd/bcm63xxpart.c
index 44cba4e..6eeb84c 100644
--- a/drivers/mtd/bcm63xxpart.c
+++ b/drivers/mtd/bcm63xxpart.c
@@ -198,9 +198,8 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,
parts[curpart].size = master->size - cfelen - nvramlen;
for (i = 0; i < nrparts; i++)
- pr_info("Partition %d is %s offset %lx and length %lx\n", i,
- parts[i].name, (long unsigned int)(parts[i].offset),
- (long unsigned int)(parts[i].size));
+ pr_info("Partition %d is %s offset %llx and length %llx\n", i,
+ parts[i].name, parts[i].offset, parts[i].size);
pr_info("Spare partition is offset %x and length %x\n", spareaddr,
sparelen);
--
1.7.2.5
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH 0/5] MTD: bcm63xxpart: small code cleanup
2012-11-12 9:52 [PATCH 0/5] MTD: bcm63xxpart: small code cleanup Jonas Gorski
` (4 preceding siblings ...)
2012-11-12 9:52 ` [PATCH 5/5] MTD: bcm63xxpart: use correct printk format for partitions Jonas Gorski
@ 2012-11-12 9:59 ` Florian Fainelli
2012-11-21 15:15 ` Artem Bityutskiy
6 siblings, 0 replies; 8+ messages in thread
From: Florian Fainelli @ 2012-11-12 9:59 UTC (permalink / raw)
To: Jonas Gorski
Cc: David Woodhouse, Maxime Bizon, Kevin Cernekee, linux-mtd,
Artem Bityutskiy
On Monday 12 November 2012 10:52:46 Jonas Gorski wrote:
> Here is a bunch of small code cleanups. No functional changes.
>
> Jonas Gorski (5):
> MTD: bcm63xxpart: remove unused variable
> MTD: bcm63xxpart: merge sparelen calculation
> MTD: bcm63xxpart: make fixed part length calculation more generic
> MTD: bcm63xxpart: move the last curpart++ to its correct place
> MTD: bcm63xxpart: use correct printk format for partitions
For this entire serie:
Reviewed-by: Florian Fainelli <florian@openwrt.org>
Thanks Jonas!
--
Florian
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH 0/5] MTD: bcm63xxpart: small code cleanup
2012-11-12 9:52 [PATCH 0/5] MTD: bcm63xxpart: small code cleanup Jonas Gorski
` (5 preceding siblings ...)
2012-11-12 9:59 ` [PATCH 0/5] MTD: bcm63xxpart: small code cleanup Florian Fainelli
@ 2012-11-21 15:15 ` Artem Bityutskiy
6 siblings, 0 replies; 8+ messages in thread
From: Artem Bityutskiy @ 2012-11-21 15:15 UTC (permalink / raw)
To: Jonas Gorski
Cc: David Woodhouse, Kevin Cernekee, linux-mtd, Florian Fainelli,
Maxime Bizon
[-- Attachment #1: Type: text/plain, Size: 530 bytes --]
On Mon, 2012-11-12 at 10:52 +0100, Jonas Gorski wrote:
> Here is a bunch of small code cleanups. No functional changes.
>
> Jonas Gorski (5):
> MTD: bcm63xxpart: remove unused variable
> MTD: bcm63xxpart: merge sparelen calculation
> MTD: bcm63xxpart: make fixed part length calculation more generic
> MTD: bcm63xxpart: move the last curpart++ to its correct place
> MTD: bcm63xxpart: use correct printk format for partitions
Pushed the series 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] 8+ messages in thread
end of thread, other threads:[~2012-11-21 15:14 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-11-12 9:52 [PATCH 0/5] MTD: bcm63xxpart: small code cleanup Jonas Gorski
2012-11-12 9:52 ` [PATCH 1/5] MTD: bcm63xxpart: remove unused variable Jonas Gorski
2012-11-12 9:52 ` [PATCH 2/5] MTD: bcm63xxpart: merge sparelen calculation Jonas Gorski
2012-11-12 9:52 ` [PATCH 3/5] MTD: bcm63xxpart: make fixed part length calculation more generic Jonas Gorski
2012-11-12 9:52 ` [PATCH 4/5] MTD: bcm63xxpart: move the last curpart++ to its correct place Jonas Gorski
2012-11-12 9:52 ` [PATCH 5/5] MTD: bcm63xxpart: use correct printk format for partitions Jonas Gorski
2012-11-12 9:59 ` [PATCH 0/5] MTD: bcm63xxpart: small code cleanup Florian Fainelli
2012-11-21 15:15 ` Artem Bityutskiy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox