mtd: fix MTD suspend
Commits3fe4bae884
and079c985e7a
broke MTD suspend in 2 ways: 1. When the '->suspend' method is not present, we return -EOPNOTSUPP, but the callers of 'mtd_suspend()' expects 0 instead. 2. Checking of the 'mtd' parameter against NULL has been incorrectly removed in 'mtd_cls_suspend()'. This patch fixes the breakages. This has been found, analyzed, reported and tested by Rafael J. Wysocki <rjw@sisk.pl>. Note, this patch is not needed in the stable tree because it causes a regression introduced during the v3.3 merge window. Reported-by: Rafael J. Wysocki <rjw@sisk.pl> Tested-by: Rafael J. Wysocki <rjw@sisk.pl> Tested-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
This commit is contained in:
parent
bce41d601e
commit
1a30871fe6
@ -119,7 +119,7 @@ static int mtd_cls_suspend(struct device *dev, pm_message_t state)
|
|||||||
{
|
{
|
||||||
struct mtd_info *mtd = dev_get_drvdata(dev);
|
struct mtd_info *mtd = dev_get_drvdata(dev);
|
||||||
|
|
||||||
return mtd_suspend(mtd);
|
return mtd ? mtd_suspend(mtd) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mtd_cls_resume(struct device *dev)
|
static int mtd_cls_resume(struct device *dev)
|
||||||
|
@ -427,9 +427,7 @@ 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)
|
static inline int mtd_suspend(struct mtd_info *mtd)
|
||||||
{
|
{
|
||||||
if (!mtd->suspend)
|
return mtd->suspend ? mtd->suspend(mtd) : 0;
|
||||||
return -EOPNOTSUPP;
|
|
||||||
return mtd->suspend(mtd);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void mtd_resume(struct mtd_info *mtd)
|
static inline void mtd_resume(struct mtd_info *mtd)
|
||||||
|
Loading…
Reference in New Issue
Block a user