staging: ccree: Use sizeof(variable) in memory allocs
authorSimon Sandström <simon@nikanor.nu>
Sun, 30 Jul 2017 20:29:02 +0000 (22:29 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 16 Aug 2017 22:10:42 +0000 (15:10 -0700)
Fixes 9 checkpatch.pl warnings of type
"Prefer kmalloc(sizeof(variable)...) over kmalloc(sizeof(type)...)"
in staging/ccree.

Signed-off-by: Simon Sandström <simon@nikanor.nu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/ccree/ssi_aead.c
drivers/staging/ccree/ssi_cipher.c
drivers/staging/ccree/ssi_driver.c
drivers/staging/ccree/ssi_hash.c
drivers/staging/ccree/ssi_ivgen.c
drivers/staging/ccree/ssi_request_mgr.c

index f5ca0e35c5d386b069bfc67edd994a74041bc11b..5abe6b24ff8ca2c284cc799fbb38f3a7aef33258 100644 (file)
@@ -2659,7 +2659,7 @@ static struct ssi_crypto_alg *ssi_aead_create_alg(struct ssi_alg_template *templ
        struct ssi_crypto_alg *t_alg;
        struct aead_alg *alg;
 
-       t_alg = kzalloc(sizeof(struct ssi_crypto_alg), GFP_KERNEL);
+       t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL);
        if (!t_alg) {
                SSI_LOG_ERR("failed to allocate t_alg\n");
                return ERR_PTR(-ENOMEM);
@@ -2714,7 +2714,7 @@ int ssi_aead_alloc(struct ssi_drvdata *drvdata)
        int rc = -ENOMEM;
        int alg;
 
-       aead_handle = kmalloc(sizeof(struct ssi_aead_handle), GFP_KERNEL);
+       aead_handle = kmalloc(sizeof(*aead_handle), GFP_KERNEL);
        if (!aead_handle) {
                rc = -ENOMEM;
                goto fail0;
index 6219a92184aa72bb2fe116c6ad4ed329ff402ee9..af9afead7bcbbe248999e248084b9a0a7a727612 100644 (file)
@@ -1218,7 +1218,7 @@ struct ssi_crypto_alg *ssi_ablkcipher_create_alg(struct ssi_alg_template *templa
        struct ssi_crypto_alg *t_alg;
        struct crypto_alg *alg;
 
-       t_alg = kzalloc(sizeof(struct ssi_crypto_alg), GFP_KERNEL);
+       t_alg = kzalloc(sizeof(*t_alg), GFP_KERNEL);
        if (!t_alg) {
                SSI_LOG_ERR("failed to allocate t_alg\n");
                return ERR_PTR(-ENOMEM);
@@ -1279,8 +1279,7 @@ int ssi_ablkcipher_alloc(struct ssi_drvdata *drvdata)
        int rc = -ENOMEM;
        int alg;
 
-       ablkcipher_handle = kmalloc(sizeof(struct ssi_blkcipher_handle),
-                                   GFP_KERNEL);
+       ablkcipher_handle = kmalloc(sizeof(*ablkcipher_handle), GFP_KERNEL);
        if (!ablkcipher_handle)
                return -ENOMEM;
 
index a4ab9ef4baf73723b82b3040571267892a025fae..88b68c81556ca8dd7469d37055f3b0f6f6f641a7 100644 (file)
@@ -223,7 +223,8 @@ static int init_cc_resources(struct platform_device *plat_dev)
        struct resource *req_mem_cc_regs = NULL;
        void __iomem *cc_base = NULL;
        bool irq_registered = false;
-       struct ssi_drvdata *new_drvdata = kzalloc(sizeof(struct ssi_drvdata), GFP_KERNEL);
+       struct ssi_drvdata *new_drvdata = kzalloc(sizeof(*new_drvdata),
+                                                 GFP_KERNEL);
        struct device *dev = &plat_dev->dev;
        struct device_node *np = dev->of_node;
        u32 signature_val;
index 1a405bbadf6d00a6abd26603914ad69593874080..13291aeaf350ba20e26236f4a20eb025f45a5c7e 100644 (file)
@@ -2060,9 +2060,9 @@ ssi_hash_create_alg(struct ssi_hash_template *template, bool keyed)
        struct crypto_alg *alg;
        struct ahash_alg *halg;
 
-       t_crypto_alg = kzalloc(sizeof(struct ssi_hash_alg), GFP_KERNEL);
+       t_crypto_alg = kzalloc(sizeof(*t_crypto_alg), GFP_KERNEL);
        if (!t_crypto_alg) {
-               SSI_LOG_ERR("failed to allocate t_alg\n");
+               SSI_LOG_ERR("failed to allocate t_crypto_alg\n");
                return ERR_PTR(-ENOMEM);
        }
 
@@ -2226,10 +2226,10 @@ int ssi_hash_alloc(struct ssi_drvdata *drvdata)
        int rc = 0;
        int alg;
 
-       hash_handle = kzalloc(sizeof(struct ssi_hash_handle), GFP_KERNEL);
+       hash_handle = kzalloc(sizeof(*hash_handle), GFP_KERNEL);
        if (!hash_handle) {
                SSI_LOG_ERR("kzalloc failed to allocate %zu B\n",
-                           sizeof(struct ssi_hash_handle));
+                           sizeof(*hash_handle));
                rc = -ENOMEM;
                goto fail;
        }
index 86364f81acabc97c4b58363c4cb8491e88479462..b01e03231947d478696ab9620dada728a5c7b690 100644 (file)
@@ -191,10 +191,11 @@ int ssi_ivgen_init(struct ssi_drvdata *drvdata)
        int rc;
 
        /* Allocate "this" context */
-       drvdata->ivgen_handle = kzalloc(sizeof(struct ssi_ivgen_ctx), GFP_KERNEL);
+       drvdata->ivgen_handle = kzalloc(sizeof(*drvdata->ivgen_handle),
+                                       GFP_KERNEL);
        if (!drvdata->ivgen_handle) {
                SSI_LOG_ERR("Not enough memory to allocate IVGEN context "
-                          "(%zu B)\n", sizeof(struct ssi_ivgen_ctx));
+                          "(%zu B)\n", sizeof(*drvdata->ivgen_handle));
                rc = -ENOMEM;
                goto out;
        }
index 2eda82f317d21adcd0a7a6d14e68525e76605531..e5c2f92857f6add54dfa0d9b8aea94783a1f5f1e 100644 (file)
@@ -100,7 +100,7 @@ int request_mgr_init(struct ssi_drvdata *drvdata)
        struct ssi_request_mgr_handle *req_mgr_h;
        int rc = 0;
 
-       req_mgr_h = kzalloc(sizeof(struct ssi_request_mgr_handle), GFP_KERNEL);
+       req_mgr_h = kzalloc(sizeof(*req_mgr_h), GFP_KERNEL);
        if (!req_mgr_h) {
                rc = -ENOMEM;
                goto req_mgr_init_err;