Skip to content

Commit f6e951a

Browse files
shengyongrichardweinberger
authored andcommitted
UBI: Fastmap: Rename variables to make them meaningful
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>
1 parent a18fd67 commit f6e951a

File tree

1 file changed

+29
-29
lines changed

1 file changed

+29
-29
lines changed

drivers/mtd/ubi/fastmap.c

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,7 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
601601
struct ubi_ainf_peb *aeb, *tmp_aeb, *_tmp_aeb;
602602
struct ubi_fm_sb *fmsb;
603603
struct ubi_fm_hdr *fmhdr;
604-
struct ubi_fm_scan_pool *fmpl1, *fmpl2;
604+
struct ubi_fm_scan_pool *fmpl, *fmpl_wl;
605605
struct ubi_fm_ec *fmec;
606606
struct ubi_fm_volhdr *fmvhdr;
607607
struct ubi_fm_eba *fm_eba;
@@ -631,30 +631,30 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
631631
goto fail_bad;
632632
}
633633

634-
fmpl1 = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos);
635-
fm_pos += sizeof(*fmpl1);
634+
fmpl = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos);
635+
fm_pos += sizeof(*fmpl);
636636
if (fm_pos >= fm_size)
637637
goto fail_bad;
638-
if (be32_to_cpu(fmpl1->magic) != UBI_FM_POOL_MAGIC) {
638+
if (be32_to_cpu(fmpl->magic) != UBI_FM_POOL_MAGIC) {
639639
ubi_err(ubi, "bad fastmap pool magic: 0x%x, expected: 0x%x",
640-
be32_to_cpu(fmpl1->magic), UBI_FM_POOL_MAGIC);
640+
be32_to_cpu(fmpl->magic), UBI_FM_POOL_MAGIC);
641641
goto fail_bad;
642642
}
643643

644-
fmpl2 = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos);
645-
fm_pos += sizeof(*fmpl2);
644+
fmpl_wl = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos);
645+
fm_pos += sizeof(*fmpl_wl);
646646
if (fm_pos >= fm_size)
647647
goto fail_bad;
648-
if (be32_to_cpu(fmpl2->magic) != UBI_FM_POOL_MAGIC) {
649-
ubi_err(ubi, "bad fastmap pool magic: 0x%x, expected: 0x%x",
650-
be32_to_cpu(fmpl2->magic), UBI_FM_POOL_MAGIC);
648+
if (be32_to_cpu(fmpl_wl->magic) != UBI_FM_POOL_MAGIC) {
649+
ubi_err(ubi, "bad fastmap WL pool magic: 0x%x, expected: 0x%x",
650+
be32_to_cpu(fmpl_wl->magic), UBI_FM_POOL_MAGIC);
651651
goto fail_bad;
652652
}
653653

654-
pool_size = be16_to_cpu(fmpl1->size);
655-
wl_pool_size = be16_to_cpu(fmpl2->size);
656-
fm->max_pool_size = be16_to_cpu(fmpl1->max_size);
657-
fm->max_wl_pool_size = be16_to_cpu(fmpl2->max_size);
654+
pool_size = be16_to_cpu(fmpl->size);
655+
wl_pool_size = be16_to_cpu(fmpl_wl->size);
656+
fm->max_pool_size = be16_to_cpu(fmpl->max_size);
657+
fm->max_wl_pool_size = be16_to_cpu(fmpl_wl->max_size);
658658

659659
if (pool_size > UBI_FM_MAX_POOL_SIZE || pool_size < 0) {
660660
ubi_err(ubi, "bad pool size: %i", pool_size);
@@ -796,11 +796,11 @@ static int ubi_attach_fastmap(struct ubi_device *ubi,
796796
}
797797
}
798798

799-
ret = scan_pool(ubi, ai, fmpl1->pebs, pool_size, &max_sqnum, &free);
799+
ret = scan_pool(ubi, ai, fmpl->pebs, pool_size, &max_sqnum, &free);
800800
if (ret)
801801
goto fail;
802802

803-
ret = scan_pool(ubi, ai, fmpl2->pebs, wl_pool_size, &max_sqnum, &free);
803+
ret = scan_pool(ubi, ai, fmpl_wl->pebs, wl_pool_size, &max_sqnum, &free);
804804
if (ret)
805805
goto fail;
806806

@@ -1083,7 +1083,7 @@ static int ubi_write_fastmap(struct ubi_device *ubi,
10831083
void *fm_raw;
10841084
struct ubi_fm_sb *fmsb;
10851085
struct ubi_fm_hdr *fmh;
1086-
struct ubi_fm_scan_pool *fmpl1, *fmpl2;
1086+
struct ubi_fm_scan_pool *fmpl, *fmpl_wl;
10871087
struct ubi_fm_ec *fec;
10881088
struct ubi_fm_volhdr *fvh;
10891089
struct ubi_fm_eba *feba;
@@ -1141,25 +1141,25 @@ static int ubi_write_fastmap(struct ubi_device *ubi,
11411141
erase_peb_count = 0;
11421142
vol_count = 0;
11431143

1144-
fmpl1 = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos);
1145-
fm_pos += sizeof(*fmpl1);
1146-
fmpl1->magic = cpu_to_be32(UBI_FM_POOL_MAGIC);
1147-
fmpl1->size = cpu_to_be16(ubi->fm_pool.size);
1148-
fmpl1->max_size = cpu_to_be16(ubi->fm_pool.max_size);
1144+
fmpl = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos);
1145+
fm_pos += sizeof(*fmpl);
1146+
fmpl->magic = cpu_to_be32(UBI_FM_POOL_MAGIC);
1147+
fmpl->size = cpu_to_be16(ubi->fm_pool.size);
1148+
fmpl->max_size = cpu_to_be16(ubi->fm_pool.max_size);
11491149

11501150
for (i = 0; i < ubi->fm_pool.size; i++) {
1151-
fmpl1->pebs[i] = cpu_to_be32(ubi->fm_pool.pebs[i]);
1151+
fmpl->pebs[i] = cpu_to_be32(ubi->fm_pool.pebs[i]);
11521152
set_seen(ubi, ubi->fm_pool.pebs[i], seen_pebs);
11531153
}
11541154

1155-
fmpl2 = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos);
1156-
fm_pos += sizeof(*fmpl2);
1157-
fmpl2->magic = cpu_to_be32(UBI_FM_POOL_MAGIC);
1158-
fmpl2->size = cpu_to_be16(ubi->fm_wl_pool.size);
1159-
fmpl2->max_size = cpu_to_be16(ubi->fm_wl_pool.max_size);
1155+
fmpl_wl = (struct ubi_fm_scan_pool *)(fm_raw + fm_pos);
1156+
fm_pos += sizeof(*fmpl_wl);
1157+
fmpl_wl->magic = cpu_to_be32(UBI_FM_POOL_MAGIC);
1158+
fmpl_wl->size = cpu_to_be16(ubi->fm_wl_pool.size);
1159+
fmpl_wl->max_size = cpu_to_be16(ubi->fm_wl_pool.max_size);
11601160

11611161
for (i = 0; i < ubi->fm_wl_pool.size; i++) {
1162-
fmpl2->pebs[i] = cpu_to_be32(ubi->fm_wl_pool.pebs[i]);
1162+
fmpl_wl->pebs[i] = cpu_to_be32(ubi->fm_wl_pool.pebs[i]);
11631163
set_seen(ubi, ubi->fm_wl_pool.pebs[i], seen_pebs);
11641164
}
11651165

0 commit comments

Comments
 (0)