Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1116201imu; Wed, 16 Jan 2019 13:03:45 -0800 (PST) X-Google-Smtp-Source: ALg8bN6AfHJH3VSJbiEUGdFaqarz7LmmxbCV8T6KgEMqGpV6n2lOLGaN75Gn5IdDi3cQESnO6gQG X-Received: by 2002:a62:7dcb:: with SMTP id y194mr11918583pfc.113.1547672625842; Wed, 16 Jan 2019 13:03:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547672625; cv=none; d=google.com; s=arc-20160816; b=Lo5u2PmjB5Eod7S5GQ4yf21M/NoTYgz2KHOhkHKR0cc0YmN1dIVmlll+/Q5kWKq4p4 nB51IhA+OPoLlj33vKUwuFBj+jdFkO4+2EI6+KRnwkanHyGa2KOvgyYoePSwX9Ju4Cg9 HT8z1xuZQlOpuXH3/kInvUZKHBFxENH9bwRB+EegsX7IDbTjwHAA0wY+yOxkeYBAks0k GrLVvFvZcCPh9rzMz+dMWbu9MM7pOya2J+03cVudZjNfA1q7MrWveyK6zlYwvwI0d93X 1zMgy+Nod7/Bds7CpDPOatJ9pH+rzS33j68kOI/ivqkOf+2sawPMseipPOkgGHXkFM7x cP0g== 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=WnBClmKWE+Vmo/YBtVAwsf4HcBDMtoPKXq4eLqDuw8I=; b=A5KKRCj1zCFs6bBIqdIRrefZH5dXPBU5X/NRljqHCwnIStJ+yQ12NZsazXzOKXnIcL B4K3uo1CJxkl2DrvGgasn1QGNZnY4utOuQxqmsoxLqpQ/tf/G5LM9sq8DzV6f2LLRvK6 Ky2IN47DIzXrGlqb7Xr024JmclLHbQtpaHEcSVpa0pmoZNZCsDEygbSGAvyqDbPYQtcI G3BWwCn1a12N91vJBaNLMxAl9edHexp9iY2T+bY7H5ddAKg1i4bUJKyYUS4fckyxd46o RIySLjYurE8NQ6BnHI9ckT5tY+cylPybvtUklu+0EPkv/3U1o73N2xq9H03TG0uQ00S3 mjQA== 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 n1si7592513pgh.172.2019.01.16.13.03.27; Wed, 16 Jan 2019 13:03:45 -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 S1730465AbfAPCve (ORCPT + 99 others); Tue, 15 Jan 2019 21:51:34 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:17552 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730077AbfAPCvc (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 76A67A81942323EFEBDA; 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 4/5] crypto: ctr - use template array registering API to simplify the code Date: Wed, 16 Jan 2019 10:50:33 +0800 Message-ID: <1547607034-40948-5-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/ctr.c | 46 +++++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 29 deletions(-) diff --git a/crypto/ctr.c b/crypto/ctr.c index 30f3946..ef51099 100644 --- a/crypto/ctr.c +++ b/crypto/ctr.c @@ -248,13 +248,6 @@ static void crypto_ctr_free(struct crypto_instance *inst) kfree(inst); } -static struct crypto_template crypto_ctr_tmpl = { - .name = "ctr", - .alloc = crypto_ctr_alloc, - .free = crypto_ctr_free, - .module = THIS_MODULE, -}; - static int crypto_rfc3686_setkey(struct crypto_skcipher *parent, const u8 *key, unsigned int keylen) { @@ -444,36 +437,31 @@ 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_tmpl[] = { + { + .name = "ctr", + .alloc = crypto_ctr_alloc, + .free = crypto_ctr_free, + .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_tmpl, + ARRAY_SIZE(crypto_ctr_tmpl)); } 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_tmpl, + ARRAY_SIZE(crypto_ctr_tmpl)); } module_init(crypto_ctr_module_init); -- 1.7.12.4