Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2760891imu; Thu, 17 Jan 2019 22:00:27 -0800 (PST) X-Google-Smtp-Source: ALg8bN5vKC2mK20J03KgWFl0qHQ1t4GeRCXDJevEUPgiCfdW7CfFXQePqZ7weP9ISZsitHB9sToL X-Received: by 2002:a62:d701:: with SMTP id b1mr17851061pfh.34.1547791227211; Thu, 17 Jan 2019 22:00:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547791227; cv=none; d=google.com; s=arc-20160816; b=nF4FP6i9QOxk+DXIY+HI4C8vsTtljZHY9krxn/d1MwAEu++1yQT5gr8s4IjAEdASAy 3bYmOGUpwWYkuiLrA7cYxsmP2Kv0N+Q1m/TdeGZD79HB/SzgxYRXOv2+PKV7v7qS2c2/ aI7/RDSOyuBmNF/kpMQ6r/1O15zeN+aSlDWZJUUBuWH7V5wEv2LQGUEtHDMw2NXEUGNl kh8/BxuxHxl1qqLGySSJ8dqn5uJpTuvq5IV3cP5tDAyYln/Q5o1G1zHBRW7oCHKosQMf DWBU9nuiCgtv1f9WtFfOjd4D9e+NbniDWiLgJBDKYzQ01CMRA3q/RwTNbrlTNyHju1wp 3/rw== 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=+siS6NINJHEpbQakP0tEADHQ7IxOxmLbe5uLlFU8FNo=; b=ehkFTOpCICRfyv4F+NfJV/7t4kvQHt+syHI9XoH4jgZxRTPPPf8WBK2kVTNWCJZIur 8g7tmEj80m0bkEmtMSc7jMYoO+BEGeKXbogNMZ4YaLkKErh32iS6kErkCFmmcXeFWvNU CECh6x5IMkEcZWC02cRqKvHH1r4aZMLc5zXtpsyqbIvcKd5a8z9u9iY7jquu05c1vXfv aultEa13revnT4wi13Y3nb540V1coljPrtN0kSK/geUkHbkYqCgSLhdT1LlKsTk3sTuw meTXT5GV//dFRbXmbdd5tFzWWSHubq+xau894PNwcT7kAyOBvgTh3Y9uolw2Ml1+hyCF d+OQ== 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 d10si3134587pgf.136.2019.01.17.22.00.11; Thu, 17 Jan 2019 22:00:27 -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 S1727271AbfARF7D (ORCPT + 99 others); Fri, 18 Jan 2019 00:59:03 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:2195 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727237AbfARF7C (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 D71C7E507BD3EF291321; 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 4/5] crypto: ctr - use template array registering API to simplify the code Date: Fri, 18 Jan 2019 13:58:14 +0800 Message-ID: <1547791095-48339-5-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/ctr.c | 42 ++++++++++++++---------------------------- 1 file changed, 14 insertions(+), 28 deletions(-) diff --git a/crypto/ctr.c b/crypto/ctr.c index 4c743a9..ec8f8b6 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,28 @@ 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