From patchwork Wed Sep 9 16:15:26 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tadeusz Struk X-Patchwork-Id: 7147401 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: X-Original-To: patchwork-linux-crypto@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 8BF6A9F1D3 for ; Wed, 9 Sep 2015 16:17:17 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id BDB0820999 for ; Wed, 9 Sep 2015 16:17:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D0C8E20998 for ; Wed, 9 Sep 2015 16:17:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753709AbbIIQRP (ORCPT ); Wed, 9 Sep 2015 12:17:15 -0400 Received: from mga11.intel.com ([192.55.52.93]:47571 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753570AbbIIQRO (ORCPT ); Wed, 9 Sep 2015 12:17:14 -0400 Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga102.fm.intel.com with ESMTP; 09 Sep 2015 09:17:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,497,1437462000"; d="scan'208";a="800976404" Received: from sramak2x-mobl.amr.corp.intel.com (HELO [127.0.1.1]) ([10.254.188.81]) by orsmga002.jf.intel.com with ESMTP; 09 Sep 2015 09:17:07 -0700 Subject: [PATCH 5/8] lib/scatterlist: Add sg_len helper From: Tadeusz Struk To: herbert@gondor.apana.org.au Cc: linux-crypto@vger.kernel.org, qat-linux@intel.com, tadeusz.struk@intel.com Date: Wed, 09 Sep 2015 09:15:26 -0700 Message-ID: <20150909161526.2828.55032.stgit@tstruk-mobl1> In-Reply-To: <20150909161454.2828.70445.stgit@tstruk-mobl1> References: <20150909161454.2828.70445.stgit@tstruk-mobl1> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable 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 Add sg_len function which returns the total number of bytes in sg. Signed-off-by: Tadeusz Struk --- include/linux/scatterlist.h | 1 + lib/scatterlist.c | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+) -- To unsubscribe from this list: send the line "unsubscribe linux-crypto" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 9b1ef0c..7c82fc1 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -246,6 +246,7 @@ static inline void *sg_virt(struct scatterlist *sg) } int sg_nents(struct scatterlist *sg); +int sg_len(struct scatterlist *sg); int sg_nents_for_len(struct scatterlist *sg, u64 len); struct scatterlist *sg_next(struct scatterlist *); struct scatterlist *sg_last(struct scatterlist *s, unsigned int); diff --git a/lib/scatterlist.c b/lib/scatterlist.c index d105a9f..71324bb 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c @@ -57,6 +57,24 @@ int sg_nents(struct scatterlist *sg) EXPORT_SYMBOL(sg_nents); /** + * sg_len - return total size of bytes in the scatterlist + * @sg: The scatterlist + * + * Description: + * Allows to know how the total size of bytes in sg, taking into acount + * chaining as well + **/ +int sg_len(struct scatterlist *sg) +{ + int len; + + for (len = 0; sg; sg = sg_next(sg)) + len += sg->length; + return len; +} +EXPORT_SYMBOL(sg_len); + +/** * sg_nents_for_len - return total count of entries in scatterlist * needed to satisfy the supplied length * @sg: The scatterlist