[source] brcm63xx: backport mtd of node changes from upstream

LEDE Commits lede-commits at lists.infradead.org
Sat Aug 13 06:52:12 PDT 2016


jogo pushed a commit to source.git, branch master:
https://git.lede-project.org/?p=source.git;a=commitdiff;h=0ddae04c226983e1e064d8750b8bb8724f077ad9

commit 0ddae04c226983e1e064d8750b8bb8724f077ad9
Author: Jonas Gorski <jonas.gorski at gmail.com>
AuthorDate: Tue Aug 9 11:23:32 2016 +0200

    brcm63xx: backport mtd of node changes from upstream
    
    Should fix parser data containing uninitialized values for of probed
    physmap flashes, which could break e.g. the redboot parser.
    
    Signed-off-by: Jonas Gorski <jonas.gorski at gmail.com>
---
 ...td-add-get-set-of_node-flash_node-helpers.patch |  78 +++++++++
 ...grab-device-tree-node-directly-from-maste.patch |  74 ++++++++
 ...r-convert-to-spi_nor_-get-set-_flash_node.patch |  79 +++++++++
 ...or-drop-unnecessary-partition-parser-data.patch |  83 +++++++++
 ...td-drop-unnecessary-partition-parser-data.patch | 195 +++++++++++++++++++++
 ...ofpart-drop-of_node-partition-parser-data.patch |  61 +++++++
 .../120-mtdpart_fixup_generic_partprobe.patch      |  13 ++
 ...-m25p80-use-parsers-if-provided-in-flash-.patch |  17 +-
 ...CES-m25p80-add-support-for-limiting-reads.patch |   2 +-
 .../414-MTD-m25p80-allow-passing-pp_data.patch     |  20 +--
 ...cm63xxpart-allow-passing-a-caldata-offset.patch |   5 +-
 .../425-bcm63xxpart_parse_paritions_from_dt.patch  |   4 +-
 12 files changed, 608 insertions(+), 23 deletions(-)

