diff options
Diffstat (limited to 'recipes-kernel/cryptodev/files/0013-clean-up-code-layout.patch')
| -rw-r--r-- | recipes-kernel/cryptodev/files/0013-clean-up-code-layout.patch | 186 |
1 files changed, 186 insertions, 0 deletions
diff --git a/recipes-kernel/cryptodev/files/0013-clean-up-code-layout.patch b/recipes-kernel/cryptodev/files/0013-clean-up-code-layout.patch new file mode 100644 index 000000000..86cf6a2b0 --- /dev/null +++ b/recipes-kernel/cryptodev/files/0013-clean-up-code-layout.patch | |||
| @@ -0,0 +1,186 @@ | |||
| 1 | From 39abcb9cea60540528e848d6c66169c36d666861 Mon Sep 17 00:00:00 2001 | ||
| 2 | From: Cristian Stoica <cristian.stoica@freescale.com> | ||
| 3 | Date: Fri, 20 Feb 2015 12:46:58 +0200 | ||
| 4 | Subject: [PATCH 13/15] clean-up code layout | ||
| 5 | |||
| 6 | Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> | ||
| 7 | Change-Id: I92c2f4baeed9470a2c3c42b592d878e65918b0af | ||
| 8 | Reviewed-on: http://git.am.freescale.net:8181/34222 | ||
| 9 | --- | ||
| 10 | cryptlib.c | 11 ++++------- | ||
| 11 | ioctl.c | 55 +++++++++++++++++++++---------------------------------- | ||
| 12 | main.c | 4 +--- | ||
| 13 | 3 files changed, 26 insertions(+), 44 deletions(-) | ||
| 14 | |||
| 15 | diff --git a/cryptlib.c b/cryptlib.c | ||
| 16 | index ec6693e..21e691b 100644 | ||
| 17 | --- a/cryptlib.c | ||
| 18 | +++ b/cryptlib.c | ||
| 19 | @@ -434,7 +434,7 @@ int cryptodev_hash_final(struct hash_data *hdata, void *output) | ||
| 20 | return waitfor(hdata->async.result, ret); | ||
| 21 | } | ||
| 22 | |||
| 23 | -int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) | ||
| 24 | +int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) | ||
| 25 | { | ||
| 26 | int ret = 0; | ||
| 27 | struct pkc_request *pkc_req = &pkc->req, *pkc_requested; | ||
| 28 | @@ -445,8 +445,7 @@ int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) | ||
| 29 | case RSA_PRIV_FORM1: | ||
| 30 | case RSA_PRIV_FORM2: | ||
| 31 | case RSA_PRIV_FORM3: | ||
| 32 | - pkc->s = crypto_alloc_pkc("pkc(rsa)", | ||
| 33 | - CRYPTO_ALG_TYPE_PKC_RSA, 0); | ||
| 34 | + pkc->s = crypto_alloc_pkc("pkc(rsa)", CRYPTO_ALG_TYPE_PKC_RSA, 0); | ||
| 35 | break; | ||
| 36 | case DSA_SIGN: | ||
| 37 | case DSA_VERIFY: | ||
| 38 | @@ -454,13 +453,11 @@ int cryptodev_pkc_offload(struct cryptodev_pkc *pkc) | ||
| 39 | case ECDSA_VERIFY: | ||
| 40 | case DLC_KEYGEN: | ||
| 41 | case ECC_KEYGEN: | ||
| 42 | - pkc->s = crypto_alloc_pkc("pkc(dsa)", | ||
| 43 | - CRYPTO_ALG_TYPE_PKC_DSA, 0); | ||
| 44 | + pkc->s = crypto_alloc_pkc("pkc(dsa)", CRYPTO_ALG_TYPE_PKC_DSA, 0); | ||
| 45 | break; | ||
| 46 | case DH_COMPUTE_KEY: | ||
| 47 | case ECDH_COMPUTE_KEY: | ||
| 48 | - pkc->s = crypto_alloc_pkc("pkc(dh)", | ||
| 49 | - CRYPTO_ALG_TYPE_PKC_DH, 0); | ||
| 50 | + pkc->s = crypto_alloc_pkc("pkc(dh)", CRYPTO_ALG_TYPE_PKC_DH, 0); | ||
| 51 | break; | ||
| 52 | default: | ||
| 53 | return -EINVAL; | ||
| 54 | diff --git a/ioctl.c b/ioctl.c | ||
| 55 | index fb4c4e3..ee0486c 100644 | ||
| 56 | --- a/ioctl.c | ||
| 57 | +++ b/ioctl.c | ||
| 58 | @@ -714,16 +714,13 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | ||
| 59 | case CRK_MOD_EXP: | ||
| 60 | { | ||
| 61 | struct rsa_pub_req_s *rsa_req = &pkc_req->req_u.rsa_pub_req; | ||
| 62 | - copy_to_user(ckop->crk_param[3].crp_p, rsa_req->g, | ||
| 63 | - rsa_req->g_len); | ||
| 64 | + copy_to_user(ckop->crk_param[3].crp_p, rsa_req->g, rsa_req->g_len); | ||
| 65 | } | ||
| 66 | break; | ||
| 67 | case CRK_MOD_EXP_CRT: | ||
| 68 | { | ||
| 69 | - struct rsa_priv_frm3_req_s *rsa_req = | ||
| 70 | - &pkc_req->req_u.rsa_priv_f3; | ||
| 71 | - copy_to_user(ckop->crk_param[6].crp_p, | ||
| 72 | - rsa_req->f, rsa_req->f_len); | ||
| 73 | + struct rsa_priv_frm3_req_s *rsa_req = &pkc_req->req_u.rsa_priv_f3; | ||
| 74 | + copy_to_user(ckop->crk_param[6].crp_p, rsa_req->f, rsa_req->f_len); | ||
| 75 | } | ||
| 76 | break; | ||
| 77 | case CRK_DSA_SIGN: | ||
| 78 | @@ -731,15 +728,11 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | ||
| 79 | struct dsa_sign_req_s *dsa_req = &pkc_req->req_u.dsa_sign; | ||
| 80 | |||
| 81 | if (pkc_req->type == ECDSA_SIGN) { | ||
| 82 | - copy_to_user(ckop->crk_param[6].crp_p, | ||
| 83 | - dsa_req->c, dsa_req->d_len); | ||
| 84 | - copy_to_user(ckop->crk_param[7].crp_p, | ||
| 85 | - dsa_req->d, dsa_req->d_len); | ||
| 86 | + copy_to_user(ckop->crk_param[6].crp_p, dsa_req->c, dsa_req->d_len); | ||
| 87 | + copy_to_user(ckop->crk_param[7].crp_p, dsa_req->d, dsa_req->d_len); | ||
| 88 | } else { | ||
| 89 | - copy_to_user(ckop->crk_param[5].crp_p, | ||
| 90 | - dsa_req->c, dsa_req->d_len); | ||
| 91 | - copy_to_user(ckop->crk_param[6].crp_p, | ||
| 92 | - dsa_req->d, dsa_req->d_len); | ||
| 93 | + copy_to_user(ckop->crk_param[5].crp_p, dsa_req->c, dsa_req->d_len); | ||
| 94 | + copy_to_user(ckop->crk_param[6].crp_p, dsa_req->d, dsa_req->d_len); | ||
| 95 | } | ||
| 96 | } | ||
| 97 | break; | ||
| 98 | @@ -749,11 +742,9 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | ||
| 99 | { | ||
| 100 | struct dh_key_req_s *dh_req = &pkc_req->req_u.dh_req; | ||
| 101 | if (pkc_req->type == ECDH_COMPUTE_KEY) | ||
| 102 | - copy_to_user(ckop->crk_param[4].crp_p, | ||
| 103 | - dh_req->z, dh_req->z_len); | ||
| 104 | + copy_to_user(ckop->crk_param[4].crp_p, dh_req->z, dh_req->z_len); | ||
| 105 | else | ||
| 106 | - copy_to_user(ckop->crk_param[3].crp_p, | ||
| 107 | - dh_req->z, dh_req->z_len); | ||
| 108 | + copy_to_user(ckop->crk_param[3].crp_p, dh_req->z, dh_req->z_len); | ||
| 109 | } | ||
| 110 | break; | ||
| 111 | case CRK_DSA_GENERATE_KEY: | ||
| 112 | @@ -763,14 +754,14 @@ static int crypto_async_fetch_asym(struct cryptodev_pkc *pkc) | ||
| 113 | |||
| 114 | if (pkc_req->type == ECC_KEYGEN) { | ||
| 115 | copy_to_user(ckop->crk_param[4].crp_p, key_req->pub_key, | ||
| 116 | - key_req->pub_key_len); | ||
| 117 | - copy_to_user(ckop->crk_param[5].crp_p, | ||
| 118 | - key_req->priv_key, key_req->priv_key_len); | ||
| 119 | + key_req->pub_key_len); | ||
| 120 | + copy_to_user(ckop->crk_param[5].crp_p, key_req->priv_key, | ||
| 121 | + key_req->priv_key_len); | ||
| 122 | } else { | ||
| 123 | - copy_to_user(ckop->crk_param[3].crp_p, | ||
| 124 | - key_req->pub_key, key_req->pub_key_len); | ||
| 125 | - copy_to_user(ckop->crk_param[4].crp_p, | ||
| 126 | - key_req->priv_key, key_req->priv_key_len); | ||
| 127 | + copy_to_user(ckop->crk_param[3].crp_p, key_req->pub_key, | ||
| 128 | + key_req->pub_key_len); | ||
| 129 | + copy_to_user(ckop->crk_param[4].crp_p, key_req->priv_key, | ||
| 130 | + key_req->priv_key_len); | ||
| 131 | } | ||
| 132 | } | ||
| 133 | default: | ||
| 134 | @@ -1113,16 +1104,14 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
| 135 | if (!list_empty(&pcr->asym_completed_list)) { | ||
| 136 | /* Run a loop in the list for upto elements | ||
| 137 | and copy their response back */ | ||
| 138 | - pkc = | ||
| 139 | - list_first_entry(&pcr->asym_completed_list, | ||
| 140 | + pkc = list_first_entry(&pcr->asym_completed_list, | ||
| 141 | struct cryptodev_pkc, list); | ||
| 142 | list_del(&pkc->list); | ||
| 143 | spin_unlock_bh(&pcr->completion_lock); | ||
| 144 | ret = crypto_async_fetch_asym(pkc); | ||
| 145 | if (!ret) { | ||
| 146 | cookie_list.cookie_available++; | ||
| 147 | - cookie_list.cookie[i] = | ||
| 148 | - pkc->kop.kop.cookie; | ||
| 149 | + cookie_list.cookie[i] = pkc->kop.kop.cookie; | ||
| 150 | cookie_list.status[i] = pkc->result.err; | ||
| 151 | } | ||
| 152 | kfree(pkc); | ||
| 153 | @@ -1133,12 +1122,10 @@ cryptodev_ioctl(struct file *filp, unsigned int cmd, unsigned long arg_) | ||
| 154 | } | ||
| 155 | |||
| 156 | /* Reflect the updated request to user-space */ | ||
| 157 | - if (cookie_list.cookie_available) | ||
| 158 | - copy_to_user(arg, &cookie_list, | ||
| 159 | - sizeof(struct pkc_cookie_list_s)); | ||
| 160 | - else { | ||
| 161 | + if (cookie_list.cookie_available) { | ||
| 162 | + copy_to_user(arg, &cookie_list, sizeof(struct pkc_cookie_list_s)); | ||
| 163 | + } else { | ||
| 164 | struct pkc_cookie_list_s *user_ck_list = (void *)arg; | ||
| 165 | - | ||
| 166 | put_user(0, &(user_ck_list->cookie_available)); | ||
| 167 | } | ||
| 168 | ret = cookie_list.cookie_available; | ||
| 169 | diff --git a/main.c b/main.c | ||
| 170 | index 6365911..af66553 100644 | ||
| 171 | --- a/main.c | ||
| 172 | +++ b/main.c | ||
| 173 | @@ -666,9 +666,7 @@ int crypto_bn_modexp(struct cryptodev_pkc *pkc) | ||
| 174 | if (pkc->type == SYNCHRONOUS) { | ||
| 175 | if (rc) | ||
| 176 | goto err; | ||
| 177 | - | ||
| 178 | - copy_to_user(cop->crk_param[3].crp_p, rsa_req->g, | ||
| 179 | - rsa_req->g_len); | ||
| 180 | + copy_to_user(cop->crk_param[3].crp_p, rsa_req->g, rsa_req->g_len); | ||
| 181 | } else { | ||
| 182 | if (rc != -EINPROGRESS && rc != 0) | ||
| 183 | goto err; | ||
| 184 | -- | ||
| 185 | 2.3.5 | ||
| 186 | |||
