We maintain no global list of MTD masters, but it's a useful thing to
have if only for informational purposes. Add a struct class for this use
case.

Signed-off-by: Ahmad Fatoum <a.fat...@barebox.org>
---
 drivers/mtd/core.c      | 4 ++++
 include/linux/mtd/mtd.h | 2 ++
 2 files changed, 6 insertions(+)

diff --git a/drivers/mtd/core.c b/drivers/mtd/core.c
index 2ca16c614dee..6162ec450fc1 100644
--- a/drivers/mtd/core.c
+++ b/drivers/mtd/core.c
@@ -25,6 +25,8 @@
 
 static LIST_HEAD(mtd_register_hooks);
 
+DEFINE_DEV_CLASS(mtd_class, "mtd");
+
 /**
  * mtd_buf_all_ff - check if buffer contains only 0xff
  * @buf: buffer to check
@@ -681,6 +683,8 @@ int add_mtd_device(struct mtd_info *mtd, const char 
*devname, int device_id)
        if (ret)
                return ret;
 
+       class_add_device(&mtd_class, &mtd->dev);
+
        mtd->cdev.ops = &mtd_ops;
        mtd->cdev.size = mtd->size;
        if (device_id == DEVICE_ID_SINGLE)
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 8d99dff27fe7..f85c7e783243 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -339,6 +339,8 @@ static inline uint32_t mtd_div_by_wb(uint64_t sz, struct 
mtd_info *mtd)
 extern int add_mtd_device(struct mtd_info *mtd, const char *devname, int 
device_id);
 extern int del_mtd_device (struct mtd_info *mtd);
 
+extern struct class mtd_class;
+
 extern struct mtd_info *get_mtd_device(struct mtd_info *mtd, int num);
 extern struct mtd_info *get_mtd_device_nm(const char *name);
 
-- 
2.39.5


Reply via email to