Skip to content

Commit 079c985

Browse files
dedekindDavid Woodhouse
authored andcommitted
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@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent 3813456 commit 079c985

4 files changed

Lines changed: 9 additions & 11 deletions

File tree

‎drivers/mtd/maps/physmap.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,8 @@ static void physmap_flash_shutdown(struct platform_device *dev)
190190
int i;
191191

192192
for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
193-
if (info->mtd[i]->suspend && info->mtd[i]->resume)
194-
if (mtd_suspend(info->mtd[i]) == 0)
195-
mtd_resume(info->mtd[i]);
193+
if (mtd_suspend(info->mtd[i]) == 0)
194+
mtd_resume(info->mtd[i]);
196195
}
197196
#else
198197
#define physmap_flash_shutdown NULL

‎drivers/mtd/maps/rbtx4939-flash.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,8 @@ static void rbtx4939_flash_shutdown(struct platform_device *dev)
119119
{
120120
struct rbtx4939_flash_info *info = platform_get_drvdata(dev);
121121

122-
if (info->mtd->suspend && info->mtd->resume)
123-
if (mtd_suspend(info->mtd) == 0)
124-
mtd_resume(info->mtd);
122+
if (mtd_suspend(info->mtd) == 0)
123+
mtd_resume(info->mtd);
125124
}
126125
#else
127126
#define rbtx4939_flash_shutdown NULL

‎drivers/mtd/mtdcore.c‎

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,10 +119,7 @@ static int mtd_cls_suspend(struct device *dev, pm_message_t state)
119119
{
120120
struct mtd_info *mtd = dev_get_drvdata(dev);
121121

122-
if (mtd && mtd->suspend)
123-
return mtd_suspend(mtd);
124-
else
125-
return 0;
122+
return mtd_suspend(mtd);
126123
}
127124

128125
static int mtd_cls_resume(struct device *dev)

‎include/linux/mtd/mtd.h‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,12 +427,15 @@ static inline int mtd_is_locked(struct mtd_info *mtd, loff_t ofs, uint64_t len)
427427

428428
static inline int mtd_suspend(struct mtd_info *mtd)
429429
{
430+
if (!mtd->suspend)
431+
return -EOPNOTSUPP;
430432
return mtd->suspend(mtd);
431433
}
432434

433435
static inline void mtd_resume(struct mtd_info *mtd)
434436
{
435-
mtd->resume(mtd);
437+
if (mtd->resume)
438+
mtd->resume(mtd);
436439
}
437440

438441
static inline int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)

0 commit comments

Comments
 (0)