UBI: fix documentation and improve readability
Subsystems (2)
PATCH 1/2 UBI: fix documentation and improve readability
From: Artem Bityutskiy <[email protected]>
The "max" parameter of 'find_wl_entry()' was documented incorrectly and it actually means the maximum possible difference from th smallest erase counter. Rename it to "diff" instead, and amend the documentation.
--- drivers/mtd/ubi/wl.c | 9 +++++---- 1 files changed, 5 insertions(+), 4 deletions(-)
drivers/mtd/ubi/wl.c +5 -4
@@ -350,18 +350,19 @@ static void prot_queue_add(struct ubi_device *ubi, struct ubi_wl_entry *e)/** * find_wl_entry - find wear-leveling entry closest to certain erase counter. * @root: the RB-tree where to look for -* @max: highest possible erase counter +* @diff: maximum possible difference from the smallest erase counter * * This function looks for a wear leveling entry with erase counter closest to -* @max and less than @max. +* min + @diff, where min is the smallest erase counter. */ -static struct ubi_wl_entry *find_wl_entry (struct rb_root *root,int max) +static struct ubi_wl_entry *find_wl_entry (struct rb_root *root,int diff) {struct rb_node *p;struct ubi_wl_entry *e; +int max; e = rb_entry(rb_first(root), struct ubi_wl_entry, u.rb); - max += e->ec; + max = e->ec + diff; p = root->rb_node;while (p) {
Signature · 1 line
1.7.9.1
PATCH 2/2 UBI: fix eraseblock picking criteria
From: Artem Bityutskiy <[email protected]>
The 'find_wl_entry()' function expects the maximum difference as the second argument, not the maximum absolute value. So the "unknown" eraseblock picking was incorrect, as Shmulik Ladkani spotted. This patch fixes the issue.
--- drivers/mtd/ubi/wl.c | 10 ++++------ 1 files changed, 4 insertions(+), 6 deletions(-)
drivers/mtd/ubi/wl.c +4 -6
@@ -390,7 +390,7 @@ static struct ubi_wl_entry *find_wl_entry(struct rb_root *root, int diff)*/ int ubi_wl_get_peb (struct ubi_device *ubi,int dtype) { -int err, medium_ec; +int err;struct ubi_wl_entry *e, *first, *last; ubi_assert(dtype == UBI_LONGTERM || dtype == UBI_SHORTTERM ||
@@ -428,7 +428,7 @@ retry:* For unknown data we pick a physical eraseblock with medium * erase counter. But we by no means can pick a physical * eraseblock with erase counter greater or equivalent than the -* lowest erase counter plus %WL_FREE_MAX_DIFF. +* lowest erase counter plus %WL_FREE_MAX_DIFF/2. */ first = rb_entry(rb_first(&ubi->free), struct ubi_wl_entry, u.rb);
@@ -437,10 +437,8 @@ retry:if (last->ec - first->ec <WL_FREE_MAX_DIFF ) e =rb_entry (ubi->free.rb_node, struct ubi_wl_entry, u.rb); -else { - medium_ec = (first->ec +WL_FREE_MAX_DIFF )/2 ; - e =find_wl_entry (&ubi->free, medium_ec); - } +else + e =find_wl_entry (&ubi->free,WL_FREE_MAX_DIFF /2 );break ;case UBI_SHORTTERM :/*
Signature · 1 line
1.7.9.1
Quoted 4 lines · On Thu, 8 Mar 2012 16:21:30 +0200 Artem Bityutskiy <[email protected]> wrote:
From: Artem Bityutskiy <[email protected]>
The "max" parameter of '
find_wl_entry()' was documented incorrectly and it actually means the maximum possible difference from th smallest erase
s/ th / the /
Regards,
Shmulik
Quoted 7 lines · Shmulik Ladkani
Quoted 4 lines · On Thu, 8 Mar 2012 16:21:30 +0200 Artem Bityutskiy <[email protected]> wrote:
From: Artem Bityutskiy <[email protected]>
The "max" parameter of '
find_wl_entry()' was documented incorrectly and it actually means the maximum possible difference from th smallest erases/ th / the /
Fixed, thanks!
Signature · 2 lines
Best Regards, Artem Bityutskiy