ubi: Replace erase_block() with sync_erase()
Since erase_block() has same logic with sync_erase(), just replace it with sync_erase(), also rename 'sync_erase()' to 'ubi_sync_erase()'. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: Richard Weinberger <richard@nod.at>
This commit is contained in:
parent
a033ab4fec
commit
c19286d70a
@ -1389,50 +1389,6 @@ out:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* erase_block - Manually erase a PEB.
|
|
||||||
* @ubi: UBI device object
|
|
||||||
* @e: the physical eraseblock to erase
|
|
||||||
*
|
|
||||||
* This function returns zero in case of success and a negative error code in
|
|
||||||
* case of failure.
|
|
||||||
*/
|
|
||||||
static int erase_block(struct ubi_device *ubi, struct ubi_wl_entry *e)
|
|
||||||
{
|
|
||||||
int err;
|
|
||||||
struct ubi_ec_hdr *ec_hdr;
|
|
||||||
long long ec = e->ec;
|
|
||||||
|
|
||||||
ec_hdr = kzalloc(ubi->ec_hdr_alsize, GFP_NOFS);
|
|
||||||
if (!ec_hdr)
|
|
||||||
return -ENOMEM;
|
|
||||||
|
|
||||||
err = ubi_io_sync_erase(ubi, e->pnum, 0);
|
|
||||||
if (err < 0)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
ec += err;
|
|
||||||
if (ec > UBI_MAX_ERASECOUNTER) {
|
|
||||||
err = -EINVAL;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
ec_hdr->ec = cpu_to_be64(ec);
|
|
||||||
err = ubi_io_write_ec_hdr(ubi, e->pnum, ec_hdr);
|
|
||||||
if (err < 0)
|
|
||||||
goto out;
|
|
||||||
|
|
||||||
e->ec = ec;
|
|
||||||
spin_lock(&ubi->wl_lock);
|
|
||||||
if (e->ec > ubi->max_ec)
|
|
||||||
ubi->max_ec = e->ec;
|
|
||||||
spin_unlock(&ubi->wl_lock);
|
|
||||||
|
|
||||||
out:
|
|
||||||
kfree(ec_hdr);
|
|
||||||
return err;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* invalidate_fastmap - destroys a fastmap.
|
* invalidate_fastmap - destroys a fastmap.
|
||||||
* @ubi: UBI device object
|
* @ubi: UBI device object
|
||||||
@ -1573,7 +1529,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)
|
|||||||
|
|
||||||
if (!tmp_e) {
|
if (!tmp_e) {
|
||||||
if (old_fm && old_fm->e[i]) {
|
if (old_fm && old_fm->e[i]) {
|
||||||
ret = erase_block(ubi, old_fm->e[i]);
|
ret = ubi_sync_erase(ubi, old_fm->e[i], 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ubi_err(ubi, "could not erase old fastmap PEB");
|
ubi_err(ubi, "could not erase old fastmap PEB");
|
||||||
|
|
||||||
@ -1625,7 +1581,7 @@ int ubi_update_fastmap(struct ubi_device *ubi)
|
|||||||
if (old_fm) {
|
if (old_fm) {
|
||||||
/* no fresh anchor PEB was found, reuse the old one */
|
/* no fresh anchor PEB was found, reuse the old one */
|
||||||
if (!tmp_e) {
|
if (!tmp_e) {
|
||||||
ret = erase_block(ubi, old_fm->e[0]);
|
ret = ubi_sync_erase(ubi, old_fm->e[0], 0);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
ubi_err(ubi, "could not erase old anchor PEB");
|
ubi_err(ubi, "could not erase old anchor PEB");
|
||||||
|
|
||||||
|
@ -902,6 +902,7 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap,
|
|||||||
struct ubi_attach_info *ai_scan);
|
struct ubi_attach_info *ai_scan);
|
||||||
|
|
||||||
/* wl.c */
|
/* wl.c */
|
||||||
|
int ubi_sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e, int torture);
|
||||||
int ubi_wl_get_peb(struct ubi_device *ubi);
|
int ubi_wl_get_peb(struct ubi_device *ubi);
|
||||||
int ubi_wl_put_peb(struct ubi_device *ubi, int vol_id, int lnum,
|
int ubi_wl_put_peb(struct ubi_device *ubi, int vol_id, int lnum,
|
||||||
int pnum, int torture);
|
int pnum, int torture);
|
||||||
|
@ -427,7 +427,7 @@ static int prot_queue_del(struct ubi_device *ubi, int pnum)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sync_erase - synchronously erase a physical eraseblock.
|
* ubi_sync_erase - synchronously erase a physical eraseblock.
|
||||||
* @ubi: UBI device description object
|
* @ubi: UBI device description object
|
||||||
* @e: the physical eraseblock to erase
|
* @e: the physical eraseblock to erase
|
||||||
* @torture: if the physical eraseblock has to be tortured
|
* @torture: if the physical eraseblock has to be tortured
|
||||||
@ -435,8 +435,7 @@ static int prot_queue_del(struct ubi_device *ubi, int pnum)
|
|||||||
* This function returns zero in case of success and a negative error code in
|
* This function returns zero in case of success and a negative error code in
|
||||||
* case of failure.
|
* case of failure.
|
||||||
*/
|
*/
|
||||||
static int sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e,
|
int ubi_sync_erase(struct ubi_device *ubi, struct ubi_wl_entry *e, int torture)
|
||||||
int torture)
|
|
||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
struct ubi_ec_hdr *ec_hdr;
|
struct ubi_ec_hdr *ec_hdr;
|
||||||
@ -1094,7 +1093,7 @@ static int __erase_worker(struct ubi_device *ubi, struct ubi_work *wl_wrk)
|
|||||||
dbg_wl("erase PEB %d EC %d LEB %d:%d",
|
dbg_wl("erase PEB %d EC %d LEB %d:%d",
|
||||||
pnum, e->ec, wl_wrk->vol_id, wl_wrk->lnum);
|
pnum, e->ec, wl_wrk->vol_id, wl_wrk->lnum);
|
||||||
|
|
||||||
err = sync_erase(ubi, e, wl_wrk->torture);
|
err = ubi_sync_erase(ubi, e, wl_wrk->torture);
|
||||||
if (!err) {
|
if (!err) {
|
||||||
spin_lock(&ubi->wl_lock);
|
spin_lock(&ubi->wl_lock);
|
||||||
|
|
||||||
@ -1749,7 +1748,7 @@ static int erase_aeb(struct ubi_device *ubi, struct ubi_ainf_peb *aeb, bool sync
|
|||||||
ubi->lookuptbl[e->pnum] = e;
|
ubi->lookuptbl[e->pnum] = e;
|
||||||
|
|
||||||
if (sync) {
|
if (sync) {
|
||||||
err = sync_erase(ubi, e, false);
|
err = ubi_sync_erase(ubi, e, false);
|
||||||
if (err)
|
if (err)
|
||||||
goto out_free;
|
goto out_free;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user