mirror of
https://github.com/AsahiLinux/u-boot
synced 2024-11-10 15:14:43 +00:00
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>
This commit is contained in:
parent
a60397d219
commit
0d1ecc99cb
15 changed files with 5 additions and 91 deletions
|
@ -186,9 +186,7 @@ next:
|
||||||
static int onenand_block_erase(u32 start, u32 size, int force)
|
static int onenand_block_erase(u32 start, u32 size, int force)
|
||||||
{
|
{
|
||||||
struct onenand_chip *this = mtd->priv;
|
struct onenand_chip *this = mtd->priv;
|
||||||
struct erase_info instr = {
|
struct erase_info instr = {};
|
||||||
.callback = NULL,
|
|
||||||
};
|
|
||||||
loff_t ofs;
|
loff_t ofs;
|
||||||
int ret;
|
int ret;
|
||||||
int blocksize = 1 << this->erase_shift;
|
int blocksize = 1 << this->erase_shift;
|
||||||
|
@ -219,10 +217,7 @@ static int onenand_block_erase(u32 start, u32 size, int force)
|
||||||
static int onenand_block_test(u32 start, u32 size)
|
static int onenand_block_test(u32 start, u32 size)
|
||||||
{
|
{
|
||||||
struct onenand_chip *this = mtd->priv;
|
struct onenand_chip *this = mtd->priv;
|
||||||
struct erase_info instr = {
|
struct erase_info instr = {};
|
||||||
.callback = NULL,
|
|
||||||
.priv = 0,
|
|
||||||
};
|
|
||||||
|
|
||||||
int blocks;
|
int blocks;
|
||||||
loff_t ofs;
|
loff_t ofs;
|
||||||
|
|
|
@ -153,7 +153,6 @@ static int altera_qspi_erase(struct mtd_info *mtd, struct erase_info *instr)
|
||||||
putc('\n');
|
putc('\n');
|
||||||
instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
|
instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
|
||||||
instr->state = MTD_ERASE_FAILED;
|
instr->state = MTD_ERASE_FAILED;
|
||||||
mtd_erase_callback(instr);
|
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
flash = pdata->base + addr;
|
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 */
|
writel(stat, ®s->isr); /* clear isr */
|
||||||
instr->fail_addr = addr;
|
instr->fail_addr = addr;
|
||||||
instr->state = MTD_ERASE_FAILED;
|
instr->state = MTD_ERASE_FAILED;
|
||||||
mtd_erase_callback(instr);
|
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
if (flash_verbose)
|
if (flash_verbose)
|
||||||
|
@ -189,7 +187,6 @@ static int altera_qspi_erase(struct mtd_info *mtd, struct erase_info *instr)
|
||||||
addr += mtd->erasesize;
|
addr += mtd->erasesize;
|
||||||
}
|
}
|
||||||
instr->state = MTD_ERASE_DONE;
|
instr->state = MTD_ERASE_DONE;
|
||||||
mtd_erase_callback(instr);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -58,7 +58,6 @@ static int cfi_mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
|
||||||
}
|
}
|
||||||
|
|
||||||
instr->state = MTD_ERASE_DONE;
|
instr->state = MTD_ERASE_DONE;
|
||||||
mtd_erase_callback(instr);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -338,14 +338,6 @@ concat_write_oob(struct mtd_info *mtd, loff_t to, struct mtd_oob_ops *ops)
|
||||||
return -EINVAL;
|
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)
|
static int concat_dev_erase(struct mtd_info *mtd, struct erase_info *erase)
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
@ -358,7 +350,6 @@ static int concat_dev_erase(struct mtd_info *mtd, struct erase_info *erase)
|
||||||
init_waitqueue_head(&waitq);
|
init_waitqueue_head(&waitq);
|
||||||
|
|
||||||
erase->mtd = mtd;
|
erase->mtd = mtd;
|
||||||
erase->callback = concat_erase_callback;
|
|
||||||
erase->priv = (unsigned long) &waitq;
|
erase->priv = (unsigned long) &waitq;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -498,8 +489,6 @@ static int concat_erase(struct mtd_info *mtd, struct erase_info *instr)
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (instr->callback)
|
|
||||||
instr->callback(instr);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -906,13 +906,6 @@ void __put_mtd_device(struct mtd_info *mtd)
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(__put_mtd_device);
|
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)
|
int mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
|
||||||
{
|
{
|
||||||
if (instr->addr > mtd->size || instr->len > mtd->size - instr->addr)
|
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;
|
instr->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
|
||||||
if (!instr->len) {
|
if (!instr->len) {
|
||||||
instr->state = MTD_ERASE_DONE;
|
instr->state = MTD_ERASE_DONE;
|
||||||
mtd_erase_callback(instr);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return mtd->_erase(mtd, instr);
|
return mtd->_erase(mtd, instr);
|
||||||
|
|
|
@ -456,27 +456,6 @@ static int part_erase(struct mtd_info *mtd, struct erase_info *instr)
|
||||||
return ret;
|
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)
|
static int part_lock(struct mtd_info *mtd, loff_t ofs, uint64_t len)
|
||||||
{
|
{
|
||||||
return mtd->parent->_lock(mtd->parent, ofs + mtd->offset, len);
|
return mtd->parent->_lock(mtd->parent, ofs + mtd->offset, len);
|
||||||
|
|
|
@ -3602,10 +3602,6 @@ erase_exit:
|
||||||
chip->select_chip(mtd, -1);
|
chip->select_chip(mtd, -1);
|
||||||
nand_release_device(mtd);
|
nand_release_device(mtd);
|
||||||
|
|
||||||
/* Do call back function */
|
|
||||||
if (!ret)
|
|
||||||
mtd_erase_callback(instr);
|
|
||||||
|
|
||||||
/* Return more or less happy */
|
/* Return more or less happy */
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1836,9 +1836,6 @@ int onenand_erase(struct mtd_info *mtd, struct erase_info *instr)
|
||||||
erase_exit:
|
erase_exit:
|
||||||
|
|
||||||
ret = instr->state == MTD_ERASE_DONE ? 0 : -EIO;
|
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 */
|
/* Deselect and wake up anyone waiting on the device */
|
||||||
onenand_release_device(mtd);
|
onenand_release_device(mtd);
|
||||||
|
|
|
@ -46,7 +46,6 @@ static int spi_flash_mtd_erase(struct mtd_info *mtd, struct erase_info *instr)
|
||||||
}
|
}
|
||||||
|
|
||||||
instr->state = MTD_ERASE_DONE;
|
instr->state = MTD_ERASE_DONE;
|
||||||
mtd_erase_callback(instr);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
div_u64_rem(instr->len, mtd->erasesize, &rem);
|
||||||
if (rem) {
|
if (rem) {
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
goto erase_err_callback;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
addr = instr->addr;
|
addr = instr->addr;
|
||||||
|
@ -966,14 +966,13 @@ erase_err:
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret = err;
|
ret = err;
|
||||||
|
|
||||||
erase_err_callback:
|
err:
|
||||||
if (ret) {
|
if (ret) {
|
||||||
instr->fail_addr = addr_known ? addr : MTD_FAIL_ADDR_UNKNOWN;
|
instr->fail_addr = addr_known ? addr : MTD_FAIL_ADDR_UNKNOWN;
|
||||||
instr->state = MTD_ERASE_FAILED;
|
instr->state = MTD_ERASE_FAILED;
|
||||||
} else {
|
} else {
|
||||||
instr->state = MTD_ERASE_DONE;
|
instr->state = MTD_ERASE_DONE;
|
||||||
}
|
}
|
||||||
mtd_erase_callback(instr);
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
|
@ -304,18 +304,6 @@ int ubi_io_write(struct ubi_device *ubi, const void *buf, int pnum, int offset,
|
||||||
return err;
|
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.
|
* do_sync_erase - synchronously erase a physical eraseblock.
|
||||||
* @ubi: UBI device description object
|
* @ubi: UBI device description object
|
||||||
|
@ -346,7 +334,6 @@ retry:
|
||||||
ei.mtd = ubi->mtd;
|
ei.mtd = ubi->mtd;
|
||||||
ei.addr = (loff_t)pnum * ubi->peb_size;
|
ei.addr = (loff_t)pnum * ubi->peb_size;
|
||||||
ei.len = ubi->peb_size;
|
ei.len = ubi->peb_size;
|
||||||
ei.callback = erase_callback;
|
|
||||||
ei.priv = (unsigned long)&wq;
|
ei.priv = (unsigned long)&wq;
|
||||||
|
|
||||||
err = mtd_erase(ubi->mtd, &ei);
|
err = mtd_erase(ubi->mtd, &ei);
|
||||||
|
|
4
env/onenand.c
vendored
4
env/onenand.c
vendored
|
@ -73,9 +73,7 @@ static int env_onenand_save(void)
|
||||||
#endif
|
#endif
|
||||||
loff_t env_addr = CONFIG_ENV_ADDR;
|
loff_t env_addr = CONFIG_ENV_ADDR;
|
||||||
size_t retlen;
|
size_t retlen;
|
||||||
struct erase_info instr = {
|
struct erase_info instr = {};
|
||||||
.callback = NULL,
|
|
||||||
};
|
|
||||||
|
|
||||||
ret = env_export(&env_new);
|
ret = env_export(&env_new);
|
||||||
if (ret)
|
if (ret)
|
||||||
|
|
|
@ -145,7 +145,6 @@ int nandmtd_EraseBlockInNAND(struct yaffs_dev *dev, int blockNumber)
|
||||||
ei.len = dev->data_bytes_per_chunk * dev->param.chunks_per_block;
|
ei.len = dev->data_bytes_per_chunk * dev->param.chunks_per_block;
|
||||||
ei.time = 1000;
|
ei.time = 1000;
|
||||||
ei.retries = 2;
|
ei.retries = 2;
|
||||||
ei.callback = NULL;
|
|
||||||
ei.priv = (u_long) dev;
|
ei.priv = (u_long) dev;
|
||||||
|
|
||||||
/* Todo finish off the ei if required */
|
/* Todo finish off the ei if required */
|
||||||
|
|
|
@ -51,7 +51,6 @@ struct erase_info {
|
||||||
u_long retries;
|
u_long retries;
|
||||||
unsigned dev;
|
unsigned dev;
|
||||||
unsigned cell;
|
unsigned cell;
|
||||||
void (*callback) (struct erase_info *self);
|
|
||||||
u_long priv;
|
u_long priv;
|
||||||
u_char state;
|
u_char state;
|
||||||
struct erase_info *next;
|
struct erase_info *next;
|
||||||
|
@ -535,16 +534,6 @@ extern int unregister_mtd_user (struct mtd_notifier *old);
|
||||||
#endif
|
#endif
|
||||||
void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size);
|
void *mtd_kmalloc_up_to(const struct mtd_info *mtd, size_t *size);
|
||||||
|
|
||||||
#ifdef CONFIG_MTD_PARTITIONS
|
|
||||||
void mtd_erase_callback(struct erase_info *instr);
|
|
||||||
#else
|
|
||||||
static inline void mtd_erase_callback(struct erase_info *instr)
|
|
||||||
{
|
|
||||||
if (instr->callback)
|
|
||||||
instr->callback(instr);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline int mtd_is_bitflip(int err) {
|
static inline int mtd_is_bitflip(int err) {
|
||||||
return err == -EUCLEAN;
|
return err == -EUCLEAN;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,6 @@ static inline int nand_erase(struct mtd_info *info, loff_t off, size_t size)
|
||||||
instr.mtd = info;
|
instr.mtd = info;
|
||||||
instr.addr = off;
|
instr.addr = off;
|
||||||
instr.len = size;
|
instr.len = size;
|
||||||
instr.callback = 0;
|
|
||||||
|
|
||||||
return mtd_erase(info, &instr);
|
return mtd_erase(info, &instr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue