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/cdev.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/cdev.c')
-rw-r--r-- | drivers/mtd/ubi/cdev.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c index 89193ba9451e..0cdaf9fba7b0 100644 --- a/drivers/mtd/ubi/cdev.c +++ b/drivers/mtd/ubi/cdev.c | |||
@@ -295,7 +295,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf, | |||
295 | off = do_div(tmp, vol->usable_leb_size); | 295 | off = do_div(tmp, vol->usable_leb_size); |
296 | lnum = tmp; | 296 | lnum = tmp; |
297 | 297 | ||
298 | if (off % ubi->min_io_size) { | 298 | if (off & (ubi->min_io_size - 1)) { |
299 | dbg_err("unaligned position"); | 299 | dbg_err("unaligned position"); |
300 | return -EINVAL; | 300 | return -EINVAL; |
301 | } | 301 | } |
@@ -304,7 +304,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf, | |||
304 | count_save = count = vol->used_bytes - *offp; | 304 | count_save = count = vol->used_bytes - *offp; |
305 | 305 | ||
306 | /* We can write only in fractions of the minimum I/O unit */ | 306 | /* We can write only in fractions of the minimum I/O unit */ |
307 | if (count % ubi->min_io_size) { | 307 | if (count & (ubi->min_io_size - 1)) { |
308 | dbg_err("unaligned write length"); | 308 | dbg_err("unaligned write length"); |
309 | return -EINVAL; | 309 | return -EINVAL; |
310 | } | 310 | } |
@@ -564,7 +564,7 @@ static int verify_mkvol_req(const struct ubi_device *ubi, | |||
564 | if (req->alignment > ubi->leb_size) | 564 | if (req->alignment > ubi->leb_size) |
565 | goto bad; | 565 | goto bad; |
566 | 566 | ||
567 | n = req->alignment % ubi->min_io_size; | 567 | n = req->alignment & (ubi->min_io_size - 1); |
568 | if (req->alignment != 1 && n) | 568 | if (req->alignment != 1 && n) |
569 | goto bad; | 569 | goto bad; |
570 | 570 | ||