diff options
author | Boris Brezillon <boris.brezillon@bootlin.com> | 2018-02-12 22:03:09 +0100 |
---|---|---|
committer | Boris Brezillon <boris.brezillon@bootlin.com> | 2018-03-15 18:21:07 +0100 |
commit | 884cfd9023ce6afe8bcf181ec988d8516eb32bf0 (patch) | |
tree | f57f5eafe52a568ac90e25b64f8e6a0e9d37e993 /drivers/mtd/mtdconcat.c | |
parent | dcba51bbb9e0cc7f80d36eb20a033a4dff2ce9cc (diff) | |
download | lwn-884cfd9023ce6afe8bcf181ec988d8516eb32bf0.tar.gz lwn-884cfd9023ce6afe8bcf181ec988d8516eb32bf0.zip |
mtd: Stop assuming mtd_erase() is asynchronous
None of the mtd->_erase() implementations work in an asynchronous manner,
so let's simplify MTD users that call mtd_erase(). All they need to do
is check the value returned by mtd_erase() and assume that != 0 means
failure.
Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
Reviewed-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'drivers/mtd/mtdconcat.c')
-rw-r--r-- | drivers/mtd/mtdconcat.c | 48 |
1 files changed, 3 insertions, 45 deletions
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index 60bf53df5454..caa09bf6e572 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c @@ -333,45 +333,6 @@ concat_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops) return -EINVAL; } -static void concat_erase_callback(struct erase_info *instr) -{ - wake_up((wait_queue_head_t *) instr->priv); -} - -static int concat_dev_erase(struct mtd_info *mtd, struct erase_info *erase) -{ - int err; - wait_queue_head_t waitq; - DECLARE_WAITQUEUE(wait, current); - - /* - * This code was stol^H^H^H^Hinspired by mtdchar.c - */ - init_waitqueue_head(&waitq); - - erase->mtd = mtd; - erase->callback = concat_erase_callback; - erase->priv = (unsigned long) &waitq; - - /* - * FIXME: Allow INTERRUPTIBLE. Which means - * not having the wait_queue head on the stack. - */ - err = mtd_erase(mtd, erase); - if (!err) { - set_current_state(TASK_UNINTERRUPTIBLE); - add_wait_queue(&waitq, &wait); - if (erase->state != MTD_ERASE_DONE - && erase->state != MTD_ERASE_FAILED) - schedule(); - remove_wait_queue(&waitq, &wait); - set_current_state(TASK_RUNNING); - - err = (erase->state == MTD_ERASE_FAILED) ? -EIO : 0; - } - return err; -} - static int concat_erase(struct mtd_info *mtd, struct erase_info *instr) { struct mtd_concat *concat = CONCAT(mtd); @@ -466,7 +427,8 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr) erase->len = length; length -= erase->len; - if ((err = concat_dev_erase(subdev, erase))) { + erase->mtd = subdev; + if ((err = mtd_erase(subdev, erase))) { /* sanity check: should never happen since * block alignment has been checked above */ BUG_ON(err == -EINVAL); @@ -487,12 +449,8 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr) } instr->state = erase->state; kfree(erase); - if (err) - return err; - if (instr->callback) - instr->callback(instr); - return 0; + return err; } static int concat_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) |