diff options
-rw-r--r-- | drivers/mtd/mtdcore.c | 7 | ||||
-rw-r--r-- | include/linux/mtd/mtd.h | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index fac54a3fa3f1..00ebf7af7467 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c | |||
@@ -65,8 +65,8 @@ static void mtd_release(struct device *dev) | |||
65 | static int mtd_cls_suspend(struct device *dev, pm_message_t state) | 65 | static int mtd_cls_suspend(struct device *dev, pm_message_t state) |
66 | { | 66 | { |
67 | struct mtd_info *mtd = dev_to_mtd(dev); | 67 | struct mtd_info *mtd = dev_to_mtd(dev); |
68 | 68 | ||
69 | if (mtd->suspend) | 69 | if (mtd && mtd->suspend) |
70 | return mtd->suspend(mtd); | 70 | return mtd->suspend(mtd); |
71 | else | 71 | else |
72 | return 0; | 72 | return 0; |
@@ -76,7 +76,7 @@ static int mtd_cls_resume(struct device *dev) | |||
76 | { | 76 | { |
77 | struct mtd_info *mtd = dev_to_mtd(dev); | 77 | struct mtd_info *mtd = dev_to_mtd(dev); |
78 | 78 | ||
79 | if (mtd->resume) | 79 | if (mtd && mtd->resume) |
80 | mtd->resume(mtd); | 80 | mtd->resume(mtd); |
81 | return 0; | 81 | return 0; |
82 | } | 82 | } |
@@ -298,6 +298,7 @@ int add_mtd_device(struct mtd_info *mtd) | |||
298 | mtd->dev.class = &mtd_class; | 298 | mtd->dev.class = &mtd_class; |
299 | mtd->dev.devt = MTD_DEVT(i); | 299 | mtd->dev.devt = MTD_DEVT(i); |
300 | dev_set_name(&mtd->dev, "mtd%d", i); | 300 | dev_set_name(&mtd->dev, "mtd%d", i); |
301 | dev_set_drvdata(&mtd->dev, mtd); | ||
301 | if (device_register(&mtd->dev) != 0) { | 302 | if (device_register(&mtd->dev) != 0) { |
302 | mtd_table[i] = NULL; | 303 | mtd_table[i] = NULL; |
303 | break; | 304 | break; |
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h index 5675b63a0631..0f32a9b6ff55 100644 --- a/include/linux/mtd/mtd.h +++ b/include/linux/mtd/mtd.h | |||
@@ -251,7 +251,7 @@ struct mtd_info { | |||
251 | 251 | ||
252 | static inline struct mtd_info *dev_to_mtd(struct device *dev) | 252 | static inline struct mtd_info *dev_to_mtd(struct device *dev) |
253 | { | 253 | { |
254 | return dev ? container_of(dev, struct mtd_info, dev) : NULL; | 254 | return dev ? dev_get_drvdata(dev) : NULL; |
255 | } | 255 | } |
256 | 256 | ||
257 | static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd) | 257 | static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd) |