Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5325704ybv; Tue, 11 Feb 2020 13:33:24 -0800 (PST) X-Google-Smtp-Source: APXvYqxYEp9icU+FjvkchzrjD0Cc11af843WTK4G21Umx5DMkR6B9DdQ6Gv0UdGB+zJp4ekj4JC/ X-Received: by 2002:a9d:7b50:: with SMTP id f16mr6888747oto.18.1581456804709; Tue, 11 Feb 2020 13:33:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581456804; cv=none; d=google.com; s=arc-20160816; b=RblymonGN+QPH5ObbPDV+v+gY2ulLBQZinhmz3rzTkOaRQTh1BABMJEoBTcEjRtrQs gPtQxk0DLr4jrrkDemE31ynlu7ZCteqctur+nWzQgI/2yVDJC37dDC5rqcjH2ftVVSRn a8sSvCCi0iFS3vQtHYceD61bn7ltEKW0d0/ewa1R5OtKg5t8eShiife54GzSg/Bm7w/G PNOLF3weq9HXCVCvT7gLqPv64gCcU3GCALq4b7GBabS5Mob07Y8JAE/hG88Ap30GzwuU nprPVlLjTGWMlKDKnrnIn3qMFiShLIEZDo6CUDDKt2hhj8y42frleFGizRpM3fLdUPtm xyXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=zltRXkj4JBm24DGAjQ4/eXh5M+4ykeYiD0CwhVPz0wA=; b=UWar7yduEJQJ5mEe5A1G+2KUN2pWdlMNmLBvjHqJTwkGVZPhUSx4UXRupl/zBZlzWK fcMuIEf30DgEp0ZKzI/mlOUvviBvMXmIjh552pj3zwGauRLRNaZv42reagzFfVBqGSG4 uAtQ3MQJt6rUKZLDCdHkbHcCyyo13jY/OC+bMlwwuJ/0Nhdr/nXvZ0RXBJmtlYuQpBFD TJYF4VTMGmFuu9ulss2SOtOeUDK2k81tQoWrc6om9Ec/s2vzCVAJQfS1YjRymaBuG//Z 87bnd0YTcvpFwK9BPjLh6JWIfDVfnFg+fye6oxydTlt7f2fDwybrq33PRHI3XmNPqTra 7B0g== 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 13si2286450oiy.28.2020.02.11.13.33.13; Tue, 11 Feb 2020 13:33:24 -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 S1731215AbgBKSTw (ORCPT + 99 others); Tue, 11 Feb 2020 13:19:52 -0500 Received: from xavier.telenet-ops.be ([195.130.132.52]:45478 "EHLO xavier.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730025AbgBKSTe (ORCPT ); Tue, 11 Feb 2020 13:19:34 -0500 Received: from ramsan ([84.195.182.253]) by xavier.telenet-ops.be with bizsmtp id 1WKV2200a5USYZQ01WKWwU; Tue, 11 Feb 2020 19:19:31 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1j1a8A-0002of-3F; Tue, 11 Feb 2020 19:19:30 +0100 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1j1a8A-0003z5-1I; Tue, 11 Feb 2020 19:19:30 +0100 From: Geert Uytterhoeven To: Gilad Ben-Yossef , Herbert Xu , "David S . Miller" Cc: Greg Kroah-Hartman , "Rafael J . Wysocki" , linux-crypto@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 21/34] crypto: ccree - remove struct cc_cipher_handle Date: Tue, 11 Feb 2020 19:19:15 +0100 Message-Id: <20200211181928.15178-22-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200211181928.15178-1-geert+renesas@glider.be> References: <20200211181928.15178-1-geert+renesas@glider.be> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The cc_cipher_handle structure contains only a single member, and only one instance exists. Simplify the code and reduce memory consumption by moving this member to struct cc_drvdata. Signed-off-by: Geert Uytterhoeven --- v2: - New. drivers/crypto/ccree/cc_cipher.c | 33 ++++++++------------------------ drivers/crypto/ccree/cc_driver.h | 2 +- 2 files changed, 9 insertions(+), 26 deletions(-) diff --git a/drivers/crypto/ccree/cc_cipher.c b/drivers/crypto/ccree/cc_cipher.c index 1c7ced65008bc311..a1430d669a584a85 100644 --- a/drivers/crypto/ccree/cc_cipher.c +++ b/drivers/crypto/ccree/cc_cipher.c @@ -20,10 +20,6 @@ #define template_skcipher template_u.skcipher -struct cc_cipher_handle { - struct list_head alg_list; -}; - struct cc_user_key_info { u8 *key; dma_addr_t key_dma_addr; @@ -1669,36 +1665,24 @@ static struct cc_crypto_alg *cc_create_alg(const struct cc_alg_template *tmpl, int cc_cipher_free(struct cc_drvdata *drvdata) { struct cc_crypto_alg *t_alg, *n; - struct cc_cipher_handle *cipher_handle = drvdata->cipher_handle; - - if (cipher_handle) { - /* Remove registered algs */ - list_for_each_entry_safe(t_alg, n, &cipher_handle->alg_list, - entry) { - crypto_unregister_skcipher(&t_alg->skcipher_alg); - list_del(&t_alg->entry); - kfree(t_alg); - } - kfree(cipher_handle); - drvdata->cipher_handle = NULL; + + /* Remove registered algs */ + list_for_each_entry_safe(t_alg, n, &drvdata->alg_list, entry) { + crypto_unregister_skcipher(&t_alg->skcipher_alg); + list_del(&t_alg->entry); + kfree(t_alg); } return 0; } int cc_cipher_alloc(struct cc_drvdata *drvdata) { - struct cc_cipher_handle *cipher_handle; struct cc_crypto_alg *t_alg; struct device *dev = drvdata_to_dev(drvdata); int rc = -ENOMEM; int alg; - cipher_handle = kmalloc(sizeof(*cipher_handle), GFP_KERNEL); - if (!cipher_handle) - return -ENOMEM; - - INIT_LIST_HEAD(&cipher_handle->alg_list); - drvdata->cipher_handle = cipher_handle; + INIT_LIST_HEAD(&drvdata->alg_list); /* Linux crypto */ dev_dbg(dev, "Number of algorithms = %zu\n", @@ -1730,8 +1714,7 @@ int cc_cipher_alloc(struct cc_drvdata *drvdata) kfree(t_alg); goto fail0; } else { - list_add_tail(&t_alg->entry, - &cipher_handle->alg_list); + list_add_tail(&t_alg->entry, &drvdata->alg_list); dev_dbg(dev, "Registered %s\n", t_alg->skcipher_alg.base.cra_driver_name); } diff --git a/drivers/crypto/ccree/cc_driver.h b/drivers/crypto/ccree/cc_driver.h index 4895f124d2b83fb1..4790eb5cb8bdac3c 100644 --- a/drivers/crypto/ccree/cc_driver.h +++ b/drivers/crypto/ccree/cc_driver.h @@ -141,7 +141,7 @@ struct cc_drvdata { struct platform_device *plat_dev; u32 mlli_sram_addr; struct dma_pool *mlli_buffs_pool; - void *cipher_handle; + struct list_head alg_list; void *hash_handle; void *aead_handle; void *request_mgr_handle; -- 2.17.1