mtd: do not use mtd->suspend and mtd->resume directly
Linux-MTD Mailing List
linux-mtd at lists.infradead.org
Mon Jan 9 13:59:17 EST 2012
Gitweb: http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=079c985e7a6f4ce60f931cebfdd5ee3c38347e31
Commit: 079c985e7a6f4ce60f931cebfdd5ee3c38347e31
Parent: 381345652fca688aeaa967c231e5075cf68d05b6
Author: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
AuthorDate: Fri Dec 30 17:15:59 2011 +0200
Committer: David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Mon Jan 9 18:26:23 2012 +0000
mtd: do not use mtd->suspend and mtd->resume directly
Just call the 'mtd_suspend()' and 'mtd_resume()' - they will do nothing
if the operation is not defined.
Signed-off-by: Artem Bityutskiy <artem.bityutskiy at linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
drivers/mtd/maps/physmap.c | 5 ++---
drivers/mtd/maps/rbtx4939-flash.c | 5 ++---
drivers/mtd/mtdcore.c | 5 +----
include/linux/mtd/mtd.h | 5 ++++-
4 files changed, 9 insertions(+), 11 deletions(-)
diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index d94cc62..abc5626 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -190,9 +190,8 @@ static void physmap_flash_shutdown(struct platform_device *dev)
int i;
for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
- if (info->mtd[i]->suspend && info->mtd[i]->resume)
- if (mtd_suspend(info->mtd[i]) == 0)
- mtd_resume(info->mtd[i]);
+ if (mtd_suspend(info->mtd[i]) == 0)
+ mtd_resume(info->mtd[i]);
}
#else
#define physmap_flash_shutdown NULL
diff --git a/drivers/mtd/maps/rbtx4939-flash.c b/drivers/mtd/maps/rbtx4939-flash.c
index 7176283..3da63fc 100644
--- a/drivers/mtd/maps/rbtx4939-flash.c
+++ b/drivers/mtd/maps/rbtx4939-flash.c
@@ -119,9 +119,8 @@ static void rbtx4939_flash_shutdown(struct platform_device *dev)
{
struct rbtx4939_flash_info *info = platform_get_drvdata(dev);
- if (info->mtd->suspend && info->mtd->resume)
- if (mtd_suspend(info->mtd) == 0)
- mtd_resume(info->mtd);
+ if (mtd_suspend(info->mtd) == 0)
+ mtd_resume(info->mtd);
}
#else
#define rbtx4939_flash_shutdown NULL
diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c
index 66494ee..6ae9ca0 100644
--- a/drivers/mtd/mtdcore.c
+++ b/drivers/mtd/mtdcore.c
@@ -119,10 +119,7 @@ static int mtd_cls_suspend(struct device *dev, pm_message_t state)
{
struct mtd_info *mtd = dev_get_drvdata(dev);
- if (mtd && mtd->suspend)
- return mtd_suspend(mtd);
- else
- return 0;
+ return mtd_suspend(mtd);
}
static int mtd_cls_resume(struct device *dev)
diff --git a/include/linux/mtd/mtd.h b/include/linux/mtd/mtd.h
index 6c91ba5..0893707 100644
--- a/include/linux/mtd/mtd.h
+++ b/include/linux/mtd/mtd.h
@@ -427,12 +427,15 @@ static inline int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)
static inline int mtd_suspend(struct mtd_info *mtd)
{
+ if (!mtd->suspend)
+ return -EOPNOTSUPP;
return mtd->suspend(mtd);
}
static inline void mtd_resume(struct mtd_info *mtd)
{
- mtd->resume(mtd);
+ if (mtd->resume)
+ mtd->resume(mtd);
}
static inline int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)
More information about the linux-mtd-cvs
mailing list