Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp833752imu; Wed, 16 Jan 2019 08:18:43 -0800 (PST) X-Google-Smtp-Source: ALg8bN7+vWf3ldDBwBOoJeUmWbuSYZmQgO3m12+lNs/waGKGy7vIKOOUQydexU393jQPIIDCS99S X-Received: by 2002:aa7:8608:: with SMTP id p8mr10698263pfn.125.1547655523919; Wed, 16 Jan 2019 08:18:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547655523; cv=none; d=google.com; s=arc-20160816; b=q+a8bw+MGCqsix3Je4xTtmlSCOhnxv6wqKo4TG44Y5aMnkKpgh+f65rvvHfDoTMNX4 baKXmG1PTtbo2LSY7HGfrICnR2kwacHS28wje2oSUiZnYA3DbO3CdskdLy2rj2/6+JLN 9Cn8Fta3z5KiEU7DhzVY7wh9mN73fnSiU+4jEKeZFIZ7Fit2cQRm4H2gUbV0grFG9REU keB1sBOXC6enKYp8tJov7o/bKFwZgXA/DjBGGj4Us1T6nGWggKB8bIIhW6pKKmORf5Ta 6CZ+ehz28F3kc8SEA9rO9LMwWPwZca4XPmS/oKsMYfzJNoDylXfcNIRrA02Uy4xcr7Kz CluQ== 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=jsXOiNUyVFFhBI/z5IwL7dRENnuA0qj/RpdTmhf5GLw=; b=zHeI3jdq9gLrX6M+w4L8C5H26SDzJ2JAZD2ah7NdkvIr8MxvTLnLh3hBaQ5SrRMuSK ApxKJwO+8uukUA1/JttF+51QGC0TgH5a42UhTtTUdWCgGKxiDx+vapWrNL7pZiE5iuTR tYDoFcvH2vGlIEl6QpNqtWhenlhDC7M0SMLUY8iUBbFounqvWMxgjhSikZV325W5Zhw4 mP/CvsqN6lM7UEZoIvjnpcc0GqJbfsVWRiusNl/eF8WJVamAhaEwqD3UVDhEdFUESI+9 DaXIq2Js/0x/t569p5Azjd+Qh1oiRFKt01E/ud3qLME7ndc+ZOsaksQpn6AAes5O/5wZ qwAg== 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 n33si4405292pgl.336.2019.01.16.08.18.08; Wed, 16 Jan 2019 08:18:43 -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 S1730538AbfAPCvl (ORCPT + 99 others); Tue, 15 Jan 2019 21:51:41 -0500 Received: from szxga06-in.huawei.com ([45.249.212.32]:56336 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730089AbfAPCvc (ORCPT ); Tue, 15 Jan 2019 21:51:32 -0500 Received: from DGGEMS407-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 529956735093987A95DE; Wed, 16 Jan 2019 10:51:20 +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; Wed, 16 Jan 2019 10:51:11 +0800 From: Xiongfeng Wang To: , CC: , , , , , Subject: [PATCH 5/5] crypto: chacha20poly1305 - use template array registering API to simplify the code Date: Wed, 16 Jan 2019 10:50:34 +0800 Message-ID: <1547607034-40948-6-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1547607034-40948-1-git-send-email-wangxiongfeng2@huawei.com> References: <1547607034-40948-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 | 38 +++++++++++++++----------------------- 1 file changed, 15 insertions(+), 23 deletions(-) diff --git a/crypto/chacha20poly1305.c b/crypto/chacha20poly1305.c index fef1144..f5134d3 100644 --- a/crypto/chacha20poly1305.c +++ b/crypto/chacha20poly1305.c @@ -701,37 +701,29 @@ 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_tmpl[] = { + { + .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_tmpl, + ARRAY_SIZE(rfc7539_tmpl)); } static void __exit chacha20poly1305_module_exit(void) { - crypto_unregister_template(&rfc7539esp_tmpl); - crypto_unregister_template(&rfc7539_tmpl); + crypto_unregister_templates(rfc7539_tmpl, + ARRAY_SIZE(rfc7539_tmpl)); } module_init(chacha20poly1305_module_init); -- 1.7.12.4