From patchwork Mon Sep 21 23:44:14 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tadeusz Struk X-Patchwork-Id: 7234571 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 970A59F32B for ; Mon, 21 Sep 2015 23:46:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C09662070B for ; Mon, 21 Sep 2015 23:46:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 980F220680 for ; Mon, 21 Sep 2015 23:46:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757069AbbIUXqM (ORCPT ); Mon, 21 Sep 2015 19:46:12 -0400 Received: from mga03.intel.com ([134.134.136.65]:2832 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756198AbbIUXqM (ORCPT ); Mon, 21 Sep 2015 19:46:12 -0400 Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP; 21 Sep 2015 16:46:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,570,1437462000"; d="scan'208";a="794355648" Received: from tstruk-mobl1.jf.intel.com (HELO [127.0.1.1]) ([134.134.171.157]) by fmsmga001.fm.intel.com with ESMTP; 21 Sep 2015 16:46:06 -0700 Subject: [PATCH v2 1/2] 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: Mon, 21 Sep 2015 16:44:14 -0700 Message-ID: <20150921234414.23782.63763.stgit@tstruk-mobl1> In-Reply-To: <20150921234408.23782.52608.stgit@tstruk-mobl1> References: <20150921234408.23782.52608.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, 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 556ec1e..1ca63bd 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -242,6 +242,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 bafa993..dc71f27 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