[PATCH 04/16] mtd: Introduce function to get mtd type string
Sascha Hauer
s.hauer at pengutronix.de
Tue Mar 15 04:15:22 PDT 2016
Signed-off-by: Sascha Hauer <s.hauer at pengutronix.de>
---
drivers/mtd/core.c | 22 ++++++++++++++++++++++
include/linux/mtd/mtd.h | 1 +
2 files changed, 23 insertions(+)
diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 3143b07..0a3f7ed 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -733,3 +733,25 @@ void mtdcore_add_hook(struct mtddev_hook *hook)
{
list_add(&hook->hook, &mtd_register_hooks);
}
+
+const char *mtd_type_str(struct mtd_info *mtd)
+{
+ switch (mtd->type) {
+ case MTD_ABSENT:
+ return "absent";
+ case MTD_RAM:
+ return "ram";
+ case MTD_ROM:
+ return "rom";
+ case MTD_NORFLASH:
+ return "nor";
+ case MTD_NANDFLASH:
+ return "nand";
+ case MTD_DATAFLASH:
+ return"dataflash";
+ case MTD_UBIVOLUME:
+ return "ubi";
+ default:
+ return "unknown";
+ }
+}
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index efb08b1..98dd82c 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -281,6 +281,7 @@ extern struct mtd_info *get_mtd_device_nm(const char *name);
extern void put_mtd_device(struct mtd_info *mtd);
+const char *mtd_type_str(struct mtd_info *mtd);
struct mtd_notifier {
void (*add)(struct mtd_info *mtd);
--
2.7.0
More information about the barebox
mailing list