Skip to content

Commit

Permalink
mtd: powernv_flash: Don't return -ERESTARTSYS on interrupted token ac…
Browse files Browse the repository at this point in the history
…quisition

Because the MTD core might split up a read() or write() from userspace
into several calls to the driver, we may fail to get a token but already
have done some work, best to return -EINTR back to userspace and have
them decide what to do.

Signed-off-by: Cyril Bur <[email protected]>
Acked-by: Boris Brezillon <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
  • Loading branch information
cyrilbur-ibm authored and mpe committed Nov 6, 2017
1 parent e32ec15 commit efe6941
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions drivers/mtd/devices/powernv_flash.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ enum flash_op {
FLASH_OP_ERASE,
};

/*
* Don't return -ERESTARTSYS if we can't get a token, the MTD core
* might have split up the call from userspace and called into the
* driver more than once, we'll already have done some amount of work.
*/
static int powernv_flash_async_op(struct mtd_info *mtd, enum flash_op op,
loff_t offset, size_t len, size_t *retlen, u_char *buf)
{
Expand All @@ -63,6 +68,8 @@ static int powernv_flash_async_op(struct mtd_info *mtd, enum flash_op op,
if (token < 0) {
if (token != -ERESTARTSYS)
dev_err(dev, "Failed to get an async token\n");
else
token = -EINTR;
return token;
}

Expand Down

0 comments on commit efe6941

Please sign in to comment.