Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mtd: nand: omap2: Fix partition creation via cmdline mtdparts

commit c9711ec5250b ("mtd: nand: omap: Clean up device tree support")
caused the parent device name to be changed from "omap2-nand.0"
to "<base address>.nand" (e.g. 30000000.nand on omap3 platforms).
This caused mtd->name to be changed as well. This breaks partition
creation via mtdparts passed by u-boot as it uses "omap2-nand.0"
for the mtd-id.

Fix this by explicitly setting the mtd->name to "omap2-nand.<CS number>"
if it isn't already set by nand_set_flash_node(). CS number is the
NAND controller instance ID.

Fixes: c9711ec5250b ("mtd: nand: omap: Clean up device tree support")
Cc: <stable@vger.kernel.org> # 4.7+
Reported-by: Leto Enrico <enrico.leto@siemens.com>
Reported-by: Adam Ford <aford173@gmail.com>
Suggested-by: Boris Brezillon <boris.brezillon@free-electrons.com>
Tested-by: Adam Ford <aford173@gmail.com>
Signed-off-by: Roger Quadros <rogerq@ti.com>
Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>

authored by

Roger Quadros and committed by
Boris Brezillon
2d283ede 038e8ad6

+9
+9
drivers/mtd/nand/omap2.c
··· 1856 1856 nand_chip->ecc.priv = NULL; 1857 1857 nand_set_flash_node(nand_chip, dev->of_node); 1858 1858 1859 + if (!mtd->name) { 1860 + mtd->name = devm_kasprintf(&pdev->dev, GFP_KERNEL, 1861 + "omap2-nand.%d", info->gpmc_cs); 1862 + if (!mtd->name) { 1863 + dev_err(&pdev->dev, "Failed to set MTD name\n"); 1864 + return -ENOMEM; 1865 + } 1866 + } 1867 + 1859 1868 res = platform_get_resource(pdev, IORESOURCE_MEM, 0); 1860 1869 nand_chip->IO_ADDR_R = devm_ioremap_resource(&pdev->dev, res); 1861 1870 if (IS_ERR(nand_chip->IO_ADDR_R))