From 1f87ed122103806892141c02fac436d3a1672c12 Mon Sep 17 00:00:00 2001 From: Saeed Bishara Date: Tue, 28 Jul 2009 04:56:43 -0700 Subject: [PATCH] --- yaml --- r: 156443 b: refs/heads/master c: 6afc4fdb3e94ba60cd566cb878b60c6c01979277 h: refs/heads/master i: 156441: f318081c426ee60dfd0e7a5a10958536d16b6805 156439: 40c8ee428e7c78d030acb10b05132ac4f5789b0e v: v3 --- [refs] | 2 +- trunk/drivers/mtd/mtdcore.c | 7 ++++--- trunk/include/linux/mtd/mtd.h | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/[refs] b/[refs] index bc330df6cad7..d87cbbfec1ec 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 7699ad35ed06044c4fc1be162553880f98658616 +refs/heads/master: 6afc4fdb3e94ba60cd566cb878b60c6c01979277 diff --git a/trunk/drivers/mtd/mtdcore.c b/trunk/drivers/mtd/mtdcore.c index fac54a3fa3f1..00ebf7af7467 100644 --- a/trunk/drivers/mtd/mtdcore.c +++ b/trunk/drivers/mtd/mtdcore.c @@ -65,8 +65,8 @@ static void mtd_release(struct device *dev) static int mtd_cls_suspend(struct device *dev, pm_message_t state) { struct mtd_info *mtd = dev_to_mtd(dev); - - if (mtd->suspend) + + if (mtd && mtd->suspend) return mtd->suspend(mtd); else return 0; @@ -76,7 +76,7 @@ static int mtd_cls_resume(struct device *dev) { struct mtd_info *mtd = dev_to_mtd(dev); - if (mtd->resume) + if (mtd && mtd->resume) mtd->resume(mtd); return 0; } @@ -298,6 +298,7 @@ int add_mtd_device(struct mtd_info *mtd) mtd->dev.class = &mtd_class; mtd->dev.devt = MTD_DEVT(i); dev_set_name(&mtd->dev, "mtd%d", i); + dev_set_drvdata(&mtd->dev, mtd); if (device_register(&mtd->dev) != 0) { mtd_table[i] = NULL; break; diff --git a/trunk/include/linux/mtd/mtd.h b/trunk/include/linux/mtd/mtd.h index 5675b63a0631..0f32a9b6ff55 100644 --- a/trunk/include/linux/mtd/mtd.h +++ b/trunk/include/linux/mtd/mtd.h @@ -251,7 +251,7 @@ struct mtd_info { static inline struct mtd_info *dev_to_mtd(struct device *dev) { - return dev ? container_of(dev, struct mtd_info, dev) : NULL; + return dev ? dev_get_drvdata(dev) : NULL; } static inline uint32_t mtd_div_by_eb(uint64_t sz, struct mtd_info *mtd)