]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/commitdiff
crypto: se-elp: Remove slot info for elp request structure
authorMallikarjun Kasoju <mkasoju@nvidia.com>
Mon, 27 Nov 2017 09:19:13 +0000 (14:49 +0530)
committermobile promotions <svcmobile_promotions@nvidia.com>
Tue, 28 Nov 2017 15:47:29 +0000 (07:47 -0800)
There is no need to store slot information in ecc request structure
as it not used anywhere.

Bug 200367774

Change-Id: Ie366208fd8c56f261b6b71a9baa3b9b9384330ac
Signed-off-by: Mallikarjun Kasoju <mkasoju@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/1605488
Reviewed-by: Konduri Praveen <kondurip@nvidia.com>
GVS: Gerrit_Virtual_Submit
Reviewed-by: Rakesh Babu Bodla <rbodla@nvidia.com>
Reviewed-by: Laxman Dewangan <ldewangan@nvidia.com>
Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com>
Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
drivers/crypto/tegra-se-elp.c

index 82a6608d867ceed7ec0f9a80cca64acb3aaf755a..a7a56858cff0e1f0b167fa435ddf3f0e1db2db65 100644 (file)
@@ -137,7 +137,6 @@ static struct tegra_se_elp_dev *elp_dev;
 
 struct tegra_se_pka1_ecc_request {
        struct tegra_se_elp_dev *se_dev;
-       struct tegra_se_pka1_slot *slot;
        u32 *message;
        u32 *result;
        u32 *modulus;
@@ -1028,10 +1027,10 @@ static void tegra_se_set_pka1_rsa_key(struct tegra_se_pka1_rsa_context *ctx)
                                    ctx->op_mode, ECC_INVALID);
 }
 
-static void tegra_se_set_pka1_ecc_key(struct tegra_se_pka1_ecc_request *req)
+static void tegra_se_set_pka1_ecc_key(struct tegra_se_pka1_ecc_request *req,
+                                       u32 slot_num)
 {
        u32 key_words = req->size / WORD_SIZE_BYTES;
-       u32 slot_num = req->slot->slot_num;
        u32 *MOD = req->modulus;
        u32 *M = req->m;
        u32 *R2 = req->r2;
@@ -1171,8 +1170,8 @@ static int tegra_se_pka1_precomp(struct tegra_se_pka1_rsa_context *ctx,
 static int tegra_se_pka1_ecc_do(struct tegra_se_pka1_ecc_request *req)
 {
        int ret;
-       u32 val, slot_num;
-       struct tegra_se_pka1_slot *pslot;
+       u32 val;
+       struct tegra_se_pka1_slot *pslot = NULL;
        struct tegra_se_elp_dev *se_dev = req->se_dev;
        u32 i = 0;
 
@@ -1182,12 +1181,13 @@ static int tegra_se_pka1_ecc_do(struct tegra_se_pka1_ecc_request *req)
                        dev_err(se_dev->dev, "no free key slot\n");
                        return -ENOMEM;
                }
-               req->slot = pslot;
-               slot_num = req->slot->slot_num;
-
-               tegra_se_set_pka1_ecc_key(req);
+               if (pslot->slot_num >= TEGRA_SE_PKA1_KEYSLOT_COUNT) {
+                       dev_err(se_dev->dev, "Invalid PKA1 key slot number\n");
+                       return -EINVAL;
+               }
+               tegra_se_set_pka1_ecc_key(req, pslot->slot_num);
 
-               val = TEGRA_SE_PKA1_CTRL_CONTROL_KEYSLOT(slot_num) |
+               val = TEGRA_SE_PKA1_CTRL_CONTROL_KEYSLOT(pslot->slot_num) |
                        TEGRA_SE_PKA1_CTRL_CONTROL_LOAD_KEY(ELP_ENABLE);
 
                se_elp_writel(se_dev, PKA1, val,
@@ -1217,7 +1217,7 @@ static int tegra_se_pka1_ecc_do(struct tegra_se_pka1_ecc_request *req)
        tegra_se_read_pka1_ecc_result(req);
 
        if (se_dev->chipdata->use_key_slot)
-               tegra_se_pka1_free_key_slot(req->slot);
+               tegra_se_pka1_free_key_slot(pslot);
 
        return ret;
 }