Skip to content

Commit 4b5e33a

Browse files
Uwe Kleine-KönigDavid Woodhouse
authored andcommitted
[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@digi.com> Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
1 parent 7b24919 commit 4b5e33a

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎drivers/mtd/maps/physmap.c‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,19 @@ static int physmap_flash_suspend(struct platform_device *dev, pm_message_t state
201201
int i;
202202

203203
for (i = 0; i < MAX_RESOURCES && info->mtd[i]; i++)
204-
if (info->mtd[i]->suspend)
205-
ret |= info->mtd[i]->suspend(info->mtd[i]);
204+
if (info->mtd[i]->suspend) {
205+
ret = info->mtd[i]->suspend(info->mtd[i]);
206+
if (ret)
207+
goto fail;
208+
}
209+
210+
return 0;
211+
fail:
212+
for (--i; i >= 0; --i)
213+
if (info->mtd[i]->suspend) {
214+
BUG_ON(!info->mtd[i]->resume);
215+
info->mtd[i]->resume(info->mtd[i]);
216+
}
206217

207218
return ret;
208219
}

0 commit comments

Comments
 (0)