From patchwork Wed Nov 25 13:49:27 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 7699591 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id AB9A0BF90C for ; Wed, 25 Nov 2015 13:50:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id CAFFC208E5 for ; Wed, 25 Nov 2015 13:50:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E48AC208E4 for ; Wed, 25 Nov 2015 13:50:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754101AbbKYNuR (ORCPT ); Wed, 25 Nov 2015 08:50:17 -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 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=2p/K7bKveMF37Et+aW t9hgLgw4Zo9FBJvEU6MnxJmZs=; b=Ec6oQYc8v/Ozja2tJR/rSH49d5Z0vNKcDP rCplCTCE0UOj+d9y2AfGKWIsYkbc7lZti/NuGv3N+ZhGAsDu1sZlT4sPQdM5YQFr 4MmNkSebE5XQlf4FAgvA6gvz5BBbHz/akfarPcqDmBaf5CrN+FUDuPunjjnIRxrr RYvlcnoJQ= Received: from localhost (unknown [116.77.146.156]) by smtp4 (Coremail) with SMTP id DtGowECZOUhpvFVWcbYoAw--.2110S3; Wed, 25 Nov 2015 21:49:31 +0800 (CST) 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-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Use offset_in_page macro instead of (addr & ~PAGE_MASK). Signed-off-by: Geliang Tang Reviewed-by: Sagi Grimberg Reviewed-by: Johannes Thumshirn --- 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);