[PATCH v4] mtd: fsl-quadspi: Distinguish the mtd device names
Fabio Estevam
festevam at gmail.com
Sat Jan 13 11:40:51 PST 2018
Hi Boris,
On Thu, Jan 11, 2018 at 6:15 PM, Boris Brezillon
<boris.brezillon at free-electrons.com> wrote:
> Nothing that I really like, sorry. One solution would be to use
> dev_name(&pdev->dev) when only one flash device is declared and use
> dev_name(&pdev->dev)-reg_val otherwise. Or you could leave the logic
Ok, so I can do as you suggested above:
--- 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)
spi_nor_set_flash_node(nor, np);
nor->priv = q;
+ if (q->nor_num > 1) {
+ int spiflash_idx;
+
+ ret = of_property_read_u32(np, "reg", &spiflash_idx);
+ if (!ret) {
+ mtd->name = devm_kasprintf(dev, GFP_KERNEL,
+ "%s-%d",
+ dev_name(dev),
+ spiflash_idx);
+ if (!mtd->name) {
+ ret = -ENOMEM;
+ goto mutex_failed;
+ }
+ } else {
+ dev_warn(dev, "reg property is missing\n");
+ }
+ }
+
/* fill the hooks */
nor->read_reg = fsl_qspi_read_reg;
nor->write_reg = fsl_qspi_write_reg;
And then I can do a separate patch adding the qspi flash examples into
Documentation/devicetree/bindings/mtd/fsl-quadspi.txt
Does this look good?
More information about the linux-mtd
mailing list