Skip to content

Commit

Permalink
crypto: scatterwalk - Add scatterwalk_crypto_chain helper
Browse files Browse the repository at this point in the history
A lot of crypto algorithms implement their own chaining function.
So add a generic one that can be used from all the algorithms that
need scatterlist chaining.

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 Dec 2, 2010
1 parent bc97e57 commit 079f2f7
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions include/crypto/scatterwalk.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,21 @@ static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg)
return (++sg)->length ? sg : (void *)sg_page(sg);
}

static inline void scatterwalk_crypto_chain(struct scatterlist *head,
struct scatterlist *sg,
int chain, int num)
{
if (chain) {
head->length += sg->length;
sg = scatterwalk_sg_next(sg);
}

if (sg)
scatterwalk_sg_chain(head, num, sg);
else
sg_mark_end(head);
}

static inline unsigned long scatterwalk_samebuf(struct scatter_walk *walk_in,
struct scatter_walk *walk_out)
{
Expand Down

0 comments on commit 079f2f7

Please sign in to comment.