]> err.no Git - linux-2.6/blobdiff - drivers/mtd/ubi/eba.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
[linux-2.6] / drivers / mtd / ubi / eba.c
index 7c05c6e1abc7de001ec26fb1ed9535347b77a337..7ce91ca742b136c7b60ac6db25ffb3d3771d2d6b 100644 (file)
@@ -78,7 +78,7 @@ static unsigned long long next_sqnum(struct ubi_device *ubi)
  */
 static int ubi_get_compat(const struct ubi_device *ubi, int vol_id)
 {
-       if (vol_id == UBI_LAYOUT_VOL_ID)
+       if (vol_id == UBI_LAYOUT_VOLUME_ID)
                return UBI_LAYOUT_VOLUME_COMPAT;
        return 0;
 }
@@ -341,9 +341,6 @@ int ubi_eba_unmap_leb(struct ubi_device *ubi, struct ubi_volume *vol,
 {
        int err, pnum, vol_id = vol->vol_id;
 
-       ubi_assert(ubi->ref_count > 0);
-       ubi_assert(vol->ref_count > 0);
-
        if (ubi->ro_mode)
                return -EROFS;
 
@@ -392,9 +389,6 @@ int ubi_eba_read_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
        struct ubi_vid_hdr *vid_hdr;
        uint32_t uninitialized_var(crc);
 
-       ubi_assert(ubi->ref_count > 0);
-       ubi_assert(vol->ref_count > 0);
-
        err = leb_read_lock(ubi, vol_id, lnum);
        if (err)
                return err;
@@ -618,9 +612,6 @@ int ubi_eba_write_leb(struct ubi_device *ubi, struct ubi_volume *vol, int lnum,
        int err, pnum, tries = 0, vol_id = vol->vol_id;
        struct ubi_vid_hdr *vid_hdr;
 
-       ubi_assert(ubi->ref_count > 0);
-       ubi_assert(vol->ref_count > 0);
-
        if (ubi->ro_mode)
                return -EROFS;
 
@@ -754,9 +745,6 @@ int ubi_eba_write_leb_st(struct ubi_device *ubi, struct ubi_volume *vol,
        struct ubi_vid_hdr *vid_hdr;
        uint32_t crc;
 
-       ubi_assert(ubi->ref_count > 0);
-       ubi_assert(vol->ref_count > 0);
-
        if (ubi->ro_mode)
                return -EROFS;
 
@@ -871,12 +859,20 @@ int ubi_eba_atomic_leb_change(struct ubi_device *ubi, struct ubi_volume *vol,
        struct ubi_vid_hdr *vid_hdr;
        uint32_t crc;
 
-       ubi_assert(ubi->ref_count > 0);
-       ubi_assert(vol->ref_count > 0);
-
        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;