Commit 83f619f3c8abb82cac9158cf23c656ec5c184607
Committed by
Herbert Xu
1 parent
33e5445068
padata: make padata_do_parallel to return zero on success
To return -EINPROGRESS on success in padata_do_parallel was considered to be odd. This patch changes this to return zero on success. Also the only user of padata, pcrypt is adapted to convert a return of zero to -EINPROGRESS within the crypto layer. This also removes the pcrypt fallback if padata_do_parallel was called on a not running padata instance as we can't handle it anymore. This fallback was unused, so it's save to remove it. Signed-off-by: Steffen Klassert <steffen.klassert@secunet.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Showing 2 changed files with 11 additions and 18 deletions Side-by-side Diff
crypto/pcrypt.c
... | ... | @@ -143,10 +143,8 @@ |
143 | 143 | aead_request_set_assoc(creq, req->assoc, req->assoclen); |
144 | 144 | |
145 | 145 | err = pcrypt_do_parallel(padata, &ctx->cb_cpu, pcrypt_enc_padata); |
146 | - if (err) | |
147 | - return err; | |
148 | - else | |
149 | - err = crypto_aead_encrypt(creq); | |
146 | + if (!err) | |
147 | + return -EINPROGRESS; | |
150 | 148 | |
151 | 149 | return err; |
152 | 150 | } |
... | ... | @@ -187,10 +185,8 @@ |
187 | 185 | aead_request_set_assoc(creq, req->assoc, req->assoclen); |
188 | 186 | |
189 | 187 | err = pcrypt_do_parallel(padata, &ctx->cb_cpu, pcrypt_dec_padata); |
190 | - if (err) | |
191 | - return err; | |
192 | - else | |
193 | - err = crypto_aead_decrypt(creq); | |
188 | + if (!err) | |
189 | + return -EINPROGRESS; | |
194 | 190 | |
195 | 191 | return err; |
196 | 192 | } |
... | ... | @@ -233,10 +229,8 @@ |
233 | 229 | aead_givcrypt_set_giv(creq, req->giv, req->seq); |
234 | 230 | |
235 | 231 | err = pcrypt_do_parallel(padata, &ctx->cb_cpu, pcrypt_enc_padata); |
236 | - if (err) | |
237 | - return err; | |
238 | - else | |
239 | - err = crypto_aead_givencrypt(creq); | |
232 | + if (!err) | |
233 | + return -EINPROGRESS; | |
240 | 234 | |
241 | 235 | return err; |
242 | 236 | } |
kernel/padata.c
... | ... | @@ -111,10 +111,13 @@ |
111 | 111 | |
112 | 112 | pd = rcu_dereference(pinst->pd); |
113 | 113 | |
114 | - err = 0; | |
114 | + err = -EINVAL; | |
115 | 115 | if (!(pinst->flags & PADATA_INIT)) |
116 | 116 | goto out; |
117 | 117 | |
118 | + if (!cpumask_test_cpu(cb_cpu, pd->cpumask)) | |
119 | + goto out; | |
120 | + | |
118 | 121 | err = -EBUSY; |
119 | 122 | if ((pinst->flags & PADATA_RESET)) |
120 | 123 | goto out; |
... | ... | @@ -122,11 +125,7 @@ |
122 | 125 | if (atomic_read(&pd->refcnt) >= MAX_OBJ_NUM) |
123 | 126 | goto out; |
124 | 127 | |
125 | - err = -EINVAL; | |
126 | - if (!cpumask_test_cpu(cb_cpu, pd->cpumask)) | |
127 | - goto out; | |
128 | - | |
129 | - err = -EINPROGRESS; | |
128 | + err = 0; | |
130 | 129 | atomic_inc(&pd->refcnt); |
131 | 130 | padata->pd = pd; |
132 | 131 | padata->cb_cpu = cb_cpu; |