From patchwork Sat Oct 3 02:34:59 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geliang Tang X-Patchwork-Id: 7319971 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 04C7C9F302 for ; Sat, 3 Oct 2015 02:37:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 25D1A20855 for ; Sat, 3 Oct 2015 02:37:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4B98320856 for ; Sat, 3 Oct 2015 02:37:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751562AbbJCCg6 (ORCPT ); Fri, 2 Oct 2015 22:36:58 -0400 Received: from m50-132.163.com ([123.125.50.132]:35755 "EHLO m50-132.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751513AbbJCCg6 (ORCPT ); Fri, 2 Oct 2015 22:36:58 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=163.com; s=s110527; h=From:Subject:Date:Message-Id; bh=bENxDkPR1T/2RHKLNs uUJ8wuUSgYdM2lY1UOX7UDZkw=; b=ik9oDq+IhiZP/zBopeYqAwh7D77LqItU9I jYDyzWN5vgPvVgDlSLN8cFAkZevQsNVjYIei7MNcpWve/ZMmZ+pS9PNFWsM7o1Ua 5csrR9V06s9Ub8T2Wc+q9EQBJtehorkAZnTjjSuJoAws9gxMjXy7BaCaMqe84U35 6rIi0+I2c= Received: from localhost (unknown [116.77.141.25]) by smtp2 (Coremail) with SMTP id DNGowEC5H2vaPg9WF2cCBA--.57523S3; Sat, 03 Oct 2015 10:35:07 +0800 (CST) From: Geliang Tang To: Mike Marciniszyn , Doug Ledford , Sean Hefty , Hal Rosenstock , Greg Kroah-Hartman Cc: Geliang Tang , linux-rdma@vger.kernel.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org Subject: [PATCH] IB/hfi1: use offset_in_page macro Date: Sat, 3 Oct 2015 10:34:59 +0800 Message-Id: <20ad2117b3ba065a6e00e80f3c27682f70a53c6f.1443839524.git.geliangtang@163.com> X-Mailer: git-send-email 2.5.0 X-CM-TRANSID: DNGowEC5H2vaPg9WF2cCBA--.57523S3 X-Coremail-Antispam: 1Uf129KBjvJXoWxJrWfXF1xCFyxZFykuF17ZFb_yoW8Wr1xpa y5Ja909rZ7ta1fGF1DCa18XFy7C3Z7uryrua4UKwsYvFnavFZYq3WSyayxurnrAFWxArn0 qF4jgFWUu3WkJwUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07U75rxUUUUU= X-Originating-IP: [116.77.141.25] X-CM-SenderInfo: 5jhoxtpqjwt0rj6rljoofrz/1tbiMByImVWBRkSCFAAAs9 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_HI,T_DKIM_INVALID,T_RP_MATCHES_RCVD, 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 --- drivers/staging/rdma/hfi1/file_ops.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/staging/rdma/hfi1/file_ops.c b/drivers/staging/rdma/hfi1/file_ops.c index 9a77221..7d28680 100644 --- a/drivers/staging/rdma/hfi1/file_ops.c +++ b/drivers/staging/rdma/hfi1/file_ops.c @@ -168,7 +168,7 @@ enum mmap_types { HFI1_MMAP_TOKEN_SET(TYPE, type) | \ HFI1_MMAP_TOKEN_SET(CTXT, ctxt) | \ HFI1_MMAP_TOKEN_SET(SUBCTXT, subctxt) | \ - HFI1_MMAP_TOKEN_SET(OFFSET, ((unsigned long)addr & ~PAGE_MASK))) + HFI1_MMAP_TOKEN_SET(OFFSET, (offset_in_page(addr)))) #define EXP_TID_SET(field, value) \ (((value) & EXP_TID_TID##field##_MASK) << \ @@ -1335,9 +1335,9 @@ static int get_base_info(struct file *fp, void __user *ubase, __u32 len) */ binfo.user_regbase = HFI1_MMAP_TOKEN(UREGS, uctxt->ctxt, subctxt_fp(fp), 0); - offset = ((((uctxt->ctxt - dd->first_user_ctxt) * + offset = offset_in_page((((uctxt->ctxt - dd->first_user_ctxt) * HFI1_MAX_SHARED_CTXTS) + subctxt_fp(fp)) * - sizeof(*dd->events)) & ~PAGE_MASK; + sizeof(*dd->events)); binfo.events_bufbase = HFI1_MMAP_TOKEN(EVENTS, uctxt->ctxt, subctxt_fp(fp), offset); @@ -1573,7 +1573,7 @@ static int exp_tid_setup(struct file *fp, struct hfi1_tid_info *tinfo) vaddr = tinfo->vaddr; - if (vaddr & ~PAGE_MASK) { + if (offset_in_page(vaddr)) { ret = -EINVAL; goto bail; }