mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
crypto: acomp - Add ACOMP_FBREQ_ON_STACK
Add a helper to create an on-stack fallback request from a given request. Use this helper in acomp_do_nondma. Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
parent
b04b395f7a
commit
05fa2c6e87
2 changed files with 27 additions and 13 deletions
|
@ -253,21 +253,9 @@ static void acomp_virt_to_sg(struct acomp_req *req)
|
|||
|
||||
static int acomp_do_nondma(struct acomp_req *req, bool comp)
|
||||
{
|
||||
u32 keep = CRYPTO_ACOMP_REQ_SRC_VIRT |
|
||||
CRYPTO_ACOMP_REQ_SRC_NONDMA |
|
||||
CRYPTO_ACOMP_REQ_DST_VIRT |
|
||||
CRYPTO_ACOMP_REQ_DST_NONDMA;
|
||||
ACOMP_REQUEST_ON_STACK(fbreq, crypto_acomp_reqtfm(req));
|
||||
ACOMP_FBREQ_ON_STACK(fbreq, req);
|
||||
int err;
|
||||
|
||||
acomp_request_set_callback(fbreq, req->base.flags, NULL, NULL);
|
||||
fbreq->base.flags &= ~keep;
|
||||
fbreq->base.flags |= req->base.flags & keep;
|
||||
fbreq->src = req->src;
|
||||
fbreq->dst = req->dst;
|
||||
fbreq->slen = req->slen;
|
||||
fbreq->dlen = req->dlen;
|
||||
|
||||
if (comp)
|
||||
err = crypto_acomp_compress(fbreq);
|
||||
else
|
||||
|
|
|
@ -23,6 +23,12 @@
|
|||
struct acomp_req *name = acomp_request_on_stack_init( \
|
||||
__##name##_req, (tfm), 0, true)
|
||||
|
||||
#define ACOMP_FBREQ_ON_STACK(name, req) \
|
||||
char __##name##_req[sizeof(struct acomp_req) + \
|
||||
MAX_SYNC_COMP_REQSIZE] CRYPTO_MINALIGN_ATTR; \
|
||||
struct acomp_req *name = acomp_fbreq_on_stack_init( \
|
||||
__##name##_req, (req))
|
||||
|
||||
/**
|
||||
* struct acomp_alg - asynchronous compression algorithm
|
||||
*
|
||||
|
@ -235,4 +241,24 @@ static inline u32 acomp_request_flags(struct acomp_req *req)
|
|||
return crypto_request_flags(&req->base) & ~CRYPTO_ACOMP_REQ_PRIVATE;
|
||||
}
|
||||
|
||||
static inline struct acomp_req *acomp_fbreq_on_stack_init(
|
||||
char *buf, struct acomp_req *old)
|
||||
{
|
||||
struct crypto_acomp *tfm = crypto_acomp_reqtfm(old);
|
||||
struct acomp_req *req;
|
||||
|
||||
req = acomp_request_on_stack_init(buf, tfm, 0, true);
|
||||
acomp_request_set_callback(req, acomp_request_flags(old), NULL, NULL);
|
||||
req->base.flags &= ~CRYPTO_ACOMP_REQ_PRIVATE;
|
||||
req->base.flags |= old->base.flags & CRYPTO_ACOMP_REQ_PRIVATE;
|
||||
req->src = old->src;
|
||||
req->dst = old->dst;
|
||||
req->slen = old->slen;
|
||||
req->dlen = old->dlen;
|
||||
req->soff = old->soff;
|
||||
req->doff = old->doff;
|
||||
|
||||
return req;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Reference in a new issue