Skip to content

Commit

Permalink
padata: make padata_do_parallel to return zero on success
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
klassert authored and herbertx committed Jul 14, 2010
1 parent 33e5445 commit 83f619f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 18 deletions.
18 changes: 6 additions & 12 deletions crypto/pcrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,8 @@ static int pcrypt_aead_encrypt(struct aead_request *req)
aead_request_set_assoc(creq, req->assoc, req->assoclen);

err = pcrypt_do_parallel(padata, &ctx->cb_cpu, pcrypt_enc_padata);
if (err)
return err;
else
err = crypto_aead_encrypt(creq);
if (!err)
return -EINPROGRESS;

return err;
}
Expand Down Expand Up @@ -187,10 +185,8 @@ static int pcrypt_aead_decrypt(struct aead_request *req)
aead_request_set_assoc(creq, req->assoc, req->assoclen);

err = pcrypt_do_parallel(padata, &ctx->cb_cpu, pcrypt_dec_padata);
if (err)
return err;
else
err = crypto_aead_decrypt(creq);
if (!err)
return -EINPROGRESS;

return err;
}
Expand Down Expand Up @@ -233,10 +229,8 @@ static int pcrypt_aead_givencrypt(struct aead_givcrypt_request *req)
aead_givcrypt_set_giv(creq, req->giv, req->seq);

err = pcrypt_do_parallel(padata, &ctx->cb_cpu, pcrypt_enc_padata);
if (err)
return err;
else
err = crypto_aead_givencrypt(creq);
if (!err)
return -EINPROGRESS;

return err;
}
Expand Down
11 changes: 5 additions & 6 deletions kernel/padata.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,21 @@ int padata_do_parallel(struct padata_instance *pinst,

pd = rcu_dereference(pinst->pd);

err = 0;
err = -EINVAL;
if (!(pinst->flags & PADATA_INIT))
goto out;

if (!cpumask_test_cpu(cb_cpu, pd->cpumask))
goto out;

err = -EBUSY;
if ((pinst->flags & PADATA_RESET))
goto out;

if (atomic_read(&pd->refcnt) >= MAX_OBJ_NUM)
goto out;

err = -EINVAL;
if (!cpumask_test_cpu(cb_cpu, pd->cpumask))
goto out;

err = -EINPROGRESS;
err = 0;
atomic_inc(&pd->refcnt);
padata->pd = pd;
padata->cb_cpu = cb_cpu;
Expand Down

0 comments on commit 83f619f

Please sign in to comment.