aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabio Estevam <fabio.estevam@nxp.com>2018-01-26 16:23:24 -0500
committerBoris Brezillon <boris.brezillon@bootlin.com>2018-03-30 04:04:53 -0400
commit6898b240f8a16be8323ec58ad1214dd3ed121592 (patch)
tree98041c35de69331748a3c7b322f18ac6018dbbfd
parent94bf11bddad836380ecced299f4d5cb7d17a7dd1 (diff)
mtd: fsl-quadspi: Distinguish the mtd device names
Currently on a imx6sx-sdb board, which has two SPI NOR chips connected to QSPI2 the following output from /proc/mtd is seen: dev: size erasesize name mtd0: 01000000 00010000 "21e4000.qspi" mtd1: 01000000 00010000 "21e4000.qspi" Attempts to partition them on the kernel command line result in both chips with identical (and identically named) partitions, which is an inconvenient behavior. Assign a different mtd->name for each mtd device to avoid this problem. After this change the output from /proc/mtd becomes: dev: size erasesize name mtd0: 01000000 00010000 "21e4000.qspi-0" mtd1: 01000000 00010000 "21e4000.qspi-1" In order to keep mtdparts compatibility keep the mtd->name unchanged when a single SPI NOR is present. Reported-by: David Wolfe <david.wolfe@nxp.com> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com> Acked-by: Han Xu <han.xu@nxp.com> Signed-off-by: Cyrille Pitchen <cyrille.pitchen@wedev4u.fr> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
-rw-r--r--drivers/mtd/spi-nor/fsl-quadspi.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c
index dc9914fce296..3e3c0bbc45c0 100644
--- a/drivers/mtd/spi-nor/fsl-quadspi.c
+++ b/drivers/mtd/spi-nor/fsl-quadspi.c
@@ -1051,6 +1051,24 @@ static int fsl_qspi_probe(struct platform_device *pdev)
1051 spi_nor_set_flash_node(nor, np); 1051 spi_nor_set_flash_node(nor, np);
1052 nor->priv = q; 1052 nor->priv = q;
1053 1053
1054 if (q->nor_num > 1 && !mtd->name) {
1055 int spiflash_idx;
1056
1057 ret = of_property_read_u32(np, "reg", &spiflash_idx);
1058 if (!ret) {
1059 mtd->name = devm_kasprintf(dev, GFP_KERNEL,
1060 "%s-%d",
1061 dev_name(dev),
1062 spiflash_idx);
1063 if (!mtd->name) {
1064 ret = -ENOMEM;
1065 goto mutex_failed;
1066 }
1067 } else {
1068 dev_warn(dev, "reg property is missing\n");
1069 }
1070 }
1071
1054 /* fill the hooks */ 1072 /* fill the hooks */
1055 nor->read_reg = fsl_qspi_read_reg; 1073 nor->read_reg = fsl_qspi_read_reg;
1056 nor->write_reg = fsl_qspi_write_reg; 1074 nor->write_reg = fsl_qspi_write_reg;