[PATCH v5 2/2] mtd: spi-nor: enable the debugfs for the partname and partid

Zhuohao Lee zhuohao at chromium.org
Mon Jun 3 03:19:33 PDT 2019


On Mon, Jun 3, 2019 at 3:23 PM Boris Brezillon
<boris.brezillon at collabora.com> wrote:
>
> On Mon,  3 Jun 2019 11:14:51 +0800
> Zhuohao Lee <zhuohao at chromium.org> wrote:
>
> > This patch adds spi_nor_debugfs_init() for the debugfs initialization.
> > With this patch, we can read the partname and partid through the
> > debugfs.
> >
> > The output of new debugfs nodes on my device are:
> > cat /sys/kernel/debug/mtd/mtd0/partid
> > spi-nor:ef6017
> > cat /sys/kernel/debug/mtd/mtd0/partname
> > w25q64dw
> >
> > Signed-off-by: Zhuohao Lee <zhuohao at chromium.org>
> > ---
> >  drivers/mtd/spi-nor/spi-nor.c | 14 ++++++++++++++
> >  1 file changed, 14 insertions(+)
> >
> > diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c
> > index 6e13bbd1aaa5..acc1915b380b 100644
> > --- a/drivers/mtd/spi-nor/spi-nor.c
> > +++ b/drivers/mtd/spi-nor/spi-nor.c
> > @@ -3935,6 +3935,18 @@ static void spi_nor_resume(struct mtd_info *mtd)
> >               dev_err(dev, "resume() failed\n");
> >  }
> >
> > +static void spi_nor_debugfs_init(struct spi_nor *nor,
> > +             const struct flash_info *info)
> > +{
> > +     struct mtd_info *mtd = &nor->mtd;
> > +
> > +     mtd->dbg.partname = info->name;
> > +     if (!mtd->dbg.partid)
>
> Hm, how can this happen? I'd expect mtd->dbg.partid to always be NULL
> when you reach that point. If that's not the case there's probably a
> bug somewhere.
Yes, it is always NULL in my case.
Let me remove it in the next patch.

>
> > +             mtd->dbg.partid = devm_kasprintf(nor->dev, GFP_KERNEL,
> > +                                             "spi-nor:%*phN",
> > +                                              info->id_len, info->id);
> > +}
> > +
> >  void spi_nor_restore(struct spi_nor *nor)
> >  {
> >       /* restore the addressing mode */
> > @@ -4036,6 +4048,8 @@ int spi_nor_scan(struct spi_nor *nor, const char *name,
> >       mtd->_read = spi_nor_read;
> >       mtd->_resume = spi_nor_resume;
> >
> > +     spi_nor_debugfs_init(nor, info);
> > +
> >       /* NOR protection support for STmicro/Micron chips and similar */
> >       if (JEDEC_MFR(info) == SNOR_MFR_ST ||
> >           JEDEC_MFR(info) == SNOR_MFR_MICRON ||
>



More information about the linux-mtd mailing list