crypto: ccree - remove struct cc_cipher_handle
authorGeert Uytterhoeven <geert+renesas@glider.be>
Tue, 11 Feb 2020 18:19:15 +0000 (19:19 +0100)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sat, 22 Feb 2020 01:25:45 +0000 (09:25 +0800)
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 <geert+renesas@glider.be>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/ccree/cc_cipher.c
drivers/crypto/ccree/cc_driver.h

index b020583..d219b5b 100644 (file)
 
 #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;
@@ -1661,36 +1657,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",
@@ -1722,8 +1706,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);
                }
index 4895f12..4790eb5 100644 (file)
@@ -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;