diff options
author | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-01-24 16:56:14 +0100 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-01-25 15:41:25 +0100 |
commit | 60c031531a85b3580f66c2530f9b2802adcad4df (patch) | |
tree | f3d9211a948233f23f8e193af951776024d6aa29 /drivers/mtd | |
parent | UBI: simplify internal interfaces (diff) | |
download | linux-60c031531a85b3580f66c2530f9b2802adcad4df.tar.xz linux-60c031531a85b3580f66c2530f9b2802adcad4df.zip |
UBI: handle zero-length case
ubi_eba_atomic_leb_change() has to just map the LEB to a free PEB
if data length is zero.
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd')
-rw-r--r-- | drivers/mtd/ubi/eba.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index 1f7375e2ffb8..7ce91ca742b1 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c @@ -862,6 +862,17 @@ int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol, if (ubi->ro_mode) return -EROFS; + if (len == 0) { + /* + * Special case when data length is zero. In this case the LEB + * has to be unmapped and mapped somewhere else. + */ + err = ubi_eba_unmap_leb(ubi, vol, lnum); + if (err) + return err; + return ubi_eba_write_leb(ubi, vol, lnum, NULL, 0, 0, dtype); + } + vid_hdr = ubi_zalloc_vid_hdr(ubi, GFP_NOFS); if (!vid_hdr) return -ENOMEM; |