Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Artem Bityutskiy and committed by
David Woodhouse
079c985e 38134565

+9 -11
+2 -3
drivers/mtd/maps/physmap.c
··· 190 190 int i; 191 191 192 192 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]); 196 195 } 197 196 #else 198 197 #define physmap_flash_shutdown NULL
+2 -3
drivers/mtd/maps/rbtx4939-flash.c
··· 119 119 { 120 120 struct rbtx4939_flash_info *info = platform_get_drvdata(dev); 121 121 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); 125 124 } 126 125 #else 127 126 #define rbtx4939_flash_shutdown NULL
+1 -4
drivers/mtd/mtdcore.c
··· 119 119 { 120 120 struct mtd_info *mtd = dev_get_drvdata(dev); 121 121 122 - if (mtd && mtd->suspend) 123 - return mtd_suspend(mtd); 124 - else 125 - return 0; 122 + return mtd_suspend(mtd); 126 123 } 127 124 128 125 static int mtd_cls_resume(struct device *dev)
+4 -1
include/linux/mtd/mtd.h
··· 427 427 428 428 static inline int mtd_suspend(struct mtd_info *mtd) 429 429 { 430 + if (!mtd->suspend) 431 + return -EOPNOTSUPP; 430 432 return mtd->suspend(mtd); 431 433 } 432 434 433 435 static inline void mtd_resume(struct mtd_info *mtd) 434 436 { 435 - mtd->resume(mtd); 437 + if (mtd->resume) 438 + mtd->resume(mtd); 436 439 } 437 440 438 441 static inline int mtd_block_isbad(struct mtd_info *mtd, loff_t ofs)