UBI: separate out corrupted list
This patch introduces 'add_corrupted()' function and separates out 'corr' list manipulation from the common 'add_to_list()' function. This is just a preparation for further changes - this patch does not change functionality. Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
This commit is contained in:
parent
b33215084c
commit
3fb34124da
|
@ -64,9 +64,9 @@ static struct ubi_vid_hdr *vidh;
|
||||||
* @ec: erase counter of the physical eraseblock
|
* @ec: erase counter of the physical eraseblock
|
||||||
* @list: the list to add to
|
* @list: the list to add to
|
||||||
*
|
*
|
||||||
* This function adds physical eraseblock @pnum to free, erase, corrupted or
|
* This function adds physical eraseblock @pnum to free, erase, or alien lists.
|
||||||
* alien lists. Returns zero in case of success and a negative error code in
|
* Returns zero in case of success and a negative error code in case of
|
||||||
* case of failure.
|
* failure.
|
||||||
*/
|
*/
|
||||||
static int add_to_list(struct ubi_scan_info *si, int pnum, int ec,
|
static int add_to_list(struct ubi_scan_info *si, int pnum, int ec,
|
||||||
struct list_head *list)
|
struct list_head *list)
|
||||||
|
@ -79,9 +79,6 @@ static int add_to_list(struct ubi_scan_info *si, int pnum, int ec,
|
||||||
} else if (list == &si->erase) {
|
} else if (list == &si->erase) {
|
||||||
dbg_bld("add to erase: PEB %d, EC %d", pnum, ec);
|
dbg_bld("add to erase: PEB %d, EC %d", pnum, ec);
|
||||||
si->erase_peb_count += 1;
|
si->erase_peb_count += 1;
|
||||||
} else if (list == &si->corr) {
|
|
||||||
dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec);
|
|
||||||
si->corr_peb_count += 1;
|
|
||||||
} else if (list == &si->alien) {
|
} else if (list == &si->alien) {
|
||||||
dbg_bld("add to alien: PEB %d, EC %d", pnum, ec);
|
dbg_bld("add to alien: PEB %d, EC %d", pnum, ec);
|
||||||
si->alien_peb_count += 1;
|
si->alien_peb_count += 1;
|
||||||
|
@ -98,6 +95,33 @@ static int add_to_list(struct ubi_scan_info *si, int pnum, int ec,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* add_corrupted - add a corrupted physical eraseblock.
|
||||||
|
* @si: scanning information
|
||||||
|
* @pnum: physical eraseblock number to add
|
||||||
|
* @ec: erase counter of the physical eraseblock
|
||||||
|
*
|
||||||
|
* This function adds corrupted physical eraseblock @pnum to the 'corr' list.
|
||||||
|
* Returns zero in case of success and a negative error code in case of
|
||||||
|
* failure.
|
||||||
|
*/
|
||||||
|
static int add_corrupted(struct ubi_scan_info *si, int pnum, int ec)
|
||||||
|
{
|
||||||
|
struct ubi_scan_leb *seb;
|
||||||
|
|
||||||
|
dbg_bld("add to corrupted: PEB %d, EC %d", pnum, ec);
|
||||||
|
|
||||||
|
seb = kmalloc(sizeof(struct ubi_scan_leb), GFP_KERNEL);
|
||||||
|
if (!seb)
|
||||||
|
return -ENOMEM;
|
||||||
|
|
||||||
|
si->corr_peb_count += 1;
|
||||||
|
seb->pnum = pnum;
|
||||||
|
seb->ec = ec;
|
||||||
|
list_add(&seb->u.list, &si->corr);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* validate_vid_hdr - check volume identifier header.
|
* validate_vid_hdr - check volume identifier header.
|
||||||
* @vid_hdr: the volume identifier header to check
|
* @vid_hdr: the volume identifier header to check
|
||||||
|
@ -464,8 +488,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si,
|
||||||
return err;
|
return err;
|
||||||
|
|
||||||
if (cmp_res & 4)
|
if (cmp_res & 4)
|
||||||
err = add_to_list(si, seb->pnum, seb->ec,
|
err = add_corrupted(si, seb->pnum, seb->ec);
|
||||||
&si->corr);
|
|
||||||
else
|
else
|
||||||
err = add_to_list(si, seb->pnum, seb->ec,
|
err = add_to_list(si, seb->pnum, seb->ec,
|
||||||
&si->erase);
|
&si->erase);
|
||||||
|
@ -488,7 +511,7 @@ int ubi_scan_add_used(struct ubi_device *ubi, struct ubi_scan_info *si,
|
||||||
* previously.
|
* previously.
|
||||||
*/
|
*/
|
||||||
if (cmp_res & 4)
|
if (cmp_res & 4)
|
||||||
return add_to_list(si, pnum, ec, &si->corr);
|
return add_corrupted(si, pnum, ec);
|
||||||
else
|
else
|
||||||
return add_to_list(si, pnum, ec, &si->erase);
|
return add_to_list(si, pnum, ec, &si->erase);
|
||||||
}
|
}
|
||||||
|
@ -835,13 +858,13 @@ static int process_eb(struct ubi_device *ubi, struct ubi_scan_info *si,
|
||||||
si->read_err_count += 1;
|
si->read_err_count += 1;
|
||||||
case UBI_IO_BAD_HDR:
|
case UBI_IO_BAD_HDR:
|
||||||
case UBI_IO_FF_BITFLIPS:
|
case UBI_IO_FF_BITFLIPS:
|
||||||
err = add_to_list(si, pnum, ec, &si->corr);
|
err = add_corrupted(si, pnum, ec);
|
||||||
if (err)
|
if (err)
|
||||||
return err;
|
return err;
|
||||||
goto adjust_mean_ec;
|
goto adjust_mean_ec;
|
||||||
case UBI_IO_FF:
|
case UBI_IO_FF:
|
||||||
if (ec_err)
|
if (ec_err)
|
||||||
err = add_to_list(si, pnum, ec, &si->corr);
|
err = add_corrupted(si, pnum, ec);
|
||||||
else
|
else
|
||||||
err = add_to_list(si, pnum, ec, &si->free);
|
err = add_to_list(si, pnum, ec, &si->free);
|
||||||
if (err)
|
if (err)
|
||||||
|
|
Loading…
Reference in a new issue