From patchwork Thu Nov 29 14:42:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corentin LABBE X-Patchwork-Id: 10704673 X-Patchwork-Delegate: herbert@gondor.apana.org.au Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0FB6217F0 for ; Thu, 29 Nov 2018 14:43:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 00EF22F389 for ; Thu, 29 Nov 2018 14:43:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E96272F397; Thu, 29 Nov 2018 14:43:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 891382F389 for ; Thu, 29 Nov 2018 14:43:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387401AbeK3BsV (ORCPT ); Thu, 29 Nov 2018 20:48:21 -0500 Received: from mail-wr1-f67.google.com ([209.85.221.67]:45426 "EHLO mail-wr1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388363AbeK3BsV (ORCPT ); Thu, 29 Nov 2018 20:48:21 -0500 Received: by mail-wr1-f67.google.com with SMTP id v6so2136276wrr.12 for ; Thu, 29 Nov 2018 06:42:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cBq7eG8tKizxp2XmG8rcRPCZ81p5cfYknd0CBmXioL4=; b=CKCWEtUulGPTqfxndJa6Spvt1bYqcvHuF1GuekUmG1k2FwovbsjDMWLhSMM/sr43vS g3EDfAjsgZyo4Qkvu6+3iUF5czfQyKQGbwbjjWL7tQZgVwRFLzSCxrE8y+f3TXrQz1Co od5Y2GL9tgdMbpC/9p7FP/V6x9mjDCwmCBHqZCfkJy+/FeuoZRYP02hhtd9CpeV32DZC 2gAGI3saDZeNQ5i1KdATYn4R52BGXs59GYCyvWyJF+YuMCzuYoKl0iBGYVI0EwL1D5OL VwbSfcW6ekzDSBu2IxTdNBlm22wDWwgGFVPmUuEeCW+RmCQ8HJdvn53NibMD1w+P5Fkr Cxzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cBq7eG8tKizxp2XmG8rcRPCZ81p5cfYknd0CBmXioL4=; b=NZXw1nHf030df7sMP2JpVxcmKyYU7sZSuSHdHvB8L0aQDkEECauaOPgH0kDizV/CB8 VK0YU90FTtJVguVdlQGsP+WAys0/KRj8v7esX/3PbwkDquALStJ186rvn0kxay8E27Xb pU9+EEkB924Lt4Zqam1GsmP3hfmEWuhUZSjoXCL9tFGReBusVMjz2afAi5cg5SsGBwcu 20eDQnYqg2TqHq10xXSwUU4s9FWPZ/hq0Oij/1O8uX+uqI/a8JR0Lh9Dak5BOf506aJL dT5cPMtQx5EFgh2hMUyrOsPPf1mVNWsRwCNgnGOWBkf5UgnXiwDbbrEqBqnREVvJFjdX 8f2Q== X-Gm-Message-State: AA+aEWZpXi7aJpZ2IBKdV4b/72+LWdhLDoF17JAr9zqoD3kuw/AfU1Fp usDdEkv6IvPrIIsJBnSFPrahnbcNzqs= X-Google-Smtp-Source: AFSGD/X/mLfsG7xxvxnr8Ytu3dCXde6ciUbx9ssd4JP3yx1ASSmJU4UhJXgIju5ijW3guvryPklELw== X-Received: by 2002:adf:bb44:: with SMTP id x4mr1728206wrg.24.1543502564809; Thu, 29 Nov 2018 06:42:44 -0800 (PST) Received: from localhost.localdomain ([51.15.160.169]) by smtp.googlemail.com with ESMTPSA id t131sm875406wmt.1.2018.11.29.06.42.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 29 Nov 2018 06:42:44 -0800 (PST) From: Corentin Labbe To: davem@davemloft.net, ebiggers@kernel.org, herbert@gondor.apana.org.au, nhorman@tuxdriver.com Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Corentin Labbe Subject: [PATCH v5 11/11] crypto: crypto_user_stat: Add crypto_stats_init Date: Thu, 29 Nov 2018 14:42:26 +0000 Message-Id: <1543502546-23870-12-git-send-email-clabbe@baylibre.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1543502546-23870-1-git-send-email-clabbe@baylibre.com> References: <1543502546-23870-1-git-send-email-clabbe@baylibre.com> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch add the crypto_stats_init() function. This will permit to remove some ifdef from __crypto_register_alg(). Signed-off-by: Corentin Labbe --- crypto/algapi.c | 10 +++++++--- include/linux/crypto.h | 3 +++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/crypto/algapi.c b/crypto/algapi.c index c0d4f9ef6b0f..8b65ada33e5d 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -258,9 +258,7 @@ static struct crypto_larval *__crypto_register_alg(struct crypto_alg *alg) list_add(&alg->cra_list, &crypto_alg_list); list_add(&larval->alg.cra_list, &crypto_alg_list); -#ifdef CONFIG_CRYPTO_STATS - memset(&alg->stats, 0, sizeof(alg->stats)); -#endif + crypto_stats_init(alg); out: return larval; @@ -1073,6 +1071,12 @@ int crypto_type_has_alg(const char *name, const struct crypto_type *frontend, EXPORT_SYMBOL_GPL(crypto_type_has_alg); #ifdef CONFIG_CRYPTO_STATS +void crypto_stats_init(struct crypto_alg *alg) +{ + memset(&alg->stats, 0, sizeof(alg->stats)); +} +EXPORT_SYMBOL_GPL(crypto_stats_init); + void crypto_stats_get(struct crypto_alg *alg) { crypto_alg_get(alg); diff --git a/include/linux/crypto.h b/include/linux/crypto.h index a2967c1a08b1..9850b41e38ae 100644 --- a/include/linux/crypto.h +++ b/include/linux/crypto.h @@ -614,6 +614,7 @@ struct crypto_alg { } CRYPTO_MINALIGN_ATTR; #ifdef CONFIG_CRYPTO_STATS +void crypto_stats_init(struct crypto_alg *alg); void crypto_stats_get(struct crypto_alg *alg); void crypto_stats_ablkcipher_encrypt(unsigned int nbytes, int ret, struct crypto_alg *alg); void crypto_stats_ablkcipher_decrypt(unsigned int nbytes, int ret, struct crypto_alg *alg); @@ -635,6 +636,8 @@ void crypto_stats_rng_generate(struct crypto_alg *alg, unsigned int dlen, int re void crypto_stats_skcipher_encrypt(unsigned int cryptlen, int ret, struct crypto_alg *alg); void crypto_stats_skcipher_decrypt(unsigned int cryptlen, int ret, struct crypto_alg *alg); #else +static inline void crypto_stats_init(struct crypto_alg *alg) +{} static inline void crypto_stats_get(struct crypto_alg *alg) {} static inline void crypto_stats_ablkcipher_encrypt(unsigned int nbytes, int ret, struct crypto_alg *alg)