Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Bluetooth: Use crypto_wait_req

This patch replaces the custom crypto completion function with
crypto_req_done.

Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

+6 -31
+6 -31
net/bluetooth/ecdh_helper.c
··· 25 25 #include <linux/scatterlist.h> 26 26 #include <crypto/ecdh.h> 27 27 28 - struct ecdh_completion { 29 - struct completion completion; 30 - int err; 31 - }; 32 - 33 - static void ecdh_complete(struct crypto_async_request *req, int err) 34 - { 35 - struct ecdh_completion *res = req->data; 36 - 37 - if (err == -EINPROGRESS) 38 - return; 39 - 40 - res->err = err; 41 - complete(&res->completion); 42 - } 43 - 44 28 static inline void swap_digits(u64 *in, u64 *out, unsigned int ndigits) 45 29 { 46 30 int i; ··· 44 60 int compute_ecdh_secret(struct crypto_kpp *tfm, const u8 public_key[64], 45 61 u8 secret[32]) 46 62 { 63 + DECLARE_CRYPTO_WAIT(result); 47 64 struct kpp_request *req; 48 65 u8 *tmp; 49 - struct ecdh_completion result; 50 66 struct scatterlist src, dst; 51 67 int err; 52 68 ··· 60 76 goto free_tmp; 61 77 } 62 78 63 - init_completion(&result.completion); 64 - 65 79 swap_digits((u64 *)public_key, (u64 *)tmp, 4); /* x */ 66 80 swap_digits((u64 *)&public_key[32], (u64 *)&tmp[32], 4); /* y */ 67 81 ··· 68 86 kpp_request_set_input(req, &src, 64); 69 87 kpp_request_set_output(req, &dst, 32); 70 88 kpp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, 71 - ecdh_complete, &result); 89 + crypto_req_done, &result); 72 90 err = crypto_kpp_compute_shared_secret(req); 73 - if (err == -EINPROGRESS) { 74 - wait_for_completion(&result.completion); 75 - err = result.err; 76 - } 91 + err = crypto_wait_req(err, &result); 77 92 if (err < 0) { 78 93 pr_err("alg: ecdh: compute shared secret failed. err %d\n", 79 94 err); ··· 144 165 */ 145 166 int generate_ecdh_public_key(struct crypto_kpp *tfm, u8 public_key[64]) 146 167 { 168 + DECLARE_CRYPTO_WAIT(result); 147 169 struct kpp_request *req; 148 170 u8 *tmp; 149 - struct ecdh_completion result; 150 171 struct scatterlist dst; 151 172 int err; 152 173 ··· 160 181 goto free_tmp; 161 182 } 162 183 163 - init_completion(&result.completion); 164 184 sg_init_one(&dst, tmp, 64); 165 185 kpp_request_set_input(req, NULL, 0); 166 186 kpp_request_set_output(req, &dst, 64); 167 187 kpp_request_set_callback(req, CRYPTO_TFM_REQ_MAY_BACKLOG, 168 - ecdh_complete, &result); 188 + crypto_req_done, &result); 169 189 170 190 err = crypto_kpp_generate_public_key(req); 171 - if (err == -EINPROGRESS) { 172 - wait_for_completion(&result.completion); 173 - err = result.err; 174 - } 191 + err = crypto_wait_req(err, &result); 175 192 if (err < 0) 176 193 goto free_all; 177 194