Skip to content

Commit ee78d46

Browse files
nxpfranklimiquelraynal
authored andcommitted
mtd: rawnand: ifc: 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 f7bd194 commit ee78d46

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

drivers/mtd/nand/raw/fsl_ifc_nand.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Author: Dipen Dudhat <Dipen.Dudhat@freescale.com>
88
*/
99

10+
#include <linux/cleanup.h>
1011
#include <linux/module.h>
1112
#include <linux/platform_device.h>
1213
#include <linux/types.h>
@@ -863,7 +864,14 @@ static int fsl_ifc_chip_init(struct fsl_ifc_mtd *priv)
863864

864865
/* Fill in fsl_ifc_mtd structure */
865866
mtd->dev.parent = priv->dev;
866-
nand_set_flash_node(chip, priv->dev->of_node);
867+
868+
struct device_node *np __free(device_node) =
869+
of_get_next_child_with_prefix(priv->dev->of_node, NULL, "nand");
870+
871+
if (np)
872+
nand_set_flash_node(chip, np);
873+
else
874+
nand_set_flash_node(chip, priv->dev->of_node);
867875

868876
/* fill in nand_chip structure */
869877
/* set up function call table */

0 commit comments

Comments
 (0)