#include <linux/slab.h>
#include <asm/div64.h>
#include "ubi.h"
+#ifdef CONFIG_PWR_LOSS_MTK_SPOH
+#include <mach/power_loss_test.h>
+#endif
static void self_vtbl_check(const struct ubi_device *ubi);
err = ubi_eba_unmap_leb(ubi, layout_vol, i);
if (err)
return err;
+#ifdef CONFIG_PWR_LOSS_MTK_SPOH
+ if(i==0)
+ {
+ PL_RESET_ON_CASE("NAND", "CreateVol_1");
+ }
+ else if(i==1)
+ {
+ PL_RESET_ON_CASE("NAND", "CreateVol_2");
+ }
+#endif
err = ubi_eba_write_leb(ubi, layout_vol, i, ubi->vtbl, 0,
ubi->vtbl_size);
err = ubi_eba_unmap_leb(ubi, layout_vol, i);
if (err)
return err;
+#ifdef CONFIG_PWR_LOSS_MTK_SPOH
+ if(i==0)
+ {
+ PL_RESET_ON_CASE("NAND", "ModifyVol_1");
+ }
+ else if(i==1)
+ {
+ PL_RESET_ON_CASE("NAND", "ModifyVol_2");
+ }
+#endif
err = ubi_eba_write_leb(ubi, layout_vol, i, ubi->vtbl, 0,
ubi->vtbl_size);
/* Read both LEB 0 and LEB 1 into memory */
ubi_rb_for_each_entry(rb, aeb, &av->root, u.rb) {
- leb[aeb->lnum] = vzalloc(ubi->vtbl_size);
+ leb[aeb->lnum] = kmalloc(ubi->vtbl_size, GFP_KERNEL);
if (!leb[aeb->lnum]) {
err = -ENOMEM;
goto out_free;
}
/* Both LEB 1 and LEB 2 are OK and consistent */
- vfree(leb[1]);
+ kfree(leb[1]);
return leb[0];
} else {
/* LEB 0 is corrupted or does not exist */
goto out_free;
ubi_msg("volume table was restored");
- vfree(leb[0]);
+ kfree(leb[0]);
return leb[1];
}
out_free:
- vfree(leb[0]);
- vfree(leb[1]);
+ kfree(leb[0]);
+ kfree(leb[1]);
return ERR_PTR(err);
}
int i;
struct ubi_vtbl_record *vtbl;
- vtbl = vzalloc(ubi->vtbl_size);
+ vtbl = kmalloc(ubi->vtbl_size, GFP_KERNEL);
if (!vtbl)
return ERR_PTR(-ENOMEM);
err = create_vtbl(ubi, ai, i, vtbl);
if (err) {
- vfree(vtbl);
+ kfree(vtbl);
return ERR_PTR(err);
}
}
ubi->vol_count += 1;
vol->ubi = ubi;
+#ifdef CONFIG_BLB
+ /* And add the backup volume */
+ vol = kzalloc(sizeof(struct ubi_volume), GFP_KERNEL);
+ if (!vol)
+ return -ENOMEM;
+
+ vol->reserved_pebs = UBI_BACKUP_VOLUME_EBS;
+ vol->alignment = 1;
+ vol->vol_type = UBI_DYNAMIC_VOLUME;
+ vol->name_len = sizeof(UBI_BACKUP_VOLUME_NAME) - 1;
+ memcpy(vol->name, UBI_BACKUP_VOLUME_NAME, vol->name_len + 1);
+ vol->usable_leb_size = ubi->leb_size;
+ vol->used_ebs = vol->reserved_pebs;
+ vol->last_eb_bytes = vol->reserved_pebs;
+ vol->used_bytes =
+ (long long)vol->used_ebs * (ubi->leb_size - vol->data_pad);
+ vol->vol_id = UBI_BACKUP_VOLUME_ID;
+ vol->ref_count = 1;
+
+ ubi_assert(!ubi->volumes[vol_id2idx(ubi, vol->vol_id)]);
+ ubi->volumes[vol_id2idx(ubi, vol->vol_id)] = vol;
+ reserved_pebs += vol->reserved_pebs;
+ ubi->vol_count += 1;
+ vol->ubi = ubi;
+#endif
+
+
if (reserved_pebs > ubi->avail_pebs) {
ubi_err("not enough PEBs, required %d, available %d",
reserved_pebs, ubi->avail_pebs);
return 0;
out_free:
- vfree(ubi->vtbl);
+ kfree(ubi->vtbl);
for (i = 0; i < ubi->vtbl_slots + UBI_INT_VOL_COUNT; i++) {
kfree(ubi->volumes[i]);
ubi->volumes[i] = NULL;