Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1681959imu; Thu, 17 Jan 2019 01:19:47 -0800 (PST) X-Google-Smtp-Source: ALg8bN6GapkytdlriW46UNuWvh1hdXaqXDpuvCIvWaHJw8A8MOwxu/mX+h8miYXrH5DusQFfTF55 X-Received: by 2002:a63:f109:: with SMTP id f9mr12609600pgi.286.1547716787716; Thu, 17 Jan 2019 01:19:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547716787; cv=none; d=google.com; s=arc-20160816; b=AaptYeSe3v8u+Bawe5cr+uDfZEQawnnl4vqtDf+aSQ/iWCnc/1r8M9W0qAUE20uEcx 8WHF8LD055aqCjYVQhxrRfK3ED5MKXLYmFCTP8e0NtDlC89gXFNfzT2/CNZEbcTn9pWm et82VwxByekDWF6w3dQpq8GuGFJSaKzQS2sYcfwn0k7hxmDsFREf9OibcFYX+5k4sOwj LiQqBD41EsQ0KCyl+OFzhpNiv3fDWA1D/ZWFXIJ8U9LQplGWP2ufAjfr2QSmb3qCsumI 0r80GsFFh33hRF8obyQ7IJtU0Sm0SvFg9AvzSOilN4YkXLcoM0e1bDadoQBvUiKvN5ZE Z6BA== 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; bh=ApAHNjZkvZHc7EamAscFR9BIJF6ZDmW/1eoyoXVUBPk=; b=WTG3rDiVL3tfkbC5l1zm2bDMnovdfzPFOp8xedpnV5kRNAPHTP0nZuxNtsfjyV2nwi mSKIqIugKnO5GpMOk2YlIeF4zif+jJQfT7Gh6yROUMjDT/6yXuW98/vXMTKRtngVCjz7 JNQUocu+Nk5mGIkmID9qGG/9cfTMByeTJEwCtdQANPfjjwK+Uu1I9Xiq+/jGNilEUbJn 0yNu3mNIB4MfEcBFNDi+ZahHFjZyjR76VsMkmnywXyNpojoVxfbpzOlt4yG4OXc3K9eq rH/ayPyobsevhGWLxcKZ5XkjCeM/wJkG05H+fmTh33U3kz8+iEAaNtfoJ2Sm2M3rn/xG YDzg== 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 d4si1109844pfa.150.2019.01.17.01.19.32; Thu, 17 Jan 2019 01:19:47 -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; 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 S1728888AbfAQGs4 (ORCPT + 99 others); Thu, 17 Jan 2019 01:48:56 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:2249 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728333AbfAQGsw (ORCPT ); Thu, 17 Jan 2019 01:48:52 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 768493DCC9A833AAB1F2; Thu, 17 Jan 2019 14:48:50 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS407-HUB.china.huawei.com (10.3.19.207) with Microsoft SMTP Server id 14.3.408.0; Thu, 17 Jan 2019 14:48:44 +0800 From: Xiongfeng Wang To: , , CC: , , , , , Subject: [PATCH V2 4/5] crypto: ctr - use template array registering API to simplify the code Date: Thu, 17 Jan 2019 14:48:02 +0800 Message-ID: <1547707683-45878-5-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1547707683-45878-1-git-send-email-wangxiongfeng2@huawei.com> References: <1547707683-45878-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 Use crypto template array registering API to simplify the code. Signed-off-by: Xiongfeng Wang --- crypto/ctr.c | 43 +++++++++++++++---------------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/crypto/ctr.c b/crypto/ctr.c index 4c743a9..d9f9d65 100644 --- a/crypto/ctr.c +++ b/crypto/ctr.c @@ -171,12 +171,6 @@ static int crypto_ctr_create(struct crypto_template *tmpl, struct rtattr **tb) return err; } -static struct crypto_template crypto_ctr_tmpl = { - .name = "ctr", - .create = crypto_ctr_create, - .module = THIS_MODULE, -}; - static int crypto_rfc3686_setkey(struct crypto_skcipher *parent, const u8 *key, unsigned int keylen) { @@ -366,36 +360,29 @@ static int crypto_rfc3686_create(struct crypto_template *tmpl, goto out; } -static struct crypto_template crypto_rfc3686_tmpl = { - .name = "rfc3686", - .create = crypto_rfc3686_create, - .module = THIS_MODULE, +static struct crypto_template crypto_ctr_tmpls[] = { + { + .name = "ctr", + .create = crypto_ctr_create, + .module = THIS_MODULE, + }, { + .name = "rfc3686", + .create = crypto_rfc3686_create, + .module = THIS_MODULE, + }, }; + static int __init crypto_ctr_module_init(void) { - int err; - - err = crypto_register_template(&crypto_ctr_tmpl); - if (err) - goto out; - - err = crypto_register_template(&crypto_rfc3686_tmpl); - if (err) - goto out_drop_ctr; - -out: - return err; - -out_drop_ctr: - crypto_unregister_template(&crypto_ctr_tmpl); - goto out; + return crypto_register_templates(crypto_ctr_tmpls, + ARRAY_SIZE(crypto_ctr_tmpls)); } static void __exit crypto_ctr_module_exit(void) { - crypto_unregister_template(&crypto_rfc3686_tmpl); - crypto_unregister_template(&crypto_ctr_tmpl); + crypto_unregister_templates(crypto_ctr_tmpls, + ARRAY_SIZE(crypto_ctr_tmpls)); } module_init(crypto_ctr_module_init); -- 1.7.12.4