summaryrefslogtreecommitdiffstats
path: root/drivers/mtd/ubi/cdev.c
diff options
context:
space:
mode:
authorKyungmin Park <kyungmin.park@samsung.com>2008-05-22 10:32:18 +0900
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>2008-07-24 13:32:54 +0300
commitcadb40ccc16a26a738f1cbc963e35b21edd93e79 (patch)
treeacd1d5d02ecda07634f1c49432ddb39cd9f5d7fd /drivers/mtd/ubi/cdev.c
parenta0fd1efd488092951f310fdb777b8a540cf84dcb (diff)
downloadop-kernel-dev-cadb40ccc16a26a738f1cbc963e35b21edd93e79.zip
op-kernel-dev-cadb40ccc16a26a738f1cbc963e35b21edd93e79.tar.gz
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.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 89193ba..0cdaf9f 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,
off = do_div(tmp, vol->usable_leb_size);
lnum = tmp;
- if (off % ubi->min_io_size) {
+ if (off & (ubi->min_io_size - 1)) {
dbg_err("unaligned position");
return -EINVAL;
}
@@ -304,7 +304,7 @@ static ssize_t vol_cdev_direct_write(struct file *file, const char __user *buf,
count_save = count = vol->used_bytes - *offp;
/* We can write only in fractions of the minimum I/O unit */
- if (count % ubi->min_io_size) {
+ if (count & (ubi->min_io_size - 1)) {
dbg_err("unaligned write length");
return -EINVAL;
}
@@ -564,7 +564,7 @@ static int verify_mkvol_req(const struct ubi_device *ubi,
if (req->alignment > ubi->leb_size)
goto bad;
- n = req->alignment % ubi->min_io_size;
+ n = req->alignment & (ubi->min_io_size - 1);
if (req->alignment != 1 && n)
goto bad;
OpenPOWER on IntegriCloud