diff options
author | Kyungmin Park <kyungmin.park@samsung.com> | 2008-05-21 21:32:18 -0400 |
---|---|---|
committer | Artem Bityutskiy <Artem.Bityutskiy@nokia.com> | 2008-07-24 06:32:54 -0400 |
commit | cadb40ccc16a26a738f1cbc963e35b21edd93e79 (patch) | |
tree | acd1d5d02ecda07634f1c49432ddb39cd9f5d7fd /drivers/mtd/ubi/build.c | |
parent | a0fd1efd488092951f310fdb777b8a540cf84dcb (diff) |
UBI: avoid unnecessary division operations
UBI already checks that @min io size is the power of 2 at io_init.
It is save to use bit operations then.
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
Diffstat (limited to 'drivers/mtd/ubi/build.c')
-rw-r--r-- | drivers/mtd/ubi/build.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/mtd/ubi/build.c b/drivers/mtd/ubi/build.c index 961416ac0616..ff4425de1527 100644 --- a/drivers/mtd/ubi/build.c +++ b/drivers/mtd/ubi/build.c | |||
@@ -530,7 +530,11 @@ static int io_init(struct ubi_device *ubi) | |||
530 | ubi->min_io_size = ubi->mtd->writesize; | 530 | ubi->min_io_size = ubi->mtd->writesize; |
531 | ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft; | 531 | ubi->hdrs_min_io_size = ubi->mtd->writesize >> ubi->mtd->subpage_sft; |
532 | 532 | ||
533 | /* Make sure minimal I/O unit is power of 2 */ | 533 | /* |
534 | * Make sure minimal I/O unit is power of 2. Note, there is no | ||
535 | * fundamental reason for this assumption. It is just an optimization | ||
536 | * which allows us to avoid costly division operations. | ||
537 | */ | ||
534 | if (!is_power_of_2(ubi->min_io_size)) { | 538 | if (!is_power_of_2(ubi->min_io_size)) { |
535 | ubi_err("min. I/O unit (%d) is not power of 2", | 539 | ubi_err("min. I/O unit (%d) is not power of 2", |
536 | ubi->min_io_size); | 540 | ubi->min_io_size); |
@@ -581,7 +585,7 @@ static int io_init(struct ubi_device *ubi) | |||
581 | if (ubi->vid_hdr_offset < UBI_EC_HDR_SIZE || | 585 | if (ubi->vid_hdr_offset < UBI_EC_HDR_SIZE || |
582 | ubi->leb_start < ubi->vid_hdr_offset + UBI_VID_HDR_SIZE || | 586 | ubi->leb_start < ubi->vid_hdr_offset + UBI_VID_HDR_SIZE || |
583 | ubi->leb_start > ubi->peb_size - UBI_VID_HDR_SIZE || | 587 | ubi->leb_start > ubi->peb_size - UBI_VID_HDR_SIZE || |
584 | ubi->leb_start % ubi->min_io_size) { | 588 | ubi->leb_start & (ubi->min_io_size - 1)) { |
585 | ubi_err("bad VID header (%d) or data offsets (%d)", | 589 | ubi_err("bad VID header (%d) or data offsets (%d)", |
586 | ubi->vid_hdr_offset, ubi->leb_start); | 590 | ubi->vid_hdr_offset, ubi->leb_start); |
587 | return -EINVAL; | 591 | return -EINVAL; |