From: Boris Brezillon <boris.brezillon@free-electrons.com>
To: Fabio Estevam <fabio.estevam@nxp.com>
Cc: <cyrille.pitchen@wedev4u.fr>, <linux-mtd@lists.infradead.org>,
<david.wolfe@nxp.com>, <han.xu@nxp.com>, <frank.li@nxp.com>
Subject: Re: [PATCH v4] mtd: fsl-quadspi: Distinguish the mtd device names
Date: Thu, 11 Jan 2018 16:48:23 +0100 [thread overview]
Message-ID: <20180111164823.34b0b8fd@bbrezillon> (raw)
In-Reply-To: <1515685478-31457-1-git-send-email-fabio.estevam@nxp.com>
On Thu, 11 Jan 2018 13:44:38 -0200
Fabio Estevam <fabio.estevam@nxp.com> wrote:
> Currently on a imx6sx-sdb board, which has two SPI NOR chips connected
> to QSPI2 the following output from /proc/mtd is seen:
>
> # cat /proc/mtd
> 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:
>
> # cat /proc/mtd
> dev: size erasesize name
> mtd0: 01000000 00010000 "21e4000.qspi-0"
> mtd1: 01000000 00010000 "21e4000.qspi-1"
>
> Reported-by: David Wolfe <david.wolfe@nxp.com>
> Signed-off-by: Fabio Estevam <fabio.estevam@nxp.com>
> ---
> Changes since v1:
> - Do not fail probe when reg is not present
>
> drivers/mtd/spi-nor/fsl-quadspi.c | 20 +++++++++++++++++++-
Still missing the DT doc update. You can do it in a separate patch, but
please make it part of the same series.
> 1 file changed, 19 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/mtd/spi-nor/fsl-quadspi.c b/drivers/mtd/spi-nor/fsl-quadspi.c
> index 2901c7b..8020295 100644
> --- a/drivers/mtd/spi-nor/fsl-quadspi.c
> +++ b/drivers/mtd/spi-nor/fsl-quadspi.c
> @@ -967,7 +967,7 @@ static int fsl_qspi_probe(struct platform_device *pdev)
> struct resource *res;
> struct spi_nor *nor;
> struct mtd_info *mtd;
> - int ret, i = 0;
> + int ret, i = 0, spiflash_idx;
>
> q = devm_kzalloc(dev, sizeof(*q), GFP_KERNEL);
> if (!q)
> @@ -1051,6 +1051,24 @@ static int fsl_qspi_probe(struct platform_device *pdev)
> spi_nor_set_flash_node(nor, np);
> nor->priv = q;
>
> + if (!mtd->name) {
Move the spiflash_idx declaration here.
> + 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);
> + } else {
> + mtd->name = dev_name(dev);
> + dev_warn(dev, "reg property is missing\n");
> + }
> +
> + if (!mtd->name) {
> + ret = -ENOMEM;
> + goto mutex_failed;
> + }
> + }
> +
> /* fill the hooks */
> nor->read_reg = fsl_qspi_read_reg;
> nor->write_reg = fsl_qspi_write_reg;
next prev parent reply other threads:[~2018-01-11 15:48 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-11 15:44 [PATCH v4] mtd: fsl-quadspi: Distinguish the mtd device names Fabio Estevam
2018-01-11 15:48 ` Boris Brezillon [this message]
2018-01-11 15:59 ` Fabio Estevam
2018-01-11 16:40 ` Boris Brezillon
2018-01-11 16:58 ` Fabio Estevam
2018-01-11 20:15 ` Boris Brezillon
2018-01-13 19:40 ` Fabio Estevam
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180111164823.34b0b8fd@bbrezillon \
--to=boris.brezillon@free-electrons.com \
--cc=cyrille.pitchen@wedev4u.fr \
--cc=david.wolfe@nxp.com \
--cc=fabio.estevam@nxp.com \
--cc=frank.li@nxp.com \
--cc=han.xu@nxp.com \
--cc=linux-mtd@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox