]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
[MTD] physmap: resume already suspended chips on failure to suspend
authorUwe Kleine-König <Uwe.Kleine-Koenig@digi.com>
Tue, 22 Jul 2008 07:39:01 +0000 (09:39 +0200)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Fri, 25 Jul 2008 13:53:26 +0000 (09:53 -0400)
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@digi.com>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
drivers/mtd/maps/physmap.c

index 7c8cdf49deb67f251a0adbacebbc4b992fbcdafe..42d844f8f6bfef79bdfef42ed48b33368ac4ecd0 100644 (file)
@@ -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;
 }