diff --git a/target/linux/brcm63xx/patches-4.4/000-4.5-01-mtd-add-get-set-of_node-flash_node-helpers.patch b/target/linux/brcm63xx/patches-4.4/000-4.5-01-mtd-add-get-set-of_node-flash_node-helpers.patch
new file mode 100644
index 0000000..7b39d4a
--- /dev/null
+++ b/target/linux/brcm63xx/patches-4.4/000-4.5-01-mtd-add-get-set-of_node-flash_node-helpers.patch
@@ -0,0 +1,78 @@
+From 28b8b26b308e656edfa9467867d5f79212da2ec3 Mon Sep 17 00:00:00 2001
+From: Brian Norris <computersforpeace at gmail.com>
+Date: Fri, 30 Oct 2015 20:33:20 -0700
+Subject: [PATCH] mtd: add get/set of_node/flash_node helpers
+
+We are going to begin using the mtd->dev.of_node field for MTD device
+nodes, so let's add helpers for it. Also, we'll be making some
+conversions on spi_nor (and nand_chip eventually) too, so get that ready
+with their own helpers.
+
+Signed-off-by: Brian Norris <computersforpeace at gmail.com>
+Reviewed-by: Boris Brezillon <boris.brezillon at free-electrons.com>
+---
+ include/linux/mtd/mtd.h     | 11 +++++++++++
+ include/linux/mtd/nand.h    | 11 +++++++++++
+ include/linux/mtd/spi-nor.h | 11 +++++++++++
+ 3 files changed, 33 insertions(+)
+
+--- a/include/linux/mtd/mtd.h
++++ b/include/linux/mtd/mtd.h
+@@ -258,6 +258,17 @@ struct mtd_info {
+ 	int usecount;
+ };
+ 
++static inline void mtd_set_of_node(struct mtd_info *mtd,
++				   struct device_node *np)
++{
++	mtd->dev.of_node = np;
++}
++
++static inline struct device_node *mtd_get_of_node(struct mtd_info *mtd)
++{
++	return mtd->dev.of_node;
++}
++
+ int mtd_erase(struct mtd_info *mtd, struct erase_info *instr);
+ int mtd_point(struct mtd_info *mtd, loff_t from, size_t len, size_t *retlen,
+ 	      void **virt, resource_size_t *phys);
+--- a/include/linux/mtd/nand.h
++++ b/include/linux/mtd/nand.h
+@@ -719,6 +719,17 @@ struct nand_chip {
+ 	void *priv;
+ };
+ 
++static inline void nand_set_flash_node(struct nand_chip *chip,
++				       struct device_node *np)
++{
++	chip->flash_node = np;
++}
++
++static inline struct device_node *nand_get_flash_node(struct nand_chip *chip)
++{
++	return chip->flash_node;
++}
++
+ /*
+  * NAND Flash Manufacturer ID Codes
+  */
+--- a/include/linux/mtd/spi-nor.h
++++ b/include/linux/mtd/spi-nor.h
+@@ -184,6 +184,17 @@ struct spi_nor {
+ 	void *priv;
+ };
+ 
++static inline void spi_nor_set_flash_node(struct spi_nor *nor,
++					  struct device_node *np)
++{
++	nor->flash_node = np;
++}
++
++static inline struct device_node *spi_nor_get_flash_node(struct spi_nor *nor)
++{
++	return nor->flash_node;
++}
++
+ /**
+  * spi_nor_scan() - scan the SPI NOR
+  * @nor:	the spi_nor structure
diff --git a/target/linux/brcm63xx/patches-4.4/000-4.5-02-mtd-ofpart-grab-device-tree-node-directly-from-maste.patch b/target/linux/brcm63xx/patches-4.4/000-4.5-02-mtd-ofpart-grab-device-tree-node-directly-from-maste.patch
new file mode 100644
index 0000000..14ad2d4
--- /dev/null
+++ b/target/linux/brcm63xx/patches-4.4/000-4.5-02-mtd-ofpart-grab-device-tree-node-directly-from-maste.patch
@@ -0,0 +1,74 @@
+From 3b6521eab0386a4854d47b1a01947d7dc46ec98d Mon Sep 17 00:00:00 2001
+From: Brian Norris <computersforpeace at gmail.com>
+Date: Fri, 30 Oct 2015 20:33:21 -0700
+Subject: [PATCH] mtd: ofpart: grab device tree node directly from master
+ device node
+
+It seems more logical to use a device node directly associated with the
+MTD master device (i.e., mtd->dev.of_node field) rather than requiring
+auxiliary partition parser information to be passed in by the driver in
+a separate struct.
+
+This patch supports the mtd->dev.of_node field and deprecates the parser
+data 'of_node' field
+
+Driver conversions may now follow.
+
+Additional side benefit to assigning mtd->dev.of_node rather than using
+parser data: the driver core will automatically create a device -> node
+symlink for us.
+
+Signed-off-by: Brian Norris <computersforpeace at gmail.com>
+Reviewed-by: Boris Brezillon <boris.brezillon at free-electrons.com>
+---
+ drivers/mtd/ofpart.c           | 18 ++++++++++--------
+ include/linux/mtd/partitions.h |  4 +++-
+ 2 files changed, 13 insertions(+), 9 deletions(-)
+
+--- a/drivers/mtd/ofpart.c
++++ b/drivers/mtd/ofpart.c
+@@ -37,10 +37,11 @@ static int parse_ofpart_partitions(struc
+ 	bool dedicated = true;
+ 
+ 
+-	if (!data)
+-		return 0;
+-
+-	mtd_node = data->of_node;
++	/*
++	 * of_node can be provided through auxiliary parser data or (preferred)
++	 * by assigning the master device node
++	 */
++	mtd_node = data && data->of_node ? data->of_node : mtd_get_of_node(master);
+ 	if (!mtd_node)
+ 		return 0;
+ 
+@@ -157,10 +158,11 @@ static int parse_ofoldpart_partitions(st
+ 	} *part;
+ 	const char *names;
+ 
+-	if (!data)
+-		return 0;
+-
+-	dp = data->of_node;
++	/*
++	 * of_node can be provided through auxiliary parser data or (preferred)
++	 * by assigning the master device node
++	 */
++	dp = data && data->of_node ? data->of_node : mtd_get_of_node(master);
+ 	if (!dp)
+ 		return 0;
+ 
+--- a/include/linux/mtd/partitions.h
++++ b/include/linux/mtd/partitions.h
+@@ -56,7 +56,9 @@ struct device_node;
+ /**
+  * struct mtd_part_parser_data - used to pass data to MTD partition parsers.
+  * @origin: for RedBoot, start address of MTD device
+- * @of_node: for OF parsers, device node containing partitioning information
++ * @of_node: for OF parsers, device node containing partitioning information.
++ *           This field is deprecated, as the device node should simply be
++ *           assigned to the master struct device.
+  */
+ struct mtd_part_parser_data {
+ 	unsigned long origin;
diff --git a/target/linux/brcm63xx/patches-4.4/000-4.5-03-spi-nor-convert-to-spi_nor_-get-set-_flash_node.patch b/target/linux/brcm63xx/patches-4.4/000-4.5-03-spi-nor-convert-to-spi_nor_-get-set-_flash_node.patch
new file mode 100644
index 0000000..91fc1ff
--- /dev/null
+++ b/target/linux/brcm63xx/patches-4.4/000-4.5-03-spi-nor-convert-to-spi_nor_-get-set-_flash_node.patch
@@ -0,0 +1,79 @@
+From 9c7d787508be6d68a6ec66de3c3466b24e820c71 Mon Sep 17 00:00:00 2001
+From: Brian Norris <computersforpeace at gmail.com>
+Date: Fri, 30 Oct 2015 20:33:24 -0700
+Subject: [PATCH] mtd: spi-nor: convert to spi_nor_{get, set}_flash_node()
+
+Used semantic patch with 'make coccicheck MODE=patch COCCI=script.cocci':
+
+---8<----
+virtual patch
+
+@@
+struct spi_nor b;
+struct spi_nor *c;
+expression d;
+@@
+(
+-(b).flash_node = (d)
++spi_nor_set_flash_node(&b, d)
+|
+-(c)->flash_node = (d)
++spi_nor_set_flash_node(c, d)
+)
+---8<----
+
+And a manual conversion for the one use of spi_nor_get_flash_node().
+
+Signed-off-by: Brian Norris <computersforpeace at gmail.com>
+Reviewed-by: Boris Brezillon <boris.brezillon at free-electrons.com>
+---
+ drivers/mtd/devices/m25p80.c      | 2 +-
+ drivers/mtd/spi-nor/fsl-quadspi.c | 2 +-
+ drivers/mtd/spi-nor/nxp-spifi.c   | 2 +-
+ drivers/mtd/spi-nor/spi-nor.c     | 2 +-
+ 4 files changed, 4 insertions(+), 4 deletions(-)
+
+--- a/drivers/mtd/devices/m25p80.c
++++ b/drivers/mtd/devices/m25p80.c
+@@ -221,7 +221,7 @@ static int m25p_probe(struct spi_device
+ 	nor->read_reg = m25p80_read_reg;
+ 
+ 	nor->dev = &spi->dev;
+-	nor->flash_node = spi->dev.of_node;
++	spi_nor_set_flash_node(nor, spi->dev.of_node);
+ 	nor->priv = flash;
+ 
+ 	spi_set_drvdata(spi, flash);
+--- a/drivers/mtd/spi-nor/fsl-quadspi.c
++++ b/drivers/mtd/spi-nor/fsl-quadspi.c
+@@ -1013,7 +1013,7 @@ static int fsl_qspi_probe(struct platfor
+ 		mtd = &nor->mtd;
+ 
+ 		nor->dev = dev;
+-		nor->flash_node = np;
++		spi_nor_set_flash_node(nor, np);
+ 		nor->priv = q;
+ 
+ 		/* fill the hooks */
+--- a/drivers/mtd/spi-nor/nxp-spifi.c
++++ b/drivers/mtd/spi-nor/nxp-spifi.c
+@@ -330,7 +330,7 @@ static int nxp_spifi_setup_flash(struct
+ 	writel(ctrl, spifi->io_base + SPIFI_CTRL);
+ 
+ 	spifi->nor.dev   = spifi->dev;
+-	spifi->nor.flash_node = np;
++	spi_nor_set_flash_node(&spifi->nor, np);
+ 	spifi->nor.priv  = spifi;
+ 	spifi->nor.read  = nxp_spifi_read;
+ 	spifi->nor.write = nxp_spifi_write;
+--- a/drivers/mtd/spi-nor/spi-nor.c
++++ b/drivers/mtd/spi-nor/spi-nor.c
+@@ -1109,7 +1109,7 @@ int spi_nor_scan(struct spi_nor *nor, co
+ 	const struct flash_info *info = NULL;
+ 	struct device *dev = nor->dev;
+ 	struct mtd_info *mtd = &nor->mtd;
+-	struct device_node *np = nor->flash_node;
++	struct device_node *np = spi_nor_get_flash_node(nor);
+ 	int ret;
+ 	int i;
+ 
diff --git a/target/linux/brcm63xx/patches-4.4/000-4.5-04-mtd-spi-nor-drop-unnecessary-partition-parser-data.patch b/target/linux/brcm63xx/patches-4.4/000-4.5-04-mtd-spi-nor-drop-unnecessary-partition-parser-data.patch
new file mode 100644
index 0000000..dafde16
--- /dev/null
+++ b/target/linux/brcm63xx/patches-4.4/000-4.5-04-mtd-spi-nor-drop-unnecessary-partition-parser-data.patch
@@ -0,0 +1,83 @@
+From df02c885f8697546da41665f28dde5e30ce99674 Mon Sep 17 00:00:00 2001
+From: Brian Norris <computersforpeace at gmail.com>
+Date: Fri, 30 Oct 2015 20:33:26 -0700
+Subject: [PATCH] mtd: spi-nor: drop unnecessary partition parser data
+
+Now that the SPI-NOR/MTD framework pass the 'flash_node' through to the
+partition parsing code, we don't have to do it ourselves.
+
+Also convert to mtd_device_register(), since we don't need the 2nd and
+3rd parameters anymore.
+
+Signed-off-by: Brian Norris <computersforpeace at gmail.com>
+Reviewed-by: Boris Brezillon <boris.brezillon at free-electrons.com>
+---
+ drivers/mtd/devices/m25p80.c      | 8 ++------
+ drivers/mtd/spi-nor/fsl-quadspi.c | 4 +---
+ drivers/mtd/spi-nor/nxp-spifi.c   | 4 +---
+ 3 files changed, 4 insertions(+), 12 deletions(-)
+
+--- a/drivers/mtd/devices/m25p80.c
++++ b/drivers/mtd/devices/m25p80.c
+@@ -197,7 +197,6 @@ static int m25p80_erase(struct spi_nor *
+  */
+ static int m25p_probe(struct spi_device *spi)
+ {
+-	struct mtd_part_parser_data	ppdata;
+ 	struct flash_platform_data	*data;
+ 	struct m25p *flash;
+ 	struct spi_nor *nor;
+@@ -249,11 +248,8 @@ static int m25p_probe(struct spi_device
+ 	if (ret)
+ 		return ret;
+ 
+-	ppdata.of_node = spi->dev.of_node;
+-
+-	return mtd_device_parse_register(&nor->mtd, NULL, &ppdata,
+-			data ? data->parts : NULL,
+-			data ? data->nr_parts : 0);
++	return mtd_device_register(&nor->mtd, data ? data->parts : NULL,
++				   data ? data->nr_parts : 0);
+ }
+ 
+ 
+--- a/drivers/mtd/spi-nor/fsl-quadspi.c
++++ b/drivers/mtd/spi-nor/fsl-quadspi.c
+@@ -927,7 +927,6 @@ static void fsl_qspi_unprep(struct spi_n
+ static int fsl_qspi_probe(struct platform_device *pdev)
+ {
+ 	struct device_node *np = pdev->dev.of_node;
+-	struct mtd_part_parser_data ppdata;
+ 	struct device *dev = &pdev->dev;
+ 	struct fsl_qspi *q;
+ 	struct resource *res;
+@@ -1038,8 +1037,7 @@ static int fsl_qspi_probe(struct platfor
+ 		if (ret)
+ 			goto mutex_failed;
+ 
+-		ppdata.of_node = np;
+-		ret = mtd_device_parse_register(mtd, NULL, &ppdata, NULL, 0);
++		ret = mtd_device_register(mtd, NULL, 0);
+ 		if (ret)
+ 			goto mutex_failed;
+ 
+--- a/drivers/mtd/spi-nor/nxp-spifi.c
++++ b/drivers/mtd/spi-nor/nxp-spifi.c
+@@ -271,7 +271,6 @@ static void nxp_spifi_dummy_id_read(stru
+ static int nxp_spifi_setup_flash(struct nxp_spifi *spifi,
+ 				 struct device_node *np)
+ {
+-	struct mtd_part_parser_data ppdata;
+ 	enum read_mode flash_read;
+ 	u32 ctrl, property;
+ 	u16 mode = 0;
+@@ -361,8 +360,7 @@ static int nxp_spifi_setup_flash(struct
+ 		return ret;
+ 	}
+ 
+-	ppdata.of_node = np;
+-	ret = mtd_device_parse_register(&spifi->nor.mtd, NULL, &ppdata, NULL, 0);
++	ret = mtd_device_register(&spifi->nor.mtd, NULL, 0);
+ 	if (ret) {
+ 		dev_err(spifi->dev, "mtd device parse failed\n");
+ 		return ret;
diff --git a/target/linux/brcm63xx/patches-4.4/000-4.5-05-mtd-drop-unnecessary-partition-parser-data.patch b/target/linux/brcm63xx/patches-4.4/000-4.5-05-mtd-drop-unnecessary-partition-parser-data.patch
new file mode 100644
index 0000000..5bd6c8c
--- /dev/null
+++ b/target/linux/brcm63xx/patches-4.4/000-4.5-05-mtd-drop-unnecessary-partition-parser-data.patch
@@ -0,0 +1,195 @@
+From 004b5e6031f4e9fd90d565fb213b74cd06d03718 Mon Sep 17 00:00:00 2001
+From: Brian Norris <computersforpeace at gmail.com>
+Date: Fri, 30 Oct 2015 20:33:28 -0700
+Subject: [PATCH] mtd: drop unnecessary partition parser data
+
+We should assign the MTD dev.of_node instead of the parser data field.
+This gets us the equivalent partition parser behavior with fewer special
+fields and parameter passing.
+
+Also convert several of these to mtd_device_register(), since we don't
+need the 2nd and 3rd parameters anymore.
+
+Signed-off-by: Brian Norris <computersforpeace at gmail.com>
+Reviewed-by: Marek Vasut <marex at denx.de>
+Reviewed-by: Boris Brezillon <boris.brezillon at free-electrons.com>
+---
+ drivers/mtd/devices/mtd_dataflash.c | 5 ++---
+ drivers/mtd/devices/spear_smi.c     | 6 ++----
+ drivers/mtd/devices/st_spi_fsm.c    | 5 ++---
+ drivers/mtd/maps/lantiq-flash.c     | 5 ++---
+ drivers/mtd/maps/physmap_of.c       | 5 ++---
+ drivers/mtd/onenand/omap2.c         | 8 +++-----
+ 6 files changed, 13 insertions(+), 21 deletions(-)
+
+--- a/drivers/mtd/devices/mtd_dataflash.c
++++ b/drivers/mtd/devices/mtd_dataflash.c
+@@ -624,7 +624,6 @@ static int add_dataflash_otp(struct spi_
+ {
+ 	struct dataflash		*priv;
+ 	struct mtd_info			*device;
+-	struct mtd_part_parser_data	ppdata;
+ 	struct flash_platform_data	*pdata = dev_get_platdata(&spi->dev);
+ 	char				*otp_tag = "";
+ 	int				err = 0;
+@@ -656,6 +655,7 @@ static int add_dataflash_otp(struct spi_
+ 	device->priv = priv;
+ 
+ 	device->dev.parent = &spi->dev;
++	mtd_set_of_node(device, spi->dev.of_node);
+ 
+ 	if (revision >= 'c')
+ 		otp_tag = otp_setup(device, revision);
+@@ -665,8 +665,7 @@ static int add_dataflash_otp(struct spi_
+ 			pagesize, otp_tag);
+ 	spi_set_drvdata(spi, priv);
+ 
+-	ppdata.of_node = spi->dev.of_node;
+-	err = mtd_device_parse_register(device, NULL, &ppdata,
++	err = mtd_device_register(device,
+ 			pdata ? pdata->parts : NULL,
+ 			pdata ? pdata->nr_parts : 0);
+ 
+--- a/drivers/mtd/devices/spear_smi.c
++++ b/drivers/mtd/devices/spear_smi.c
+@@ -810,7 +810,6 @@ static int spear_smi_setup_banks(struct
+ 				 u32 bank, struct device_node *np)
+ {
+ 	struct spear_smi *dev = platform_get_drvdata(pdev);
+-	struct mtd_part_parser_data ppdata = {};
+ 	struct spear_smi_flash_info *flash_info;
+ 	struct spear_smi_plat_data *pdata;
+ 	struct spear_snor_flash *flash;
+@@ -855,6 +854,7 @@ static int spear_smi_setup_banks(struct
+ 		flash->mtd.name = flash_devices[flash_index].name;
+ 
+ 	flash->mtd.dev.parent = &pdev->dev;
++	mtd_set_of_node(&flash->mtd, np);
+ 	flash->mtd.type = MTD_NORFLASH;
+ 	flash->mtd.writesize = 1;
+ 	flash->mtd.flags = MTD_CAP_NORFLASH;
+@@ -881,10 +881,8 @@ static int spear_smi_setup_banks(struct
+ 		count = flash_info->nr_partitions;
+ 	}
+ #endif
+-	ppdata.of_node = np;
+ 
+-	ret = mtd_device_parse_register(&flash->mtd, NULL, &ppdata, parts,
+-					count);
++	ret = mtd_device_register(&flash->mtd, parts, count);
+ 	if (ret) {
+ 		dev_err(&dev->pdev->dev, "Err MTD partition=%d\n", ret);
+ 		return ret;
+--- a/drivers/mtd/devices/st_spi_fsm.c
++++ b/drivers/mtd/devices/st_spi_fsm.c
+@@ -2025,7 +2025,6 @@ boot_device_fail:
+ static int stfsm_probe(struct platform_device *pdev)
+ {
+ 	struct device_node *np = pdev->dev.of_node;
+-	struct mtd_part_parser_data ppdata;
+ 	struct flash_info *info;
+ 	struct resource *res;
+ 	struct stfsm *fsm;
+@@ -2035,7 +2034,6 @@ static int stfsm_probe(struct platform_d
+ 		dev_err(&pdev->dev, "No DT found\n");
+ 		return -EINVAL;
+ 	}
+-	ppdata.of_node = np;
+ 
+ 	fsm = devm_kzalloc(&pdev->dev, sizeof(*fsm), GFP_KERNEL);
+ 	if (!fsm)
+@@ -2106,6 +2104,7 @@ static int stfsm_probe(struct platform_d
+ 
+ 	fsm->mtd.name		= info->name;
+ 	fsm->mtd.dev.parent	= &pdev->dev;
++	mtd_set_of_node(&fsm->mtd, np);
+ 	fsm->mtd.type		= MTD_NORFLASH;
+ 	fsm->mtd.writesize	= 4;
+ 	fsm->mtd.writebufsize	= fsm->mtd.writesize;
+@@ -2124,7 +2123,7 @@ static int stfsm_probe(struct platform_d
+ 		(long long)fsm->mtd.size, (long long)(fsm->mtd.size >> 20),
+ 		fsm->mtd.erasesize, (fsm->mtd.erasesize >> 10));
+ 
+-	return mtd_device_parse_register(&fsm->mtd, NULL, &ppdata, NULL, 0);
++	return mtd_device_register(&fsm->mtd, NULL, 0);
+ }
+ 
+ static int stfsm_remove(struct platform_device *pdev)
+--- a/drivers/mtd/maps/lantiq-flash.c
++++ b/drivers/mtd/maps/lantiq-flash.c
+@@ -110,7 +110,6 @@ ltq_copy_to(struct map_info *map, unsign
+ static int
+ ltq_mtd_probe(struct platform_device *pdev)
+ {
+-	struct mtd_part_parser_data ppdata;
+ 	struct ltq_mtd *ltq_mtd;
+ 	struct cfi_private *cfi;
+ 	int err;
+@@ -161,13 +160,13 @@ ltq_mtd_probe(struct platform_device *pd
+ 	}
+ 
+ 	ltq_mtd->mtd->dev.parent = &pdev->dev;
++	mtd_set_of_node(ltq_mtd->mtd, pdev->dev.of_node);
+ 
+ 	cfi = ltq_mtd->map->fldrv_priv;
+ 	cfi->addr_unlock1 ^= 1;
+ 	cfi->addr_unlock2 ^= 1;
+ 
+-	ppdata.of_node = pdev->dev.of_node;
+-	err = mtd_device_parse_register(ltq_mtd->mtd, NULL, &ppdata, NULL, 0);
++	err = mtd_device_register(ltq_mtd->mtd, NULL, 0);
+ 	if (err) {
+ 		dev_err(&pdev->dev, "failed to add partitions\n");
+ 		goto err_destroy;
+--- a/drivers/mtd/maps/physmap_of.c
++++ b/drivers/mtd/maps/physmap_of.c
+@@ -128,7 +128,6 @@ static int of_flash_probe(struct platfor
+ 	int reg_tuple_size;
+ 	struct mtd_info **mtd_list = NULL;
+ 	resource_size_t res_size;
+-	struct mtd_part_parser_data ppdata;
+ 	bool map_indirect;
+ 	const char *mtd_name = NULL;
+ 
+@@ -272,8 +271,8 @@ static int of_flash_probe(struct platfor
+ 	if (err)
+ 		goto err_out;
+ 
+-	ppdata.of_node = dp;
+-	mtd_device_parse_register(info->cmtd, part_probe_types_def, &ppdata,
++	mtd_set_of_node(info->cmtd, dp);
++	mtd_device_parse_register(info->cmtd, part_probe_types_def, NULL,
+ 			NULL, 0);
+ 
+ 	kfree(mtd_list);
+--- a/drivers/mtd/onenand/omap2.c
++++ b/drivers/mtd/onenand/omap2.c
+@@ -614,7 +614,6 @@ static int omap2_onenand_probe(struct pl
+ 	struct onenand_chip *this;
+ 	int r;
+ 	struct resource *res;
+-	struct mtd_part_parser_data ppdata = {};
+ 
+ 	pdata = dev_get_platdata(&pdev->dev);
+ 	if (pdata == NULL) {
+@@ -713,6 +712,7 @@ static int omap2_onenand_probe(struct pl
+ 	c->mtd.priv = &c->onenand;
+ 
+ 	c->mtd.dev.parent = &pdev->dev;
++	mtd_set_of_node(&c->mtd, pdata->of_node);
+ 
+ 	this = &c->onenand;
+ 	if (c->dma_channel >= 0) {
+@@ -743,10 +743,8 @@ static int omap2_onenand_probe(struct pl
+ 	if ((r = onenand_scan(&c->mtd, 1)) < 0)
+ 		goto err_release_regulator;
+ 
+-	ppdata.of_node = pdata->of_node;
+-	r = mtd_device_parse_register(&c->mtd, NULL, &ppdata,
+-				      pdata ? pdata->parts : NULL,
+-				      pdata ? pdata->nr_parts : 0);
++	r = mtd_device_register(&c->mtd, pdata ? pdata->parts : NULL,
++				pdata ? pdata->nr_parts : 0);
+ 	if (r)
+ 		goto err_release_onenand;
+ 
diff --git a/target/linux/brcm63xx/patches-4.4/000-4.5-06-mtd-ofpart-drop-of_node-partition-parser-data.patch b/target/linux/brcm63xx/patches-4.4/000-4.5-06-mtd-ofpart-drop-of_node-partition-parser-data.patch
new file mode 100644
index 0000000..a94e422
--- /dev/null
+++ b/target/linux/brcm63xx/patches-4.4/000-4.5-06-mtd-ofpart-drop-of_node-partition-parser-data.patch
@@ -0,0 +1,61 @@
+From e270bca531b40cd0a143176eb093d173b9c6f418 Mon Sep 17 00:00:00 2001
+From: Brian Norris <computersforpeace at gmail.com>
+Date: Fri, 30 Oct 2015 20:33:29 -0700
+Subject: [PATCH] mtd: ofpart: drop 'of_node' partition parser data
+
+This field is no longer used anywhere, as it is superseded by
+mtd->dev.of_node.
+
+Signed-off-by: Brian Norris <computersforpeace at gmail.com>
+Reviewed-by: Boris Brezillon <boris.brezillon at free-electrons.com>
+---
+ drivers/mtd/ofpart.c           | 14 ++++----------
+ include/linux/mtd/partitions.h |  4 ----
+ 2 files changed, 4 insertions(+), 14 deletions(-)
+
+--- a/drivers/mtd/ofpart.c
++++ b/drivers/mtd/ofpart.c
+@@ -37,11 +37,8 @@ static int parse_ofpart_partitions(struc
+ 	bool dedicated = true;
+ 
+ 
+-	/*
+-	 * of_node can be provided through auxiliary parser data or (preferred)
+-	 * by assigning the master device node
+-	 */
+-	mtd_node = data && data->of_node ? data->of_node : mtd_get_of_node(master);
++	/* Pull of_node from the master device node */
++	mtd_node = mtd_get_of_node(master);
+ 	if (!mtd_node)
+ 		return 0;
+ 
+@@ -158,11 +155,8 @@ static int parse_ofoldpart_partitions(st
+ 	} *part;
+ 	const char *names;
+ 
+-	/*
+-	 * of_node can be provided through auxiliary parser data or (preferred)
+-	 * by assigning the master device node
+-	 */
+-	dp = data && data->of_node ? data->of_node : mtd_get_of_node(master);
++	/* Pull of_node from the master device node */
++	dp = mtd_get_of_node(master);
+ 	if (!dp)
+ 		return 0;
+ 
+--- a/include/linux/mtd/partitions.h
++++ b/include/linux/mtd/partitions.h
+@@ -56,13 +56,9 @@ struct device_node;
+ /**
+  * struct mtd_part_parser_data - used to pass data to MTD partition parsers.
+  * @origin: for RedBoot, start address of MTD device
+- * @of_node: for OF parsers, device node containing partitioning information.
+- *           This field is deprecated, as the device node should simply be
+- *           assigned to the master struct device.
+  */
+ struct mtd_part_parser_data {
+ 	unsigned long origin;
+-	struct device_node *of_node;
+ };
+ 
+ 
diff --git a/target/linux/brcm63xx/patches-4.4/120-mtdpart_fixup_generic_partprobe.patch b/target/linux/brcm63xx/patches-4.4/120-mtdpart_fixup_generic_partprobe.patch
new file mode 100644
index 0000000..b662c9b
--- /dev/null
+++ b/target/linux/brcm63xx/patches-4.4/120-mtdpart_fixup_generic_partprobe.patch
@@ -0,0 +1,13 @@
+--- a/drivers/mtd/mtdpart.c
++++ b/drivers/mtd/mtdpart.c
+@@ -978,8 +978,8 @@ int parse_mtd_partitions(struct mtd_info
+ 	int ret, err = 0;
+ 	const char *const *types_of = NULL;
+ 
+-	if (data && data->of_node) {
+-		types_of = of_get_probes(data->of_node);
++	if (mtd_get_of_node(master)) {
++		types_of = of_get_probes(mtd_get_of_node(master));
+ 		if (types_of != NULL)
+ 			types = types_of;
+ 	}
diff --git a/target/linux/brcm63xx/patches-4.4/202-MTD-DEVICES-m25p80-use-parsers-if-provided-in-flash-.patch b/target/linux/brcm63xx/patches-4.4/202-MTD-DEVICES-m25p80-use-parsers-if-provided-in-flash-.patch
index 4793836..6c26d6c 100644
--- a/target/linux/brcm63xx/patches-4.4/202-MTD-DEVICES-m25p80-use-parsers-if-provided-in-flash-.patch
+++ b/target/linux/brcm63xx/patches-4.4/202-MTD-DEVICES-m25p80-use-parsers-if-provided-in-flash-.patch
@@ -11,13 +11,16 @@ Signed-off-by: Jonas Gorski <jonas.gorski at gmail.com>
 
 --- a/drivers/mtd/devices/m25p80.c
 +++ b/drivers/mtd/devices/m25p80.c
-@@ -251,7 +251,8 @@ static int m25p_probe(struct spi_device
+@@ -248,8 +248,10 @@ static int m25p_probe(struct spi_device
+ 	if (ret)
+ 		return ret;
  
- 	ppdata.of_node = spi->dev.of_node;
- 
--	return mtd_device_parse_register(&nor->mtd, NULL, &ppdata,
+-	return mtd_device_register(&nor->mtd, data ? data->parts : NULL,
+-				   data ? data->nr_parts : 0);
 +	return mtd_device_parse_register(&nor->mtd,
-+			data ? data->part_probe_types : NULL, &ppdata,
- 			data ? data->parts : NULL,
- 			data ? data->nr_parts : 0);
++			data ? data->part_probe_types : NULL, NULL,
++			data ? data->parts : NULL,
++			data ? data->nr_parts : 0);
  }
+ 
+ 
diff --git a/target/linux/brcm63xx/patches-4.4/203-MTD-DEVICES-m25p80-add-support-for-limiting-reads.patch b/target/linux/brcm63xx/patches-4.4/203-MTD-DEVICES-m25p80-add-support-for-limiting-reads.patch
index 75a874d..ddb070c 100644
--- a/target/linux/brcm63xx/patches-4.4/203-MTD-DEVICES-m25p80-add-support-for-limiting-reads.patch
+++ b/target/linux/brcm63xx/patches-4.4/203-MTD-DEVICES-m25p80-add-support-for-limiting-reads.patch
@@ -58,7 +58,7 @@ Signed-off-by: Jonas Gorski <jonas.gorski at gmail.com>
  static int m25p80_erase(struct spi_nor *nor, loff_t offset)
  {
  	struct m25p *flash = nor->priv;
-@@ -245,6 +269,9 @@ static int m25p_probe(struct spi_device
+@@ -244,6 +268,9 @@ static int m25p_probe(struct spi_device
  	else
  		flash_name = spi->modalias;
  
diff --git a/target/linux/brcm63xx/patches-4.4/414-MTD-m25p80-allow-passing-pp_data.patch b/target/linux/brcm63xx/patches-4.4/414-MTD-m25p80-allow-passing-pp_data.patch
index bbb565e..a0b4b4f 100644
--- a/target/linux/brcm63xx/patches-4.4/414-MTD-m25p80-allow-passing-pp_data.patch
+++ b/target/linux/brcm63xx/patches-4.4/414-MTD-m25p80-allow-passing-pp_data.patch
@@ -4,22 +4,22 @@ Date: Tue, 1 May 2012 17:33:03 +0200
 Subject: [PATCH 64/79] MTD: m25p80: allow passing pp_data
 
 ---
- drivers/mtd/devices/m25p80.c |    3 +++
+ drivers/mtd/devices/m25p80.c |    5 +++--
  include/linux/spi/flash.h    |    2 ++
  2 files changed, 5 insertions(+)
 
 --- a/drivers/mtd/devices/m25p80.c
 +++ b/drivers/mtd/devices/m25p80.c
-@@ -272,6 +272,9 @@ static int m25p_probe(struct spi_device
- 	if (data)
- 		flash->max_transfer_len = data->max_transfer_len;
- 
-+	if (data && data->pp_data)
-+		memcpy(&ppdata, data->pp_data, sizeof(ppdata));
-+
- 	ret = spi_nor_scan(nor, flash_name, mode);
- 	if (ret)
+@@ -276,7 +276,8 @@ static int m25p_probe(struct spi_device
  		return ret;
+ 
+ 	return mtd_device_parse_register(&nor->mtd,
+-			data ? data->part_probe_types : NULL, NULL,
++			data ? data->part_probe_types : NULL,
++			data ? data->pp_data : NULL,
+ 			data ? data->parts : NULL,
+ 			data ? data->nr_parts : 0);
+ }
 --- a/include/linux/spi/flash.h
 +++ b/include/linux/spi/flash.h
 @@ -12,6 +12,7 @@ struct mtd_part_parser_data;
diff --git a/target/linux/brcm63xx/patches-4.4/417-MTD-bcm63xxpart-allow-passing-a-caldata-offset.patch b/target/linux/brcm63xx/patches-4.4/417-MTD-bcm63xxpart-allow-passing-a-caldata-offset.patch
index 3b02c07..c055308 100644
--- a/target/linux/brcm63xx/patches-4.4/417-MTD-bcm63xxpart-allow-passing-a-caldata-offset.patch
+++ b/target/linux/brcm63xx/patches-4.4/417-MTD-bcm63xxpart-allow-passing-a-caldata-offset.patch
@@ -105,16 +105,15 @@ contained in flash.
  		pr_info("Partition %d is %s offset %llx and length %llx\n", i,
 --- a/include/linux/mtd/partitions.h
 +++ b/include/linux/mtd/partitions.h
-@@ -56,10 +56,12 @@ struct device_node;
+@@ -56,9 +56,11 @@ struct device_node;
  /**
   * struct mtd_part_parser_data - used to pass data to MTD partition parsers.
   * @origin: for RedBoot, start address of MTD device
 + * @caldata: for CFE, start address of wifi calibration data
-  * @of_node: for OF parsers, device node containing partitioning information
   */
  struct mtd_part_parser_data {
  	unsigned long origin;
 +	unsigned long caldata[2];
- 	struct device_node *of_node;
  };
  
+ 
diff --git a/target/linux/brcm63xx/patches-4.4/425-bcm63xxpart_parse_paritions_from_dt.patch b/target/linux/brcm63xx/patches-4.4/425-bcm63xxpart_parse_paritions_from_dt.patch
index 53fc4c5..330ec1e 100644
--- a/target/linux/brcm63xx/patches-4.4/425-bcm63xxpart_parse_paritions_from_dt.patch
+++ b/target/linux/brcm63xx/patches-4.4/425-bcm63xxpart_parse_paritions_from_dt.patch
@@ -155,7 +155,7 @@
 +					   struct mtd_partition **pparts,
 +					   struct mtd_part_parser_data *data)
 +{
-+	struct device_node *dp = data->of_node;
++	struct device_node *dp = mtd_get_of_node(master);
 +	struct device_node *pp;
 +	int i, nr_parts = 0;
 +	const char *partname;
@@ -342,7 +342,7 @@
 +				    struct mtd_partition **pparts,
 +				    struct mtd_part_parser_data *data)
 +{
-+	if (data && data->of_node)
++	if (mtd_get_of_node(master))
 +		return bcm63xx_parse_cfe_partitions_of(master, pparts, data);
 +	else
 +		return bcm63xx_parse_cfe_partitions(master, pparts, data);



More information about the lede-commits mailing list