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>
此提交包含在:
@@ -308,18 +308,6 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
|
||||
return err;
|
||||
}
|
||||
|
||||
/**
|
||||
* erase_callback - MTD erasure call-back.
|
||||
* @ei: MTD erase information object.
|
||||
*
|
||||
* Note, even though MTD erase interface is asynchronous, all the current
|
||||
* implementations are synchronous anyway.
|
||||
*/
|
||||
static void erase_callback(struct erase_info *ei)
|
||||
{
|
||||
wake_up_interruptible((wait_queue_head_t *)ei->priv);
|
||||
}
|
||||
|
||||
/**
|
||||
* do_sync_erase - synchronously erase a physical eraseblock.
|
||||
* @ubi: UBI device description object
|
||||
@@ -333,7 +321,6 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum)
|
||||
{
|
||||
int err, retries = 0;
|
||||
struct erase_info ei;
|
||||
wait_queue_head_t wq;
|
||||
|
||||
dbg_io("erase PEB %d", pnum);
|
||||
ubi_assert(pnum >= 0 && pnum < ubi->peb_count);
|
||||
@@ -344,14 +331,11 @@ static int do_sync_erase(struct ubi_device *ubi, int pnum)
|
||||
}
|
||||
|
||||
retry:
|
||||
init_waitqueue_head(&wq);
|
||||
memset(&ei, 0, sizeof(struct erase_info));
|
||||
|
||||
ei.mtd = ubi->mtd;
|
||||
ei.addr = (loff_t)pnum * ubi->peb_size;
|
||||
ei.len = ubi->peb_size;
|
||||
ei.callback = erase_callback;
|
||||
ei.priv = (unsigned long)&wq;
|
||||
|
||||
err = mtd_erase(ubi->mtd, &ei);
|
||||
if (err) {
|
||||
@@ -366,25 +350,6 @@ retry:
|
||||
return err;
|
||||
}
|
||||
|
||||
err = wait_event_interruptible(wq, ei.state == MTD_ERASE_DONE ||
|
||||
ei.state == MTD_ERASE_FAILED);
|
||||
if (err) {
|
||||
ubi_err(ubi, "interrupted PEB %d erasure", pnum);
|
||||
return -EINTR;
|
||||
}
|
||||
|
||||
if (ei.state == MTD_ERASE_FAILED) {
|
||||
if (retries++ < UBI_IO_RETRIES) {
|
||||
ubi_warn(ubi, "error while erasing PEB %d, retry",
|
||||
pnum);
|
||||
yield();
|
||||
goto retry;
|
||||
}
|
||||
ubi_err(ubi, "cannot erase PEB %d", pnum);
|
||||
dump_stack();
|
||||
return -EIO;
|
||||
}
|
||||
|
||||
err = ubi_self_check_all_ff(ubi, pnum, 0, ubi->peb_size);
|
||||
if (err)
|
||||
return err;
|
||||
|
新增問題並參考
封鎖使用者