Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754218AbbKYNuS (ORCPT ); Wed, 25 Nov 2015 08:50:18 -0500 Received: from m50-134.163.com ([123.125.50.134]:46730 "EHLO m50-134.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752883AbbKYNuQ (ORCPT ); Wed, 25 Nov 2015 08:50:16 -0500 From: Geliang Tang To: "Nicholas A. Bellinger" , Dan Carpenter , Bart Van Assche Cc: Geliang Tang , linux-scsi@vger.kernel.org, target-devel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] target: use offset_in_page macro Date: Wed, 25 Nov 2015 21:49:27 +0800 Message-Id: X-Mailer: git-send-email 2.5.0 X-CM-TRANSID: DtGowECZOUhpvFVWcbYoAw--.2110S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxJrW3CF13WF4rJry8Kr43GFg_yoW8Aw47pF srGw1UCrW3K3yUXwn7Ja1qvry3uwn7GFWjga4xWa1ru342qrWUJas5X3WxWFyrJF4vkry3 KFZ0yw15Xa18XwUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UtUUbUUUUU= X-Originating-IP: [116.77.146.156] X-CM-SenderInfo: 5jhoxtpqjwt0rj6rljoofrz/1tbiNQ29mVSIKW28hgAAs+ Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2021 Lines: 58 Use offset_in_page macro instead of (addr & ~PAGE_MASK). Signed-off-by: Geliang Tang --- drivers/target/target_core_user.c | 2 +- drivers/target/tcm_fc/tfc_io.c | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 937cebf..d5477c0 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c @@ -194,7 +194,7 @@ static struct tcmu_cmd *tcmu_alloc_cmd(struct se_cmd *se_cmd) static inline void tcmu_flush_dcache_range(void *vaddr, size_t size) { - unsigned long offset = (unsigned long) vaddr & ~PAGE_MASK; + unsigned long offset = offset_in_page(vaddr); size = round_up(size+offset, PAGE_SIZE); vaddr -= offset; diff --git a/drivers/target/tcm_fc/tfc_io.c b/drivers/target/tcm_fc/tfc_io.c index 847c1aa..6f7c65a 100644 --- a/drivers/target/tcm_fc/tfc_io.c +++ b/drivers/target/tcm_fc/tfc_io.c @@ -154,9 +154,9 @@ int ft_queue_data_in(struct se_cmd *se_cmd) BUG_ON(!page); from = kmap_atomic(page + (mem_off >> PAGE_SHIFT)); page_addr = from; - from += mem_off & ~PAGE_MASK; + from += offset_in_page(mem_off); tlen = min(tlen, (size_t)(PAGE_SIZE - - (mem_off & ~PAGE_MASK))); + offset_in_page(mem_off))); memcpy(to, from, tlen); kunmap_atomic(page_addr); to += tlen; @@ -314,9 +314,9 @@ void ft_recv_write_data(struct ft_cmd *cmd, struct fc_frame *fp) to = kmap_atomic(page + (mem_off >> PAGE_SHIFT)); page_addr = to; - to += mem_off & ~PAGE_MASK; + to += offset_in_page(mem_off); tlen = min(tlen, (size_t)(PAGE_SIZE - - (mem_off & ~PAGE_MASK))); + offset_in_page(mem_off))); memcpy(to, from, tlen); kunmap_atomic(page_addr); -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/