Skip to content

Commit 4c36842

Browse files
Boris Brezillonrichardweinberger
authored andcommitted
UBI: fastmap: avoid multiple be32_to_cpu() when unneccesary
process_pool_aeb() does several times the be32_to_cpu(new_vh->vol_id) operation. Create a temporary variable and do it once. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: Richard Weinberger <richard@nod.at>
1 parent 3f84e45 commit 4c36842

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/mtd/ubi/fastmap.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -370,24 +370,24 @@ static int process_pool_aeb(struct ubi_device *ubi, struct ubi_attach_info *ai,
370370
struct ubi_vid_hdr *new_vh,
371371
struct ubi_ainf_peb *new_aeb)
372372
{
373+
int vol_id = be32_to_cpu(new_vh->vol_id);
373374
struct ubi_ainf_volume *av;
374375

375-
if (be32_to_cpu(new_vh->vol_id) == UBI_FM_SB_VOLUME_ID ||
376-
be32_to_cpu(new_vh->vol_id) == UBI_FM_DATA_VOLUME_ID) {
376+
if (vol_id == UBI_FM_SB_VOLUME_ID || vol_id == UBI_FM_DATA_VOLUME_ID) {
377377
kmem_cache_free(ai->aeb_slab_cache, new_aeb);
378378

379379
return 0;
380380
}
381381

382382
/* Find the volume this SEB belongs to */
383-
av = ubi_find_av(ai, be32_to_cpu(new_vh->vol_id));
383+
av = ubi_find_av(ai, vol_id);
384384
if (!av) {
385385
ubi_err(ubi, "orphaned volume in fastmap pool!");
386386
kmem_cache_free(ai->aeb_slab_cache, new_aeb);
387387
return UBI_BAD_FASTMAP;
388388
}
389389

390-
ubi_assert(be32_to_cpu(new_vh->vol_id) == av->vol_id);
390+
ubi_assert(vol_id == av->vol_id);
391391

392392
return update_vol(ubi, ai, av, new_vh, new_aeb);
393393
}

0 commit comments

Comments
 (0)