Skip to content

Commit 3a6e21e

Browse files
nxpfranklimiquelraynal
authored andcommitted
mtd: rawnand: gpmi: 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 520886a commit 3a6e21e

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

drivers/mtd/nand/raw/gpmi-nand/gpmi-nand.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
* Copyright (C) 2010-2015 Freescale Semiconductor, Inc.
66
* Copyright (C) 2008 Embedded Alley Solutions, Inc.
77
*/
8+
#include <linux/cleanup.h>
89
#include <linux/clk.h>
910
#include <linux/delay.h>
1011
#include <linux/slab.h>
@@ -2688,7 +2689,15 @@ static int gpmi_nand_init(struct gpmi_nand_data *this)
26882689

26892690
/* init the nand_chip{}, we don't support a 16-bit NAND Flash bus. */
26902691
nand_set_controller_data(chip, this);
2691-
nand_set_flash_node(chip, this->pdev->dev.of_node);
2692+
2693+
struct device_node *np __free(device_node) =
2694+
of_get_next_child_with_prefix(this->pdev->dev.of_node, NULL, "nand");
2695+
2696+
if (np)
2697+
nand_set_flash_node(chip, np);
2698+
else
2699+
nand_set_flash_node(chip, this->pdev->dev.of_node);
2700+
26922701
chip->legacy.block_markbad = gpmi_block_markbad;
26932702
chip->badblock_pattern = &gpmi_bbt_descr;
26942703
chip->options |= NAND_NO_SUBPAGE_WRITE;

0 commit comments

Comments
 (0)