linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PM / MTD: Fix regressions related to mtd_suspend()
@ 2012-01-15 13:43 Rafael J. Wysocki
  2012-01-15 14:21 ` Artem Bityutskiy
  0 siblings, 1 reply; 8+ messages in thread
From: Rafael J. Wysocki @ 2012-01-15 13:43 UTC (permalink / raw)
  To: Linux PM list, David Woodhouse; +Cc: LKML, Artem Bityutskiy, linux-mtd

From: Rafael J. Wysocki <rjw@sisk.pl>

Commit 3fe4bae88460869a8e553397cd9057a4ee7ca341 (mtd: introduce
mtd_suspend interface) introduced the mtd_suspend() routine
which didn't check whether or not mtd and mtd->suspend were
both valid pointers.  Later commit 079c985e7a6f4ce60f931cebfdd5ee3c3
(mtd: do not use mtd->suspend and mtd->resume directly) added the
check for mtd->suspend, but still it failed to check mtd.  Moreover,
it caused mtd_suspend() to return an error code for NULL
mtd->suspend, which makes system suspend fail on one of my test
systems on every attempt and which is a regression from v3.2.

Fix mtd_suspend() by making it check if mtd is not NULL and
return 0 if mtd or mtd->suspend is NULL, which shouldn't prevent
the system from suspending.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
---
 include/linux/mtd/mtd.h |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Index: linux/include/linux/mtd/mtd.h
===================================================================
--- linux.orig/include/linux/mtd/mtd.h
+++ linux/include/linux/mtd/mtd.h
@@ -427,9 +427,7 @@ static inline int mtd_is_locked(struct m
 
 static inline int mtd_suspend(struct mtd_info *mtd)
 {
-	if (!mtd->suspend)
-		return -EOPNOTSUPP;
-	return mtd->suspend(mtd);
+	return mtd && mtd->suspend ? mtd->suspend(mtd) : 0;
 }
 
 static inline void mtd_resume(struct mtd_info *mtd)

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2012-01-27 22:47 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-15 13:43 [PATCH] PM / MTD: Fix regressions related to mtd_suspend() Rafael J. Wysocki
2012-01-15 14:21 ` Artem Bityutskiy
2012-01-15 23:18   ` Rafael J. Wysocki
2012-01-16  9:17     ` Artem Bityutskiy
2012-01-16  9:23       ` Oliver Neukum
2012-01-16  9:26         ` Artem Bityutskiy
2012-01-16 20:59       ` Rafael J. Wysocki
2012-01-27 22:51       ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).