diff options
author | Marek BehĂșn <marek.behun@nic.cz> | 2021-10-05 16:56:06 +0300 |
---|---|---|
committer | Jagan Teki <jagan@amarulasolutions.com> | 2021-10-23 13:17:33 +0300 |
commit | 0d1ecc99cb59c2190257f7738f91db21f174dc02 (patch) | |
tree | bd610819dcce9dd95ff9c8e43411c53986abbf31 /drivers/mtd | |
parent | a60397d219c2ddbceedfea4e121e303804d333d0 (diff) | |
download | u-boot-0d1ecc99cb59c2190257f7738f91db21f174dc02.tar.xz |
mtd: Remove mtd_erase_callback() entirely
The original purpose of mtd_erase_callback() in Linux at the time it was
imported to U-Boot, was to inform the caller that erasing is done (since
it was an asynchronous operation).
All supplied callback methods in U-Boot do nothing, but the
mtd_erase_callback() function was (until previous patch) grossly abused
in U-Boot's mtdpart implementation for completely different purpose.
Since we got rid of the abusement, remove the mtd_erase_callback()
function and the .callback member from struct erase_info entirely, in
order to avoid such problems in the future.
Signed-off-by: Marek BehĂșn <marek.behun@nic.cz>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/altera_qspi.c | 3 | ||||
-rw-r--r-- | drivers/mtd/cfi_mtd.c | 1 | ||||
-rw-r--r-- | drivers/mtd/mtdconcat.c | 11 | ||||
-rw-r--r-- | drivers/mtd/mtdcore.c | 8 | ||||
-rw-r--r-- | drivers/mtd/mtdpart.c | 21 | ||||
-rw-r--r-- | drivers/mtd/nand/raw/nand_base.c | 4 | ||||
-rw-r--r-- | drivers/mtd/onenand/onenand_base.c | 3 | ||||
-rw-r--r-- | drivers/mtd/spi/sf_mtd.c | 1 | ||||
-rw-r--r-- | drivers/mtd/spi/spi-nor-core.c | 5 | ||||
-rw-r--r-- | drivers/mtd/ubi/io.c | 13 |
10 files changed, 2 insertions, 68 deletions
diff --git a/drivers/mtd/altera_qspi.c b/drivers/mtd/altera_qspi.c index 7bac599a54..d31391f36a 100644 --- a/drivers/mtd/altera_qspi.c +++ b/drivers/mtd/altera_qspi.c @@ -153,7 +153,6 @@ static int altera_qspi_erase(struct mtd_info *mtd, struct erase_info *instr) putc('\n'); instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN; instr->state = MTD_ERASE_FAILED; - mtd_erase_callback(instr); return -EIO; } flash = pdata->base + addr; @@ -177,7 +176,6 @@ static int altera_qspi_erase(struct mtd_info *mtd, struct erase_info *instr) writel(stat, ®s->isr); /* clear isr */ instr->fail_addr = addr; instr->state = MTD_ERASE_FAILED; - mtd_erase_callback(instr); return -EIO; } if (flash_verbose) @@ -189,7 +187,6 @@ static int altera_qspi_erase(struct mtd_info *mtd, struct erase_info *instr) addr += mtd->erasesize; } instr->state = MTD_ERASE_DONE; - mtd_erase_callback(instr); return 0; } diff --git a/drivers/mtd/cfi_mtd.c b/drivers/mtd/cfi_mtd.c index 78293caa2f..2295bb7220 100644 --- a/drivers/mtd/cfi_mtd.c +++ b/drivers/mtd/cfi_mtd.c @@ -58,7 +58,6 @@ static int cfi_mtd_erase(struct mtd_info *mtd, struct erase_info *instr) } instr->state = MTD_ERASE_DONE; - mtd_erase_callback(instr); return 0; } diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index 684bc94998..af3c4765c4 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c @@ -338,14 +338,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) -{ - /* Nothing to do here in U-Boot */ -#ifndef __UBOOT__ - wake_up((wait_queue_head_t *) instr->priv); -#endif -} - static int concat_dev_erase(struct mtd_info *mtd, struct erase_info *erase) { int err; @@ -358,7 +350,6 @@ static int concat_dev_erase(struct mtd_info *mtd, struct erase_info *erase) init_waitqueue_head(&waitq); erase->mtd = mtd; - erase->callback = concat_erase_callback; erase->priv = (unsigned long) &waitq; /* @@ -498,8 +489,6 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr) if (err) return err; - if (instr->callback) - instr->callback(instr); return 0; } diff --git a/drivers/mtd/mtdcore.c b/drivers/mtd/mtdcore.c index 9496903e86..1d45fb55c7 100644 --- a/drivers/mtd/mtdcore.c +++ b/drivers/mtd/mtdcore.c @@ -906,13 +906,6 @@ void __put_mtd_device(struct mtd_info *mtd) } EXPORT_SYMBOL_GPL(__put_mtd_device); -/* - * Erase is an asynchronous operation. Device drivers are supposed - * to call instr->callback() whenever the operation completes, even - * if it completes with a failure. - * Callers are supposed to pass a callback function and wait for it - * to be called before writing to the block. - */ int mtd_erase(struct mtd_info *mtd, struct erase_info *instr) { if (instr->addr > mtd->size || instr->len > mtd->size - instr->addr) @@ -922,7 +915,6 @@ int mtd_erase(struct mtd_info *mtd, struct erase_info *instr) instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN; if (!instr->len) { instr->state = MTD_ERASE_DONE; - mtd_erase_callback(instr); return 0; } return mtd->_erase(mtd, instr); diff --git a/drivers/mtd/mtdpart.c b/drivers/mtd/mtdpart.c index 6ab481a7b1..a435ce6d07 100644 --- a/drivers/mtd/mtdpart.c +++ b/drivers/mtd/mtdpart.c @@ -456,27 +456,6 @@ static int part_erase(struct mtd_info *mtd, struct erase_info *instr) return ret; } -void mtd_erase_callback(struct erase_info *instr) -{ - if (!instr->callback) - return; - - if (instr->mtd->_erase == part_erase && instr->len) { - if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN) - instr->fail_addr -= instr->mtd->offset; - instr->addr -= instr->mtd->offset; - } - - instr->callback(instr); - - if (instr->mtd->_erase == part_erase && instr->len) { - if (instr->fail_addr != MTD_FAIL_ADDR_UNKNOWN) - instr->fail_addr += instr->mtd->offset; - instr->addr += instr->mtd->offset; - } -} -EXPORT_SYMBOL_GPL(mtd_erase_callback); - static int part_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len) { return mtd->parent->_lock(mtd->parent, ofs + mtd->offset, len); diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index b533683dfe..f7616985d9 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -3602,10 +3602,6 @@ erase_exit: chip->select_chip(mtd, -1); nand_release_device(mtd); - /* Do call back function */ - if (!ret) - mtd_erase_callback(instr); - /* Return more or less happy */ return ret; } diff --git a/drivers/mtd/onenand/onenand_base.c b/drivers/mtd/onenand/onenand_base.c index 46aeef258d..56e1858de4 100644 --- a/drivers/mtd/onenand/onenand_base.c +++ b/drivers/mtd/onenand/onenand_base.c @@ -1836,9 +1836,6 @@ int onenand_erase(struct mtd_info *mtd, struct erase_info *instr) erase_exit: ret = instr->state == MTD_ERASE_DONE ? 0 : -EIO; - /* Do call back function */ - if (!ret) - mtd_erase_callback(instr); /* Deselect and wake up anyone waiting on the device */ onenand_release_device(mtd); diff --git a/drivers/mtd/spi/sf_mtd.c b/drivers/mtd/spi/sf_mtd.c index 04de868080..0aed28a52b 100644 --- a/drivers/mtd/spi/sf_mtd.c +++ b/drivers/mtd/spi/sf_mtd.c @@ -46,7 +46,6 @@ static int spi_flash_mtd_erase(struct mtd_info *mtd, struct erase_info *instr) } instr->state = MTD_ERASE_DONE; - mtd_erase_callback(instr); return 0; } diff --git a/drivers/mtd/spi/spi-nor-core.c b/drivers/mtd/spi/spi-nor-core.c index a85759967b..4388a08a90 100644 --- a/drivers/mtd/spi/spi-nor-core.c +++ b/drivers/mtd/spi/spi-nor-core.c @@ -918,7 +918,7 @@ static int spi_nor_erase(struct mtd_info *mtd, struct erase_info *instr) div_u64_rem(instr->len, mtd->erasesize, &rem); if (rem) { ret = -EINVAL; - goto erase_err_callback; + goto err; } addr = instr->addr; @@ -966,14 +966,13 @@ erase_err: if (!ret) ret = err; -erase_err_callback: +err: if (ret) { instr->fail_addr = addr_known ? addr : MTD_FAIL_ADDR_UNKNOWN; instr->state = MTD_ERASE_FAILED; } else { instr->state = MTD_ERASE_DONE; } - mtd_erase_callback(instr); return ret; } diff --git a/drivers/mtd/ubi/io.c b/drivers/mtd/ubi/io.c index b8b878b918..14be95b74b 100644 --- a/drivers/mtd/ubi/io.c +++ b/drivers/mtd/ubi/io.c @@ -305,18 +305,6 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset, } /** - * 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 * @pnum: the physical eraseblock number to erase @@ -346,7 +334,6 @@ retry: 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); |