Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1290739

[PATCH linux-next v4 10/11] mtd: bcm63xxpart: Move NOR flash layout to a separate function

Path csiph.com!au2pb.net!feeder.erje.net!2.us.feeder.erje.net!nntpspool01.opticnetworks.net!aioe.org!bofh.it!news.nic.it!robomod
From Simon Arlott <simon@fire.lp0.eu>
Newsgroups linux.kernel
Subject [PATCH linux-next v4 10/11] mtd: bcm63xxpart: Move NOR flash layout to a separate function
Date Mon, 14 Dec 2015 00:00:02 +0100
Message-ID <qFnMu-638-5@gated-at.bofh.it> (permalink)
References <qFnCN-5ZR-3@gated-at.bofh.it>
X-Original-To Ralf Baechle <ralf@linux-mips.org>, David Woodhouse <dwmw2@infradead.org>, Brian Norris <computersforpeace@gmail.com>, Kevin Cernekee <cernekee@gmail.com>, Florian Fainelli <f.fainelli@gmail.com>, Jonas Gorski <jogo@openwrt.org>
Dkim-Signature v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=fire.lp0.eu; s=exim; h=Content-Transfer-Encoding:Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:Cc:References:To:Subject; bh=EJJTKb6JA8fZxv0JOfb/4ZLwvEES2/I5jvez/jAvSxc=; b=KeOn/Qb7E6wdJro4G6CR1R27ZBJoLkt7AGrV6iJ/sFakISK+49QV/fN/ZJdbWMNenO1F8XA+zaATjv2C8n+yR9pBy8mDMdeLye3FHiI4oftiDqNu/7ak71gvl6YGlVxy6Fwjaj4fITB4Tr4i0iQjF1QuI6dg86Q0VSbH55rt48rjkXkFb6uKWtWlYbny2yNMMgR8fSo84bVBzJV5eUcspxIBq+8bBWPZ8HUewnMfjrIV9p9GLmb85FOVtgVKa/YUr8JHVr3nRO8/KV0ZtaFxWYST66I3UDOr0OVfk0GB313Ojt13uWm4LeT3t+iWJ1ZsehqvoB/RFCF44qRVV8/GPw==;
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0
MIME-Version 1.0
Content-Type text/plain; charset=utf-8
Content-Transfer-Encoding 7bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 123
Organization linux.* mail to news gateway
X-Original-Cc Linux Kernel Mailing List <linux-kernel@vger.kernel.org>, MIPS Mailing List <linux-mips@linux-mips.org>, MTD Maling List <linux-mtd@lists.infradead.org>
X-Original-Date Sun, 13 Dec 2015 22:52:15 +0000
X-Original-Message-ID <566DF69F.5090700@simon.arlott.org.uk>
X-Original-References <566DF43B.5010400@simon.arlott.org.uk>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1290739

Show key headers only | View raw


Move the NOR flash layout to a separate function to allow the NAND flash
layout to be supported.

Signed-off-by: Simon Arlott <simon@fire.lp0.eu>
---
v4: New patch.

 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 = {
-- 
2.1.4

-- 
Simon Arlott
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH linux-next v4 00/11] mtd: bcm63xxpart: Add NAND partitioning  support Simon Arlott <simon@fire.lp0.eu> - 2015-12-13 23:50 +0100
  [PATCH linux-next v4 10/11] mtd: bcm63xxpart: Move NOR flash layout  to a separate function Simon Arlott <simon@fire.lp0.eu> - 2015-12-14 00:00 +0100
  [PATCH linux-next v4 08/11] mtd: bcm63xxpart: Extract read of image  tag to separate function Simon Arlott <simon@fire.lp0.eu> - 2015-12-14 00:00 +0100
  [PATCH linux-next v4 11/11] mtd: bcm63xxpart: Add NAND partitioning  support Simon Arlott <simon@fire.lp0.eu> - 2015-12-14 00:00 +0100
  [PATCH linux-next v4 07/11] MIPS: bcm63xx: nvram: Remove unused  bcm63xx_nvram_get_psi_size() function Simon Arlott <simon@fire.lp0.eu> - 2015-12-14 00:00 +0100
  [PATCH linux-next v4 09/11] mtd: bcm63xxpart: Null terminate and  validate conversion of flash strings Simon Arlott <simon@fire.lp0.eu> - 2015-12-14 00:00 +0100

csiph-web