Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp225330imm; Wed, 18 Jul 2018 00:44:31 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcuOOgiToT11+ZOEpmLCa+YkkeskeVzEXm9kEo/uslHjSRsf+Ecwqqv7eCaOCveTXTw6WIL X-Received: by 2002:a62:c819:: with SMTP id z25-v6mr4089966pff.44.1531899871347; Wed, 18 Jul 2018 00:44:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531899871; cv=none; d=google.com; s=arc-20160816; b=dvCVx313ms/aH3ZDGb1dOgWm+RujG11g/mNWo3bbT+5480e7/Ja8ckFsBgcuwVk6MB f4Auq4NCG93E3DCxvVVTaA2UIOsedU/qa/cqE14RfIxMOe/kKIvpqBpURWKubZAX2CHN VtG/bTD7ziCZp8v5OLBXAhzn2KYVBWjosPgIv+ZNyDBKkP1S9iiA0Vm88Ex9VIEvT+5c eFauAOW4xtTPUBmmKtowWkIj+cJNkNDafa9dab+OUHOxD1CfUDlgkdyopkiuYD6iVErZ jIFmzTQsIKFb/EuXCd9/onPfENIa8Qf1IEM1Z0palZCpOPWuT+z/g1uWyF7AXbc6I9kx hS/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:arc-authentication-results; bh=xcTNwpR2BbZ/zHESTmcf/fidv1PbZipAZoxAnhMa4To=; b=eEzhsZSpHf8N/AcvjoS7SQpw017tz6cNPVnK0fmVzP1Vos+x4ko1jtI+mFERfJwTOa 3n61pX3pcVeUeES34PuqCNtrIpTo8FoWuQiZtQ+pkJUN1cS0/rVForAY8IOaycxR5Qce vsyglJ8rMdQufhZ35OncvzfUpfrHwFMowToKYxqxDA/zC6FZXGdNgkygeMk2RfuuGJWk OIuEXCXC/c1s/j0VrfmvrN5O5LmNIK/O3WnWgNjEpMDZhdjFID9sX18TEjuMb0ccrTx2 6fCtA7pRgxE9I0aVJf1ZSwSx5IlJUvQrjSVhC9o47npcz74Mgm1HZYS3c3aYR76h7mcj +itw== ARC-Authentication-Results: i=1; mx.google.com; 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 y62-v6si2918645pfd.254.2018.07.18.00.44.16; Wed, 18 Jul 2018 00:44:31 -0700 (PDT) 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; 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 S1729677AbeGRITQ (ORCPT + 99 others); Wed, 18 Jul 2018 04:19:16 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:9641 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728861AbeGRITP (ORCPT ); Wed, 18 Jul 2018 04:19:15 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 45CBA3593EA92; Wed, 18 Jul 2018 15:42:28 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS411-HUB.china.huawei.com (10.3.19.211) with Microsoft SMTP Server id 14.3.382.0; Wed, 18 Jul 2018 15:42:21 +0800 From: Xiongfeng Wang To: , , CC: , , , , , Subject: [PATCH 1/5] crypto: api - introduce API to (un)register a array of templates Date: Wed, 18 Jul 2018 15:30:51 +0800 Message-ID: <1531899055-29362-2-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1531899055-29362-1-git-send-email-wangxiongfeng2@huawei.com> References: <1531899055-29362-1-git-send-email-wangxiongfeng2@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.175.102.37] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following patch introduce several crypto templates. To simplify the code, this patch add two APIs to (un)register a array of templates. Signed-off-by: Xiongfeng Wang --- crypto/algapi.c | 27 +++++++++++++++++++++++++++ include/crypto/algapi.h | 2 ++ 2 files changed, 29 insertions(+) diff --git a/crypto/algapi.c b/crypto/algapi.c index c0755cf..08c29e6 100644 --- a/crypto/algapi.c +++ b/crypto/algapi.c @@ -485,6 +485,24 @@ int crypto_register_template(struct crypto_template *tmpl) } EXPORT_SYMBOL_GPL(crypto_register_template); +int crypto_register_template_array(struct crypto_template *tmpl, int num) +{ + int i, err; + + for (i = 0; i < num; i++) { + err = crypto_register_template(&tmpl[i]); + if (err) + goto out; + } + return 0; + +out: + for (i -= 1; i >= 0; i--) + crypto_unregister_template(&tmpl[i]); + return err; +} +EXPORT_SYMBOL_GPL(crypto_register_template_array); + void crypto_unregister_template(struct crypto_template *tmpl) { struct crypto_instance *inst; @@ -514,6 +532,15 @@ void crypto_unregister_template(struct crypto_template *tmpl) } EXPORT_SYMBOL_GPL(crypto_unregister_template); +void crypto_unregister_template_array(struct crypto_template *tmpl, int num) +{ + int i; + + for (i = 0; i < num; i++) + crypto_unregister_template(&tmpl[i]); +} +EXPORT_SYMBOL_GPL(crypto_unregister_template_array); + static struct crypto_template *__crypto_lookup_template(const char *name) { struct crypto_template *q, *tmpl = NULL; diff --git a/include/crypto/algapi.h b/include/crypto/algapi.h index bd5e8cc..14bfbe31 100644 --- a/include/crypto/algapi.h +++ b/include/crypto/algapi.h @@ -141,7 +141,9 @@ struct ablkcipher_walk { void crypto_mod_put(struct crypto_alg *alg); int crypto_register_template(struct crypto_template *tmpl); +int crypto_register_template_array(struct crypto_template *tmpl, int num); void crypto_unregister_template(struct crypto_template *tmpl); +void crypto_unregister_template_array(struct crypto_template *tmpl, int num); struct crypto_template *crypto_lookup_template(const char *name); int crypto_register_instance(struct crypto_template *tmpl, -- 1.7.12.4