Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2762764imu; Thu, 17 Jan 2019 22:02:33 -0800 (PST) X-Google-Smtp-Source: ALg8bN7T3egHic4seqGao/H5DEOiKEkX33AwY+L1dcpOfIfpRq6isLkeo78WKMH/sizT4LbW4fNM X-Received: by 2002:a62:42d4:: with SMTP id h81mr17996875pfd.259.1547791353484; Thu, 17 Jan 2019 22:02:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547791353; cv=none; d=google.com; s=arc-20160816; b=v6Z2Tc3aj42hcRlDCAy9Imx7g0lou4gald28AQ/n4OG/ZhzG4noFaUCWye5lle/jS0 N101IWXY7Nvs3iQxXjsLUix4O2JiQ+6mcz+XrIzEy9JvfoGVx2QjwPEUZtRdqp+AFk75 xMROSpsz7zuyEVWJZV5bKYn95Bb5dwPBQPnrHe8eRUZk0OHUBG+Dg5dLowZLALCG1S0G xZEA+JLwEU1nJOLvAugiJjzjm5MCxTTnR749giF0pAADTPAGslrEHnRoGPd9PAVfOE5l LTJqWTw+akUH2jcBkvbMSQM12+Iwd+njQ3Wp6EAYaclArP8+2nxH/ZLsDd2fydpdwRlS Ly4w== 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=0wueGePRR7tAbK8/HjqihMZBlpl5vQy+xLJ/EXtqGd0=; b=SUPAmfCXxlZH6dj2vFJ5xuMprWKHMhCUjG6QjpnErdB1Ce2NujnQCNHcOmE2OMk4ej Pd1dt3Qv8VesW7kwlFL/hifjqUOlNJzvW0xuIb+wNK/yn+Eg6AJK2f6w7uNYegXPHOjk Q+WyRo3yF+DaXDUs1jjUFp42ljioTr4V/j35nJRy/eI2/s0STxUmAMFZ3coYIFnCJ1hr 6C25xTGy+ZL+moRqIzNH3KsJYWgoilJ8bzKbpAZHlyVxNfV7OnUbzOHmCn4kCaCaBbkw cdbLfgGRclp61plEQ11Jazo7BqHTes3J9CBwFYuSe5xuGFH7GIbIos48oP+qMsA/uSgV xUAg== 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 j91si3851720pld.395.2019.01.17.22.02.15; Thu, 17 Jan 2019 22:02:33 -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 S1727348AbfARF7U (ORCPT + 99 others); Fri, 18 Jan 2019 00:59:20 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2196 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727084AbfARF7C (ORCPT ); Fri, 18 Jan 2019 00:59:02 -0500 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id DC9FB45E15388DB10ECF; Fri, 18 Jan 2019 13:58:59 +0800 (CST) Received: from linux-ibm.site (10.175.102.37) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.408.0; Fri, 18 Jan 2019 13:58:51 +0800 From: Xiongfeng Wang To: , , CC: , , , , , Subject: [PATCH V3 5/5] crypto: chacha20poly1305 - use template array registering API to simplify the code Date: Fri, 18 Jan 2019 13:58:15 +0800 Message-ID: <1547791095-48339-6-git-send-email-wangxiongfeng2@huawei.com> X-Mailer: git-send-email 1.7.12.4 In-Reply-To: <1547791095-48339-1-git-send-email-wangxiongfeng2@huawei.com> References: <1547791095-48339-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 From: Xiongfeng Wang Use crypto template array registering API to simplify the code. Signed-off-by: Xiongfeng Wang Reviewed-by: Eric Biggers --- 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