[OpenWrt-Devel] [PATCH 3/6] bcm53xx: bcm_nand: add support for overriding partition probe through device tree

Álvaro Fernández Rojas noltari at gmail.com
Sat May 16 06:53:21 EDT 2015


Signed-off-by: Álvaro Fernández Rojas <noltari at gmail.com>
---
 .../patches-3.18/420-mtd-bcm5301x_nand.patch       | 47 ++++++++++++++++++++--
 1 file changed, 43 insertions(+), 4 deletions(-)

diff --git a/target/linux/bcm53xx/patches-3.18/420-mtd-bcm5301x_nand.patch b/target/linux/bcm53xx/patches-3.18/420-mtd-bcm5301x_nand.patch
index 199f1e5..aa631e0 100644
--- a/target/linux/bcm53xx/patches-3.18/420-mtd-bcm5301x_nand.patch
+++ b/target/linux/bcm53xx/patches-3.18/420-mtd-bcm5301x_nand.patch
@@ -22,7 +22,7 @@
  nand-objs := nand_base.o nand_bbt.o nand_timings.o
 --- /dev/null
 +++ b/drivers/mtd/nand/bcm_nand.c
-@@ -0,0 +1,1583 @@
+@@ -0,0 +1,1622 @@
 +/*
 + * Nortstar NAND controller driver
 + *
@@ -1516,15 +1516,52 @@
 +	return 0;
 +}
 +
-+static const char * const part_probes[] = { "ofpart", "bcm47xxpart", NULL };
++static const char * const part_probe_types_def[] = { "ofpart", "bcm47xxpart", NULL };
++
++static const char * const *of_get_probes(struct device_node *dp)
++{
++	const char *cp;
++	int cplen;
++	unsigned int l;
++	unsigned int count;
++	const char **res;
++
++	cp = of_get_property(dp, "linux,part-probe", &cplen);
++	if (cp == NULL)
++		return part_probe_types_def;
++
++	count = 0;
++	for (l = 0; l != cplen; l++)
++		if (cp[l] == 0)
++			count++;
++
++	res = kzalloc((count + 1)*sizeof(*res), GFP_KERNEL);
++	count = 0;
++	while (cplen > 0) {
++		res[count] = cp;
++		l = strlen(cp) + 1;
++		cp += l;
++		cplen -= l;
++		count++;
++	}
++	return res;
++}
++
++static void of_free_probes(const char * const *probes)
++{
++	if (probes != part_probe_types_def)
++		kfree(probes);
++}
 +
 +/*
 + * Top-level init function
 + */
 +static int bcmnand_probe(struct bcma_device *core)
 +{
++	const char * const *part_probe_types;
 +	struct mtd_part_parser_data parser_data;
 +	struct device *dev = &core->dev;
++	struct device_node *dp = dev->of_node;
 +	struct bcmnand_ctrl *ctrl;
 +	int res, i, irq;
 +
@@ -1561,8 +1598,10 @@
 +	if (res)
 +		return res;
 +
-+	parser_data.of_node = dev->of_node;
-+	res = mtd_device_parse_register(&ctrl->mtd, part_probes, &parser_data, NULL, 0);
++	parser_data.of_node = dp;
++	part_probe_types = of_get_probes(dp);
++	res = mtd_device_parse_register(&ctrl->mtd, part_probe_types, &parser_data, NULL, 0);
++	of_free_probes(part_probe_types);
 +	if (res) {
 +		dev_err(dev, "Failed to register MTD device: %d\n", res);
 +		return res;
-- 
1.9.1
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list