mtd: ubi: wl: avoid erasing a PEB which is empty
authorSebastian Siewior <bigeasy@linutronix.de>
Thu, 26 Nov 2015 20:23:50 +0000 (21:23 +0100)
committerRichard Weinberger <richard@nod.at>
Sun, 10 Jan 2016 11:33:11 +0000 (12:33 +0100)
commit34b89df90374b631692132640c6b3dbef52f808d
tree3a1e0fec6d608bf57763f94f6b92e05f0cb54ebb
parent168309855a7d1e16db751e9c647119fe2d2dc878
mtd: ubi: wl: avoid erasing a PEB which is empty

wear_leveling_worker() currently unconditionally puts a PEB on erase in
the error case even it just been taken from the free_list and never
used.
In case the PEB was never used it can be put back on the free list
saving a precious erase cycle.

v1…v2:
- to_leb_clean -> dst_leb_clean
- use the nested option for ensure_wear_leveling()
- do_sync_erase() can't go -ENOMEM so we can just go into
  RO-mode now.

Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/ubi/wl.c