UBI: Fastmap: Rename variables to make them meaningful
authorshengyong <shengyong1@huawei.com>
Tue, 26 May 2015 10:07:07 +0000 (10:07 +0000)
committerRichard Weinberger <richard@nod.at>
Tue, 2 Jun 2015 09:44:20 +0000 (11:44 +0200)
s/fmpl1/fmpl
s/fmpl2/fmpl_wl

Add "WL" to the error message when wrong WL pool magic number is detected.

Signed-off-by: Sheng Yong <shengyong1@huawei.com>
Signed-off-by: Richard Weinberger <richard@nod.at>
drivers/mtd/ubi/fastmap.c

index 696a4f96e06b882fdb5e48e8cfaba9a1598d6a35..e3d829409fa68285615e702aeb76fe07b41db2eb 100644 (file)
@@ -601,7 +601,7 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
        struct ubi_ainf_peb *aeb, *tmp_aeb, *_tmp_aeb;
        struct ubi_fm_sb *fmsb;
        struct ubi_fm_hdr *fmhdr;
-       struct ubi_fm_scan_pool *fmpl1, *fmpl2;
+       struct ubi_fm_scan_pool *fmpl, *fmpl_wl;
        struct ubi_fm_ec *fmec;
        struct ubi_fm_volhdr *fmvhdr;
        struct ubi_fm_eba *fm_eba;
@@ -631,30 +631,30 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
                goto fail_bad;
        }
 
-       fmpl1 = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos);
-       fm_pos += sizeof(*fmpl1);
+       fmpl = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos);
+       fm_pos += sizeof(*fmpl);
        if (fm_pos >= fm_size)
                goto fail_bad;
-       if (be32_to_cpu(fmpl1->magic) != UBI_FM_POOL_MAGIC) {
+       if (be32_to_cpu(fmpl->magic) != UBI_FM_POOL_MAGIC) {
                ubi_err(ubi, "bad fastmap pool magic: 0x%x, expected: 0x%x",
-                       be32_to_cpu(fmpl1->magic), UBI_FM_POOL_MAGIC);
+                       be32_to_cpu(fmpl->magic), UBI_FM_POOL_MAGIC);
                goto fail_bad;
        }
 
-       fmpl2 = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos);
-       fm_pos += sizeof(*fmpl2);
+       fmpl_wl = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos);
+       fm_pos += sizeof(*fmpl_wl);
        if (fm_pos >= fm_size)
                goto fail_bad;
-       if (be32_to_cpu(fmpl2->magic) != UBI_FM_POOL_MAGIC) {
-               ubi_err(ubi, "bad fastmap pool magic: 0x%x, expected: 0x%x",
-                       be32_to_cpu(fmpl2->magic), UBI_FM_POOL_MAGIC);
+       if (be32_to_cpu(fmpl_wl->magic) != UBI_FM_POOL_MAGIC) {
+               ubi_err(ubi, "bad fastmap WL pool magic: 0x%x, expected: 0x%x",
+                       be32_to_cpu(fmpl_wl->magic), UBI_FM_POOL_MAGIC);
                goto fail_bad;
        }
 
-       pool_size = be16_to_cpu(fmpl1->size);
-       wl_pool_size = be16_to_cpu(fmpl2->size);
-       fm->max_pool_size = be16_to_cpu(fmpl1->max_size);
-       fm->max_wl_pool_size = be16_to_cpu(fmpl2->max_size);
+       pool_size = be16_to_cpu(fmpl->size);
+       wl_pool_size = be16_to_cpu(fmpl_wl->size);
+       fm->max_pool_size = be16_to_cpu(fmpl->max_size);
+       fm->max_wl_pool_size = be16_to_cpu(fmpl_wl->max_size);
 
        if (pool_size > UBI_FM_MAX_POOL_SIZE || pool_size < 0) {
                ubi_err(ubi, "bad pool size: %i", pool_size);
@@ -796,11 +796,11 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
                }
        }
 
-       ret = scan_pool(ubi, ai, fmpl1->pebs, pool_size, &max_sqnum, &free);
+       ret = scan_pool(ubi, ai, fmpl->pebs, pool_size, &max_sqnum, &free);
        if (ret)
                goto fail;
 
-       ret = scan_pool(ubi, ai, fmpl2->pebs, wl_pool_size, &max_sqnum, &free);
+       ret = scan_pool(ubi, ai, fmpl_wl->pebs, wl_pool_size, &max_sqnum, &free);
        if (ret)
                goto fail;
 
@@ -1083,7 +1083,7 @@ static int ubi_write_fastmap(struct ubi_device *ubi,
        void *fm_raw;
        struct ubi_fm_sb *fmsb;
        struct ubi_fm_hdr *fmh;
-       struct ubi_fm_scan_pool *fmpl1, *fmpl2;
+       struct ubi_fm_scan_pool *fmpl, *fmpl_wl;
        struct ubi_fm_ec *fec;
        struct ubi_fm_volhdr *fvh;
        struct ubi_fm_eba *feba;
@@ -1141,25 +1141,25 @@ static int ubi_write_fastmap(struct ubi_device *ubi,
        erase_peb_count = 0;
        vol_count = 0;
 
-       fmpl1 = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos);
-       fm_pos += sizeof(*fmpl1);
-       fmpl1->magic = cpu_to_be32(UBI_FM_POOL_MAGIC);
-       fmpl1->size = cpu_to_be16(ubi->fm_pool.size);
-       fmpl1->max_size = cpu_to_be16(ubi->fm_pool.max_size);
+       fmpl = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos);
+       fm_pos += sizeof(*fmpl);
+       fmpl->magic = cpu_to_be32(UBI_FM_POOL_MAGIC);
+       fmpl->size = cpu_to_be16(ubi->fm_pool.size);
+       fmpl->max_size = cpu_to_be16(ubi->fm_pool.max_size);
 
        for (i = 0; i < ubi->fm_pool.size; i++) {
-               fmpl1->pebs[i] = cpu_to_be32(ubi->fm_pool.pebs[i]);
+               fmpl->pebs[i] = cpu_to_be32(ubi->fm_pool.pebs[i]);
                set_seen(ubi, ubi->fm_pool.pebs[i], seen_pebs);
        }
 
-       fmpl2 = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos);
-       fm_pos += sizeof(*fmpl2);
-       fmpl2->magic = cpu_to_be32(UBI_FM_POOL_MAGIC);
-       fmpl2->size = cpu_to_be16(ubi->fm_wl_pool.size);
-       fmpl2->max_size = cpu_to_be16(ubi->fm_wl_pool.max_size);
+       fmpl_wl = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos);
+       fm_pos += sizeof(*fmpl_wl);
+       fmpl_wl->magic = cpu_to_be32(UBI_FM_POOL_MAGIC);
+       fmpl_wl->size = cpu_to_be16(ubi->fm_wl_pool.size);
+       fmpl_wl->max_size = cpu_to_be16(ubi->fm_wl_pool.max_size);
 
        for (i = 0; i < ubi->fm_wl_pool.size; i++) {
-               fmpl2->pebs[i] = cpu_to_be32(ubi->fm_wl_pool.pebs[i]);
+               fmpl_wl->pebs[i] = cpu_to_be32(ubi->fm_wl_pool.pebs[i]);
                set_seen(ubi, ubi->fm_wl_pool.pebs[i], seen_pebs);
        }