crypto: caam - fix sparse warnings
authorHoria Geantă <horia.geanta@nxp.com>
Wed, 9 Nov 2016 08:46:14 +0000 (10:46 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Sun, 13 Nov 2016 09:45:08 +0000 (17:45 +0800)
Fix the following sparse warning (note that endianness issues
are not not addressed in current patch):

drivers/crypto/caam/ctrl.c:388:24: warning: incorrect type in argument 1 (different address spaces)
drivers/crypto/caam/ctrl.c:388:24:    expected void [noderef] <asn:2>*reg
drivers/crypto/caam/ctrl.c:388:24:    got unsigned int *<noident>
drivers/crypto/caam/ctrl.c:390:24: warning: incorrect type in argument 1 (different address spaces)
drivers/crypto/caam/ctrl.c:390:24:    expected void [noderef] <asn:2>*reg
drivers/crypto/caam/ctrl.c:390:24:    got unsigned int *<noident>
drivers/crypto/caam/ctrl.c:548:24: warning: incorrect type in assignment (different address spaces)
drivers/crypto/caam/ctrl.c:548:24:    expected struct caam_ctrl [noderef] <asn:2>*ctrl
drivers/crypto/caam/ctrl.c:548:24:    got struct caam_ctrl *<noident>
drivers/crypto/caam/ctrl.c:550:30: warning: cast removes address space of expression
drivers/crypto/caam/ctrl.c:549:26: warning: incorrect type in assignment (different address spaces)
drivers/crypto/caam/ctrl.c:549:26:    expected struct caam_assurance [noderef] <asn:2>*assure
drivers/crypto/caam/ctrl.c:549:26:    got struct caam_assurance *<noident>
drivers/crypto/caam/ctrl.c:554:28: warning: cast removes address space of expression
drivers/crypto/caam/ctrl.c:553:24: warning: incorrect type in assignment (different address spaces)
drivers/crypto/caam/ctrl.c:553:24:    expected struct caam_deco [noderef] <asn:2>*deco
drivers/crypto/caam/ctrl.c:553:24:    got struct caam_deco *<noident>
drivers/crypto/caam/ctrl.c:634:48: warning: cast removes address space of expression
drivers/crypto/caam/ctrl.c:633:44: warning: incorrect type in assignment (different address spaces)
drivers/crypto/caam/ctrl.c:633:44:    expected struct caam_job_ring [noderef] <asn:2>*<noident>
drivers/crypto/caam/ctrl.c:633:44:    got struct caam_job_ring *<noident>
drivers/crypto/caam/ctrl.c:648:34: warning: cast removes address space of expression
drivers/crypto/caam/ctrl.c:647:30: warning: incorrect type in assignment (different address spaces)
drivers/crypto/caam/ctrl.c:647:30:    expected struct caam_queue_if [noderef] <asn:2>*qi
drivers/crypto/caam/ctrl.c:647:30:    got struct caam_queue_if *<noident>
drivers/crypto/caam/ctrl.c:806:37: warning: incorrect type in assignment (different address spaces)
drivers/crypto/caam/ctrl.c:806:37:    expected void *data
drivers/crypto/caam/ctrl.c:806:37:    got unsigned int [noderef] <asn:2>*
drivers/crypto/caam/ctrl.c:814:38: warning: incorrect type in assignment (different address spaces)
drivers/crypto/caam/ctrl.c:814:38:    expected void *data
drivers/crypto/caam/ctrl.c:814:38:    got unsigned int [noderef] <asn:2>*
drivers/crypto/caam/ctrl.c:822:38: warning: incorrect type in assignment (different address spaces)
drivers/crypto/caam/ctrl.c:822:38:    expected void *data
drivers/crypto/caam/ctrl.c:822:38:    got unsigned int [noderef] <asn:2>*
drivers/crypto/caam/jr.c:492:23: warning: incorrect type in assignment (different address spaces)
drivers/crypto/caam/jr.c:492:23:    expected struct caam_job_ring [noderef] <asn:2>*rregs
drivers/crypto/caam/jr.c:492:23:    got struct caam_job_ring *<noident>
drivers/crypto/caam/caampkc.c:398:35: warning: Using plain integer as NULL pointer
drivers/crypto/caam/caampkc.c:444:35: warning: Using plain integer as NULL pointer

Signed-off-by: Horia Geantă <horia.geanta@nxp.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/crypto/caam/caampkc.c
drivers/crypto/caam/ctrl.c
drivers/crypto/caam/jr.c

index 851015e652b81525cabbad5695470a954985b20e..32100c4851dd4bd94b9b5b6814558812d8b13629 100644 (file)
@@ -395,7 +395,7 @@ static int caam_rsa_set_pub_key(struct crypto_akcipher *tfm, const void *key,
                                unsigned int keylen)
 {
        struct caam_rsa_ctx *ctx = akcipher_tfm_ctx(tfm);
-       struct rsa_key raw_key = {0};
+       struct rsa_key raw_key = {NULL};
        struct caam_rsa_key *rsa_key = &ctx->key;
        int ret;
 
@@ -441,7 +441,7 @@ static int caam_rsa_set_priv_key(struct crypto_akcipher *tfm, const void *key,
                                 unsigned int keylen)
 {
        struct caam_rsa_ctx *ctx = akcipher_tfm_ctx(tfm);
-       struct rsa_key raw_key = {0};
+       struct rsa_key raw_key = {NULL};
        struct caam_rsa_key *rsa_key = &ctx->key;
        int ret;
 
index a79937d68c26ddf6212fe5f3eda71dd5b0cda743..be62a7f482ace121e2b2aec9fc23005289d3d5c4 100644 (file)
@@ -365,11 +365,8 @@ static void kick_trng(struct platform_device *pdev, int ent_delay)
         */
        val = (rd_reg32(&r4tst->rtsdctl) & RTSDCTL_ENT_DLY_MASK)
              >> RTSDCTL_ENT_DLY_SHIFT;
-       if (ent_delay <= val) {
-               /* put RNG4 into run mode */
-               clrsetbits_32(&r4tst->rtmctl, RTMCTL_PRGM, 0);
-               return;
-       }
+       if (ent_delay <= val)
+               goto start_rng;
 
        val = rd_reg32(&r4tst->rtsdctl);
        val = (val & ~RTSDCTL_ENT_DLY_MASK) |
@@ -381,15 +378,12 @@ static void kick_trng(struct platform_device *pdev, int ent_delay)
        wr_reg32(&r4tst->rtfrqmax, RTFRQMAX_DISABLE);
        /* read the control register */
        val = rd_reg32(&r4tst->rtmctl);
+start_rng:
        /*
         * select raw sampling in both entropy shifter
-        * and statistical checker
+        * and statistical checker; ; put RNG4 into run mode
         */
-       clrsetbits_32(&val, 0, RTMCTL_SAMP_MODE_RAW_ES_SC);
-       /* put RNG4 into run mode */
-       clrsetbits_32(&val, RTMCTL_PRGM, 0);
-       /* write back the control register */
-       wr_reg32(&r4tst->rtmctl, val);
+       clrsetbits_32(&r4tst->rtmctl, RTMCTL_PRGM, RTMCTL_SAMP_MODE_RAW_ES_SC);
 }
 
 /**
@@ -545,13 +539,13 @@ static int caam_probe(struct platform_device *pdev)
        else
                BLOCK_OFFSET = PG_SIZE_64K;
 
-       ctrlpriv->ctrl = (struct caam_ctrl __force *)ctrl;
-       ctrlpriv->assure = (struct caam_assurance __force *)
-                          ((uint8_t *)ctrl +
+       ctrlpriv->ctrl = (struct caam_ctrl __iomem __force *)ctrl;
+       ctrlpriv->assure = (struct caam_assurance __iomem __force *)
+                          ((__force uint8_t *)ctrl +
                            BLOCK_OFFSET * ASSURE_BLOCK_NUMBER
                           );
-       ctrlpriv->deco = (struct caam_deco __force *)
-                        ((uint8_t *)ctrl +
+       ctrlpriv->deco = (struct caam_deco __iomem __force *)
+                        ((__force uint8_t *)ctrl +
                         BLOCK_OFFSET * DECO_BLOCK_NUMBER
                         );
 
@@ -630,8 +624,8 @@ static int caam_probe(struct platform_device *pdev)
                                        ring);
                                continue;
                        }
-                       ctrlpriv->jr[ring] = (struct caam_job_ring __force *)
-                                            ((uint8_t *)ctrl +
+                       ctrlpriv->jr[ring] = (struct caam_job_ring __iomem __force *)
+                                            ((__force uint8_t *)ctrl +
                                             (ring + JR_BLOCK_NUMBER) *
                                              BLOCK_OFFSET
                                             );
@@ -644,8 +638,8 @@ static int caam_probe(struct platform_device *pdev)
                        !!(rd_reg32(&ctrl->perfmon.comp_parms_ms) &
                           CTPR_MS_QI_MASK);
        if (ctrlpriv->qi_present) {
-               ctrlpriv->qi = (struct caam_queue_if __force *)
-                              ((uint8_t *)ctrl +
+               ctrlpriv->qi = (struct caam_queue_if __iomem __force *)
+                              ((__force uint8_t *)ctrl +
                                 BLOCK_OFFSET * QI_BLOCK_NUMBER
                               );
                /* This is all that's required to physically enable QI */
@@ -803,7 +797,7 @@ static int caam_probe(struct platform_device *pdev)
                                    &caam_fops_u32_ro);
 
        /* Internal covering keys (useful in non-secure mode only) */
-       ctrlpriv->ctl_kek_wrap.data = &ctrlpriv->ctrl->kek[0];
+       ctrlpriv->ctl_kek_wrap.data = (__force void *)&ctrlpriv->ctrl->kek[0];
        ctrlpriv->ctl_kek_wrap.size = KEK_KEY_SIZE * sizeof(u32);
        ctrlpriv->ctl_kek = debugfs_create_blob("kek",
                                                S_IRUSR |
@@ -811,7 +805,7 @@ static int caam_probe(struct platform_device *pdev)
                                                ctrlpriv->ctl,
                                                &ctrlpriv->ctl_kek_wrap);
 
-       ctrlpriv->ctl_tkek_wrap.data = &ctrlpriv->ctrl->tkek[0];
+       ctrlpriv->ctl_tkek_wrap.data = (__force void *)&ctrlpriv->ctrl->tkek[0];
        ctrlpriv->ctl_tkek_wrap.size = KEK_KEY_SIZE * sizeof(u32);
        ctrlpriv->ctl_tkek = debugfs_create_blob("tkek",
                                                 S_IRUSR |
@@ -819,7 +813,7 @@ static int caam_probe(struct platform_device *pdev)
                                                 ctrlpriv->ctl,
                                                 &ctrlpriv->ctl_tkek_wrap);
 
-       ctrlpriv->ctl_tdsk_wrap.data = &ctrlpriv->ctrl->tdsk[0];
+       ctrlpriv->ctl_tdsk_wrap.data = (__force void *)&ctrlpriv->ctrl->tdsk[0];
        ctrlpriv->ctl_tdsk_wrap.size = KEK_KEY_SIZE * sizeof(u32);
        ctrlpriv->ctl_tdsk = debugfs_create_blob("tdsk",
                                                 S_IRUSR |
index 757c27f9953d52aa4b662f317b7c0d5ff508a685..7331ea734f372abf63ae1e1960e913b5a54eb230 100644 (file)
@@ -489,7 +489,7 @@ static int caam_jr_probe(struct platform_device *pdev)
                return -ENOMEM;
        }
 
-       jrpriv->rregs = (struct caam_job_ring __force *)ctrl;
+       jrpriv->rregs = (struct caam_job_ring __iomem __force *)ctrl;
 
        if (sizeof(dma_addr_t) == sizeof(u64))
                if (of_device_is_compatible(nprop, "fsl,sec-v5.0-job-ring"))