Skip to content

Commit f7bd194

Browse files
nxpfranklimiquelraynal
authored andcommitted
mtd: rawnand: mxc: set chip->of_node to nand@0 child node if present
The nand-controller.yaml binding requires a child node (e.g. nand@0) under the NAND controller. However, the driver currently assigns the controller's of_node directly to the NAND chip. Search for the first child node with the "nand" prefix and assign it to chip->of_node. This filters out properties such as "partition" that may be placed under the controller node in some older DTS files. Fall back to using the controller's of_node if no suitable child node is found to maintain backward compatibility. This issue went unnoticed because the default behavior works for most NAND chips. Signed-off-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
1 parent 3a6e21e commit f7bd194

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

drivers/mtd/nand/raw/mxc_nand.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Copyright 2008 Sascha Hauer, kernel@pengutronix.de
55
*/
66

7+
#include <linux/cleanup.h>
78
#include <linux/delay.h>
89
#include <linux/slab.h>
910
#include <linux/init.h>
@@ -1714,7 +1715,14 @@ static int mxcnd_probe(struct platform_device *pdev)
17141715
this->legacy.chip_delay = 5;
17151716

17161717
nand_set_controller_data(this, host);
1717-
nand_set_flash_node(this, pdev->dev.of_node);
1718+
1719+
struct device_node *np __free(device_node) =
1720+
of_get_next_child_with_prefix(pdev->dev.of_node, NULL, "nand");
1721+
1722+
if (np)
1723+
nand_set_flash_node(this, np);
1724+
else
1725+
nand_set_flash_node(this, pdev->dev.of_node);
17181726

17191727
host->clk = devm_clk_get(&pdev->dev, NULL);
17201728
if (IS_ERR(host->clk))

0 commit comments

Comments
 (0)