mtd: bcm63xxpart: Move NOR flash layout to a separate function
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Thu Mar 24 11:59:06 PDT 2016
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=4110fdd295e1219f4e4c4e35e2eba7b605b74ed7
Commit: 4110fdd295e1219f4e4c4e35e2eba7b605b74ed7
Parent: 2c4fd433fb934c7d5ed02113a5eaa3edb42ea10b
Author: Simon Arlott <simon at fire.lp0.eu>
AuthorDate: Sun Dec 13 22:52:15 2015 +0000
Committer: Brian Norris <computersforpeace at gmail.com>
CommitDate: Fri Feb 12 10:34:16 2016 -0800
mtd: bcm63xxpart: Move NOR flash layout to a separate function
Move the NOR flash layout to a separate function to allow the NAND flash
layout to be supported.
Signed-off-by: Simon Arlott <simon at fire.lp0.eu>
Signed-off-by: Brian Norris <computersforpeace at gmail.com>
---
drivers/mtd/bcm63xxpart.c | 54 ++++++++++++++++++++++++++++-------------------
1 file changed, 32 insertions(+), 22 deletions(-)
diff --git a/drivers/mtd/bcm63xxpart.c b/drivers/mtd/bcm63xxpart.c
index 41aa202..26c38a1 100644
--- a/drivers/mtd/bcm63xxpart.c
+++ b/drivers/mtd/bcm63xxpart.c
@@ -124,13 +124,11 @@ static int bcm63xx_read_image_tag(struct mtd_info *master, const char *name,
return 1;
}
-static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,
- const struct mtd_partition **pparts,
- struct mtd_part_parser_data *data)
+static int bcm63xx_parse_cfe_nor_partitions(struct mtd_info *master,
+ const struct mtd_partition **pparts, struct bcm963xx_nvram *nvram)
{
/* CFE, NVRAM and global Linux are always present */
int nrparts = 3, curpart = 0;
- struct bcm963xx_nvram *nvram = NULL;
struct bcm_tag *buf = NULL;
struct mtd_partition *parts;
int ret;
@@ -141,17 +139,6 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,
int i;
bool rootfs_first = false;
- if (bcm63xx_detect_cfe(master))
- return -EINVAL;
-
- nvram = vzalloc(sizeof(*nvram));
- if (!nvram)
- return -ENOMEM;
-
- ret = bcm63xx_read_nvram(master, nvram);
- if (ret)
- goto out;
-
cfe_erasesize = max_t(uint32_t, master->erasesize,
BCM963XX_CFE_BLOCK_SIZE);
@@ -159,12 +146,9 @@ static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,
nvramlen = nvram->psi_size * SZ_1K;
nvramlen = roundup(nvramlen, cfe_erasesize);
- /* Allocate memory for buffer */
buf = vmalloc(sizeof(struct bcm_tag));
- if (!buf) {
- ret = -ENOMEM;
- goto out;
- }
+ if (!buf)
+ return -ENOMEM;
/* Get the tag */
ret = bcm63xx_read_image_tag(master, "rootfs", cfelen, buf);
@@ -234,7 +218,6 @@ invalid_tag:
if (kernellen > 0)
nrparts++;
- /* Ask kernel for more memory */
parts = kzalloc(sizeof(*parts) * nrparts + 10 * nrparts, GFP_KERNEL);
if (!parts) {
ret = -ENOMEM;
@@ -292,13 +275,40 @@ invalid_tag:
ret = 0;
out:
- vfree(nvram);
vfree(buf);
if (ret)
return ret;
return nrparts;
+}
+
+static int bcm63xx_parse_cfe_partitions(struct mtd_info *master,
+ const struct mtd_partition **pparts,
+ struct mtd_part_parser_data *data)
+{
+ struct bcm963xx_nvram *nvram = NULL;
+ int ret;
+
+ if (bcm63xx_detect_cfe(master))
+ return -EINVAL;
+
+ nvram = vzalloc(sizeof(*nvram));
+ if (!nvram)
+ return -ENOMEM;
+
+ ret = bcm63xx_read_nvram(master, nvram);
+ if (ret)
+ goto out;
+
+ if (!mtd_type_is_nand(master))
+ ret = bcm63xx_parse_cfe_nor_partitions(master, pparts, nvram);
+ else
+ ret = -EINVAL;
+
+out:
+ vfree(nvram);
+ return ret;
};
static struct mtd_part_parser bcm63xx_cfe_parser = {
More information about the linux-mtd-cvs
mailing list