Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1681767imu; Thu, 17 Jan 2019 01:19:34 -0800 (PST) X-Google-Smtp-Source: ALg8bN7lF0miUeCZ80Hnmo0VzrVgCwJSd9Mth0wcaElcUVBjxUJWrMCAGCyujyz3pNjDxe6VAGyA X-Received: by 2002:a63:c64f:: with SMTP id x15mr12549980pgg.16.1547716774910; Thu, 17 Jan 2019 01:19:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547716774; cv=none; d=google.com; s=arc-20160816; b=inGRgKX6l2b+ba2x6jEY8vzuBjvAOZ8KRJEsjGbrua03g+bvlkqVuC1pCxo1V/KPot m/BliPnddgqki83jGn2xitXNzQeHmNFtsjotw05Ko0APoYOZHkUCBg8csfZNLKolxFJ9 Q0lidMpuwN++CECNJMvjyrHZtu/r6G42AtC+JVHjTtRvHVtDeG1QMbCC50s+s3dDPPwc qiL+2D1kGD6+sn2Wd9y9IfdzatatT2nFjaZPyw+ZSe9RI6n7lm33lFUNkjX1yLeT/A9F xq9HReoIdMe/QVQEQY7+WLTyrhhjcvhubNyAkHwJIBoNsVtVEZ4/PNqqfNXyhJwd+ias stYA== 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=PRloW5zQrcxE7y7C+qT+3w4h1EOYkdPJfi3IhiWS/3o=; b=a5ubzYPAY3CuLKom84juCPp5hUyu86caCHgko9a5x2gWylZovGtybkrs/2PMaAYuAA nBycvFEX/T1EwQXROAsYK3zSEjKSt1MzYjZ6IObnrmXz1mYdpX/d886sILDYFRi/HU9o AyJyXSfaTcIUEgdGVgTvtvlLvlwAher/0poUjwg0AfFC/nluOXdO3nTrCMkJGTOt34Yi yMy6ZmOVDqp4omMscrfS9lNDBcbHnY0uTz0G40hVWDCer3psAJvuDazK/4NfpNjGGPRm A7EeqWp+gt+qiTGONKRPsIsxqVfSIa4YvTzvv4pAi6abh1y8KirF3cs9tUArfy3LZc9c 8Pzg== 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 28si965642pgz.593.2019.01.17.01.19.18; Thu, 17 Jan 2019 01:19:34 -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 S1729012AbfAQGtA (ORCPT + 99 others); Thu, 17 Jan 2019 01:49:00 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:58994 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1728906AbfAQGs5 (ORCPT ); Thu, 17 Jan 2019 01:48:57 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 7BC7D42763699AB628D2; Thu, 17 Jan 2019 14:48:55 +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:45 +0800 From: Xiongfeng Wang To: , , CC: , , , , , Subject: [PATCH V2 5/5] crypto: chacha20poly1305 - use template array registering API to simplify the code Date: Thu, 17 Jan 2019 14:48:03 +0800 Message-ID: <1547707683-45878-6-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/chacha20poly1305.c | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/crypto/chacha20poly1305.c b/crypto/chacha20poly1305.c index fef1144..ed2e12e 100644 --- a/crypto/chacha20poly1305.c +++ b/crypto/chacha20poly1305.c @@ -701,37 +701,28 @@ static int rfc7539esp_create(struct crypto_template *tmpl, struct rtattr **tb) return chachapoly_create(tmpl, tb, "rfc7539esp", 8); } -static struct crypto_template rfc7539_tmpl = { - .name = "rfc7539", - .create = rfc7539_create, - .module = THIS_MODULE, -}; - -static struct crypto_template rfc7539esp_tmpl = { - .name = "rfc7539esp", - .create = rfc7539esp_create, - .module = THIS_MODULE, +static struct crypto_template rfc7539_tmpls[] = { + { + .name = "rfc7539", + .create = rfc7539_create, + .module = THIS_MODULE, + }, { + .name = "rfc7539esp", + .create = rfc7539esp_create, + .module = THIS_MODULE, + }, }; static int __init chacha20poly1305_module_init(void) { - int err; - - err = crypto_register_template(&rfc7539_tmpl); - if (err) - return err; - - err = crypto_register_template(&rfc7539esp_tmpl); - if (err) - crypto_unregister_template(&rfc7539_tmpl); - - return err; + return crypto_register_templates(rfc7539_tmpls, + ARRAY_SIZE(rfc7539_tmpls)); } static void __exit chacha20poly1305_module_exit(void) { - crypto_unregister_template(&rfc7539esp_tmpl); - crypto_unregister_template(&rfc7539_tmpl); + crypto_unregister_templates(rfc7539_tmpls, + ARRAY_SIZE(rfc7539_tmpls)); } module_init(chacha20poly1305_module_init); -- 1.7.12.4