Skip to content

Commit

Permalink
mtd: do not use mtd->suspend and mtd->resume directly
Browse files Browse the repository at this point in the history
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@linux.intel.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
  • Loading branch information
Artem Bityutskiy authored and David Woodhouse committed Jan 9, 2012
1 parent 3813456 commit 079c985
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 11 deletions.
5 changes: 2 additions & 3 deletions drivers/mtd/maps/physmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 2 additions & 3 deletions drivers/mtd/maps/rbtx4939-flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 1 addition & 4 deletions drivers/mtd/mtdcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
5 changes: 4 additions & 1 deletion include/linux/mtd/mtd.h
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 079c985

Please sign in to comment.