Received: by 10.223.185.116 with SMTP id b49csp4073498wrg; Tue, 13 Feb 2018 12:16:44 -0800 (PST) X-Google-Smtp-Source: AH8x227eInRE97c9aq5bcl9ZXRFQPnXkfEPi9gGrzyVlT1Np2itrR2urIjJcF31Wy7j94NmfdlxO X-Received: by 2002:a17:902:274a:: with SMTP id j10-v6mr2149731plg.107.1518553004041; Tue, 13 Feb 2018 12:16:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518553003; cv=none; d=google.com; s=arc-20160816; b=S+jgoQOp/gVcdbr84dDlT/EQfha/VZyoQUS40vNmJTX36pPacbsXzrbOMcKHH1hRUR i0aPt6qf2mfIxCV1GR4QC7luh3avw0JG5qOaCkSEwS1UguDhryzkC2tZJQkj4/6+iS+h CGjwv3hfY9IISnJfOF/0z3altTWlYU0QW9qeEI99SSQVNy/nQ1MRE9eNOSyTZdlAhewJ j73ZMa2LHrWuAvAjtjBue+ftElqPBYtiU27KokwbKHu3TwE7Q0dHOPx1ayd0wjjme3+5 dbFfZ/Qm4+JtW0Ui2bCDZ/g2CIOXlfQsqzizycMQi6UW29/T0PdUfeOgxeQbacvlk8qO SLDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=4+Bu4UaKHWQTkVUCoAuHkDe6s+u7OJlCtiwhgluiHp0=; b=Oyzt1kZOpmRwWElok5PfEIWQXERT7nmS35HOoae6Y5q5L/ZBlX56kkCFqOpzcGgs8T L1LSqzmMBHWZRrESG/53kqndaZ8GLafUj7hdzLYWnn0ECVIWwGejwR7aVPxQjjctmTIZ Vmvum6lWRw6Ahs1aJ0OLCrjP+XtC/5vHE2U9mhYJDkPSNby/jRvXYAuizoImuMsWhB/A 1td2Pyma1FIRa/5BapilzUub4n8z2BL/FHswgc4itRW/IrYp8vhs4jqEx8RE3BKghBCl fbLhJs334lA47H1L+s9a+IF/WRl+nndx03yottbh5fPrsMZBnYp6uepNaQxOLhTbQLIu EEaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qT+odiyt; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id s67si2165445pgb.64.2018.02.13.12.16.29; Tue, 13 Feb 2018 12:16:43 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=qT+odiyt; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S965702AbeBMUOT (ORCPT + 99 others); Tue, 13 Feb 2018 15:14:19 -0500 Received: from mail-qt0-f195.google.com ([209.85.216.195]:38353 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S965611AbeBMUOR (ORCPT ); Tue, 13 Feb 2018 15:14:17 -0500 Received: by mail-qt0-f195.google.com with SMTP id k13so5062737qtg.5 for ; Tue, 13 Feb 2018 12:14:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=4+Bu4UaKHWQTkVUCoAuHkDe6s+u7OJlCtiwhgluiHp0=; b=qT+odiytSfu3QpsfoMD60XRmPQHfW4ynQB+FW08We/gAzc1h6touUeK+VLn5sAMlF/ JGz/h610PXMHkqeVgwTOgViWXnd5Ga320TShWcSzxDCLY9jmt+edYrxXhGERqWytGqiL HGqwucYS7lfQBQfEiW8A1UMm+FkWg7vEqdq9srlHZ/SnVgdlAmOtATLL1EDo7VdCSehP TkYi8QZj5a/B/taIgVtzYceBYR+8RX4FzhrR/O13a6bUqjjoPyYB7fXqWs9ZP3hDZ/Cd GJ2DZTAsutk56msqUtKT3/dOErGSX+7hog1wKu028lmvvazEtphFo7Iicv1JZHfs8J47 YTOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=4+Bu4UaKHWQTkVUCoAuHkDe6s+u7OJlCtiwhgluiHp0=; b=DruGSwot35I3PRdznT5GODGXZV8F8PW07deYFS0aUZvUnObo7qjAUm4EQuwtsBcpAd 3ARsUcRhRD4FWWbv9+pfsxuPOK5IKEgu0FfecCrPSO2XEboVhFUqXhFsAjef3KV/DFNT vDbdEOCiWgLiacAyIDKa8Lcym+DBGlwZnTCLjjH34sLfob0pKdJ03eqS9oWwNJQ60xi1 vz34JimTEU+h4QaKOeVMrseb7oCgJT3f7WsNqaoOvLy2F+/BY4SeB2TfdiALb2cHOY0J /WaNBP00HUz1bJi4yTcDCz10mA9SWdBmjg3Fdv656ox8pBK+wr5plt80t1ISVyByG7jx +n4g== X-Gm-Message-State: APf1xPBmZh/Go3ohyHifB0W5Yaiykd3Qlc6Mp1xuKl8CB9sWF/rj8tvi JtEYd7z7lSXn7VEcZazPL7H7kXYI243UzNzvxaZwLIyi X-Received: by 10.200.9.86 with SMTP id z22mr3859179qth.87.1518552856626; Tue, 13 Feb 2018 12:14:16 -0800 (PST) MIME-Version: 1.0 Received: by 10.12.195.82 with HTTP; Tue, 13 Feb 2018 12:14:16 -0800 (PST) In-Reply-To: <1518285964-31657-1-git-send-email-alexey.skidanov@intel.com> References: <1518285964-31657-1-git-send-email-alexey.skidanov@intel.com> From: Andy Shevchenko Date: Tue, 13 Feb 2018 22:14:16 +0200 Message-ID: Subject: Re: [PATCH] lib/scatterlist: Make sg_page_count() accessible to other modules To: Alexey Skidanov Cc: chris@chris-wilson.co.uk, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Feb 10, 2018 at 8:06 PM, Alexey Skidanov wrote: > 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. Can you provide an example of potential (or existing?) use case? > > 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 > -- With Best Regards, Andy Shevchenko