From: Zhuohao Lee Date: Wed, 28 Aug 2019 06:08:02 +0000 (+0300) Subject: mtd: spi-nor: enable the debugfs for the partname and partid X-Git-Tag: v5.4-rc1~87^2~12^2~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=dcc935b06f1f29aa9f93008df3d13ab84ab0bbbb;p=platform%2Fkernel%2Flinux-rpi.git mtd: spi-nor: enable the debugfs for the partname and partid 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 Reviewed-by: Boris Brezillon Signed-off-by: Tudor Ambarus --- diff --git a/drivers/mtd/spi-nor/spi-nor.c b/drivers/mtd/spi-nor/spi-nor.c index 79c8f1d..6a2fff0 100644 --- a/drivers/mtd/spi-nor/spi-nor.c +++ b/drivers/mtd/spi-nor/spi-nor.c @@ -4767,6 +4767,16 @@ static int spi_nor_set_addr_width(struct spi_nor *nor) return 0; } +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; + mtd->dbg.partid = devm_kasprintf(nor->dev, GFP_KERNEL, "spi-nor:%*phN", + info->id_len, info->id); +} + static const struct flash_info *spi_nor_get_flash_info(struct spi_nor *nor, const char *name) { @@ -4847,6 +4857,8 @@ int spi_nor_scan(struct spi_nor *nor, const char *name, nor->info = info; + spi_nor_debugfs_init(nor, info); + mutex_init(&nor->lock); /*