From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753764AbcHRDMi (ORCPT ); Wed, 17 Aug 2016 23:12:38 -0400 Received: from lucky1.263xmail.com ([211.157.147.133]:35046 "EHLO lucky1.263xmail.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753542AbcHRDMh (ORCPT ); Wed, 17 Aug 2016 23:12:37 -0400 X-263anti-spam: KSV:0; X-MAIL-GRAY: 1 X-MAIL-DELIVERY: 0 X-KSVirus-check: 0 X-ABS-CHECKED: 4 X-ADDR-CHECKED: 0 X-RL-SENDER: shawn.lin@rock-chips.com X-FST-TO: minchan@kernel.org X-SENDER-IP: 58.22.7.114 X-LOGIN-NAME: shawn.lin@rock-chips.com X-UNIQUE-TAG: <11cebb2f8bd7cd12ed74f8de1ba10262> X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 From: Shawn Lin To: Minchan Kim Cc: Nitin Gupta , Sergey Senozhatsky , linux-kernel@vger.kernel.org, Andrew Morton , Shawn Lin Subject: [PATCH] zram: clean up valid_io_request Date: Thu, 18 Aug 2016 11:08:01 +0800 Message-Id: <1471489681-4027-1-git-send-email-shawn.lin@rock-chips.com> X-Mailer: git-send-email 1.8.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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