Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2549169imu; Thu, 29 Nov 2018 06:44:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/UQuDlqu7G0fubX9jI0JoGYItt0MwWfXg7p8UE/Dui4RjysKXIGZnqiadRJxGRj9LnAXoAc X-Received: by 2002:a17:902:bb98:: with SMTP id m24mr1700994pls.71.1543502686533; Thu, 29 Nov 2018 06:44:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543502686; cv=none; d=google.com; s=arc-20160816; b=sn31iP0uZw/JXcV6vR4zC9iMk8/qFXMoy+xHGMkrVtvTp1aziG9dgezjaJlzPldiMb YrJOvYdKNN8XNTTKmx6jqiaXiLVcco629KxCk3bDyUHqyxrs4w0xs1+HcA0NjDUSO3as LbE/Ofxlz4LXaXN86zO7I2DdNGzZO5OHqc6hX378lrpa1o1g/eDOE57kJ9X5kre5IEpM NbtgnyVHUYZ7qcxC+q1l8VjEKIvBiQYqCbkKiFiztMalsHEvBc/dALks+gjmnOToVAsT RGPCbCiU/7VlNE3Ye5D3ClV43Vy7/9SLAof6kKamvp/ySSEzBktmLw0e7Do3ZhwOSEw1 pbcw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=cBq7eG8tKizxp2XmG8rcRPCZ81p5cfYknd0CBmXioL4=; b=ZwFPbPtZWmHxQ9hs6FrFdsN77dGyMDDJ2S12Xvkrg3b3FtFAbFI7xnqniEFJHPk1Ob dKb/OKUYuhMWqdE7GHfLUdpY/NwczeeHbLaSxs+O2TNjSmd/sZJBeh3CPwUeLurZcWKs Px3Nb08YikKLmZw1RuWry4jhLAb3c5UETMc3d+KiFYrPNwe1tpyzvLsafD4V59Tg26hA x9T1qsvsEBztTgf0dcyHEuAmAv7U57cNkCIqMvBRpl89R8tBAchD0CuNv9T9eqf/VifC JzySf4o5ZlvjXappYaN2OLaxbZl62xfbp2k27M43FGQ0Q/AR7r/TotI/gKdFLZ5gwzRt 4dKw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=CKCWEtUu; 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 b124si2293062pfg.47.2018.11.29.06.44.31; Thu, 29 Nov 2018 06:44:46 -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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=CKCWEtUu; 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 S2388495AbeK3BsW (ORCPT + 99 others); Thu, 29 Nov 2018 20:48:22 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:44849 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388163AbeK3BsV (ORCPT ); Thu, 29 Nov 2018 20:48:21 -0500 Received: by mail-wr1-f68.google.com with SMTP id z5so2143477wrt.11 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=uaxub0RaJ9fBQY/nPyL/Dty5tnSzeCA2binOf6qFNyKpOVLrQNTH5RFw+seX1U16AG s4wTVP9on/sWqdlNKxX1qH7u9bVtEhXBg7w3JWTugkBGOiQqdjnoo9cM2QYT9uaKFs+o vhp3L9/Uy8/vz13xLXVp6h6XATNQjlNfvZCykVo2JlRuMZVOJRUlaBCZIGQc3911jPe/ C0aKdQ2oQUOpyCNyhWkiYIeiihRzzNCKl6uRs++BjJQZFUpC9nBGHi/E/mXbm8XBeipP a+L0HxaDHMTQhoqJPEX7ANcEaaBMtFV/i8UFwm/uPhyd9jU/HNlLHgacbCw0rCqqbV7X J9pA== X-Gm-Message-State: AA+aEWbCBeSOyUvWY2pxbS7ueDTb1ZlduknvJY67QvfWXRE34M+DMEbq Jb9juNETonETB2P0itK48Uv10w== 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-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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) -- 2.18.1