Received: by 10.223.185.116 with SMTP id b49csp428297wrg; Sat, 10 Feb 2018 10:08:24 -0800 (PST) X-Google-Smtp-Source: AH8x226uEt2pZPZnLI3x/O6OJEDbF3vW3xspowEKreXiknAoX5kY6UCWf1/NpNuyMGU8ZklHxI41 X-Received: by 10.99.4.66 with SMTP id 63mr779748pge.93.1518286104101; Sat, 10 Feb 2018 10:08:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518286104; cv=none; d=google.com; s=arc-20160816; b=ULu9SPOo/OUuRTweosV4NyWKYgEiY1fv6YXG0h+8GK/CvfkQVhOliwg9ip+DzEesS2 9K0VZ8zJGXXTVO1aDdyTYHLKNQPRVlOZ3mZNbImugsx9sIshkyTcKBaX34FiLg5dgzi5 6ZZfhj5xPMxbTBdF2d+r+Uiq4RcAVX1pIAue/rM4/DL0s0vQBSDmnb7o1MN+5m0PFPwt sGosOQeK2ITK9YwB1EOqKmNsZlrzezzDVhj4fs/uZTqMr5WyjjZFBDJg9NRFLmHu+2g5 Tr02CaafJ+uCpndmsr7TvyvMpllHF4slHpWsH6nXbRn78ni5hCrMu2KYvYQHoXFfzw8M aaIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=aNhHlXQ0N2G0m00Ebick2hxb595621ELeByw1FgX8lw=; b=nqyqMQZrjd21ZYsoZiosb+43NCP1E8Ajb/qfdjkKmVibV2bhck5LwYmiPa4F2hoheo GV6Jd7fkOs/t9Z77Rf4LMRtPKM7w6ZAGgZ2AHvLSQgsWXG1zPNR0/PgaePlh/c9NK7hm 6I0dQTcARCfgm8BqbU9rcEJ+VOQCTJ/eecBKYL2wGRblYAVE0yWqHX0YH8Tk04H7Ef7A wq48Dm+WUNyoCPk2nhSr4zxt+UES4HDw2KxnBol7D8CoeZucR65Wu1aXsr2eh8J7imRJ MDy1HotmaKPwDy6xff/WbqREHZXWcHa3A4XwTadfZrTihQcunRYPQWy/MOeiwPttbJje dxmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u86si1841751pfa.314.2018.02.10.10.08.10; Sat, 10 Feb 2018 10:08:24 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752100AbeBJSFo (ORCPT + 99 others); Sat, 10 Feb 2018 13:05:44 -0500 Received: from mga11.intel.com ([192.55.52.93]:9474 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751115AbeBJSFn (ORCPT ); Sat, 10 Feb 2018 13:05:43 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Feb 2018 10:05:43 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,490,1511856000"; d="scan'208";a="30422781" Received: from alexey-system-product-name.iil.intel.com ([10.236.193.131]) by orsmga001.jf.intel.com with ESMTP; 10 Feb 2018 10:05:41 -0800 From: Alexey Skidanov To: chris@chris-wilson.co.uk Cc: linux-kernel@vger.kernel.org, Alexey Skidanov Subject: [PATCH] lib/scatterlist: Make sg_page_count() accessible to other modules Date: Sat, 10 Feb 2018 20:06:04 +0200 Message-Id: <1518285964-31657-1-git-send-email-alexey.skidanov@intel.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently, sg_page_count() may be used only inside the scatterlist.c file. However, the same calculation is done outside of scatterlist.c file causing to code duplication. To fix this, we move the sg_page_count() to the scatterlist.h file, making it accessible to other modules. Signed-off-by: Alexey Skidanov --- include/linux/scatterlist.h | 5 +++++ lib/scatterlist.c | 5 ----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index b7c8325..fe28148 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -248,6 +248,11 @@ static inline void *sg_virt(struct scatterlist *sg) return page_address(sg_page(sg)) + sg->offset; } +static inline int sg_page_count(struct scatterlist *sg) +{ + return PAGE_ALIGN(sg->offset + sg->length) >> PAGE_SHIFT; +} + int sg_nents(struct scatterlist *sg); int sg_nents_for_len(struct scatterlist *sg, u64 len); struct scatterlist *sg_next(struct scatterlist *); diff --git a/lib/scatterlist.c b/lib/scatterlist.c index 7c1c55f..4a59131 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c @@ -486,11 +486,6 @@ void __sg_page_iter_start(struct sg_page_iter *piter, } EXPORT_SYMBOL(__sg_page_iter_start); -static int sg_page_count(struct scatterlist *sg) -{ - return PAGE_ALIGN(sg->offset + sg->length) >> PAGE_SHIFT; -} - bool __sg_page_iter_next(struct sg_page_iter *piter) { if (!piter->__nents || !piter->sg) -- 2.7.4