[MTD] physmap: resume already suspended chips on failure to suspend

Linux-MTD Mailing List linux-mtd at lists.infradead.org
Fri Jul 25 10:59:02 EDT 2008


Gitweb:     http://git.infradead.org/?p=mtd-2.6.git;a=commit;h=4b5e33a7bf185c8d8568a807d9805fb155bcedd9
Commit:     4b5e33a7bf185c8d8568a807d9805fb155bcedd9
Parent:     7b2491911540e4904498622fbee2e1a9e3120d2f
Author:     Uwe Kleine-König <Uwe.Kleine-Koenig at digi.com>
AuthorDate: Tue Jul 22 09:39:01 2008 +0200
Committer:  David Woodhouse <David.Woodhouse at intel.com>
CommitDate: Fri Jul 25 09:53:26 2008 -0400

    [MTD] physmap: resume already suspended chips on failure to suspend
    
    A nice side effect of this patch is that the return value of
    physmap_flash_suspend in the error path is the value of the first failing
    suspend callback and not the bitwise OR of all of them.
    
    Signed-off-by: Uwe Kleine-König <Uwe.Kleine-Koenig at digi.com>
    Signed-off-by: David Woodhouse <David.Woodhouse at intel.com>
---
 drivers/mtd/maps/physmap.c |   15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)

diff --git a/drivers/mtd/maps/physmap.c b/drivers/mtd/maps/physmap.c
index 7c8cdf4..42d844f 100644
--- a/drivers/mtd/maps/physmap.c
+++ b/drivers/mtd/maps/physmap.c
@@ -201,8 +201,19 @@ static int physmap_flash_suspend(struct platform_device *dev, pm_message_t state
 	int i;
 
 	for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
-		if (info->mtd[i]->suspend)
-			ret |= info->mtd[i]->suspend(info->mtd[i]);
+		if (info->mtd[i]->suspend) {
+			ret = info->mtd[i]->suspend(info->mtd[i]);
+			if (ret)
+				goto fail;
+		}
+
+	return 0;
+fail:
+	for (--i; i >= 0; --i)
+		if (info->mtd[i]->suspend) {
+			BUG_ON(!info->mtd[i]->resume);
+			info->mtd[i]->resume(info->mtd[i]);
+		}
 
 	return ret;
 }



More information about the linux-mtd-cvs mailing list