[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1471489681-4027-1-git-send-email-shawn.lin@rock-chips.com>
Date: Thu, 18 Aug 2016 11:08:01 +0800
From: Shawn Lin <shawn.lin@...k-chips.com>
To: Minchan Kim <minchan@...nel.org>
Cc: Nitin Gupta <ngupta@...are.org>,
Sergey Senozhatsky <sergey.senozhatsky.work@...il.com>,
linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Shawn Lin <shawn.lin@...k-chips.com>
Subject: [PATCH] zram: clean up valid_io_request
Use IS_ALIGNED instead of opencoding to check the unaligned
case. And size is aligned to ZRAM_LOGICAL_BLOCK_SIZE which
will not make end <= start, so we do not need to compare
the start and end.
Signed-off-by: Shawn Lin <shawn.lin@...k-chips.com>
---
drivers/block/zram/zram_drv.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 04365b1..1094e95 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -120,15 +120,15 @@ static inline bool valid_io_request(struct zram *zram,
u64 end, bound;
/* unaligned request */
- if (unlikely(start & (ZRAM_SECTOR_PER_LOGICAL_BLOCK - 1)))
+ if (unlikely(!IS_ALIGNED(start, ZRAM_SECTOR_PER_LOGICAL_BLOCK)))
return false;
- if (unlikely(size & (ZRAM_LOGICAL_BLOCK_SIZE - 1)))
+ if (unlikely(!IS_ALIGNED(size, ZRAM_LOGICAL_BLOCK_SIZE)))
return false;
end = start + (size >> SECTOR_SHIFT);
bound = zram->disksize >> SECTOR_SHIFT;
/* out of range range */
- if (unlikely(start >= bound || end > bound || start > end))
+ if (unlikely(start >= bound || end > bound))
return false;
/* I/O request is valid */
--
2.3.7
Powered by blists - more mailing lists