Skip to contentSkip to conversation

mtd: rawnand: rockchip_nfc: set mtd->dev instead of writing through NULL

PATCH New Yalçın Can 1 participant 1 message Oct 30

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mtd: rawnand: rockchip_nfc: set mtd->dev instead of writing through NULL

rk_nfc_nand_chip_init() does mtd->dev->parent = dev, taken from Linux, where the device is embedded in struct mtd_info. In U-Boot mtd->dev is a pointer and still NULL at this point, so this writes dev to address 0x18.

Harmless while address 0 is RAM; on the RK3066 started from the boot ROM it is the ROM, and the write ends in an asynchronous external abort.

Set mtd->dev to the controller device instead, as other raw NAND drivers do.

Tested on an MK808B (RK3066) from the NAND ID blocks (H27UCG8T2BTR).

---
 drivers/mtd/nand/raw/rockchip_nfc.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
drivers/mtd/nand/raw/rockchip_nfc.c +6 -1
index d23a651f..c134045d 100644
@@ -948,7 +948,12 @@ static int rk_nfc_nand_chip_init(ofnode node, struct rk_nfc *nfc, int devnum)
 
 	mtd = nand_to_mtd(chip);
 	mtd->owner = THIS_MODULE;
-	mtd->dev->parent = dev;
+	/*
+	 * mtd->dev is still NULL here: `mtd->dev->parent = dev` (from Linux, where dev is embedded)
+	 * wrote to address 0x18. Harmless only while 0 is RAM; on RK3066 started from the boot ROM
+	 * (soc_remap = 0) it is the ROM, and the write ends in an asynchronous external abort.
+	 */
+	mtd->dev = dev;
 
 	nand_set_controller_data(chip, nfc);
 
Signature · 1 line
2.47.3