summaryrefslogtreecommitdiff
path: root/crypto
diff options
context:
space:
mode:
authorEric Biggers <ebiggers@google.com>2025-03-10 10:20:16 -0700
committerHerbert Xu <herbert@gondor.apana.org.au>2025-03-21 17:33:38 +0800
commit7450ebd29cd9b9745f005f2609badacea15fbe30 (patch)
treeab9fffe125e88f5e396745ac2966230f0a247ab1 /crypto
parentea3d35467ba474768013365ce5f2c6eb454fed3a (diff)
crypto: scatterwalk - simplify map and unmap calling convention
Now that the address returned by scatterwalk_map() is always being stored into the same struct scatter_walk that is passed in, make scatterwalk_map() do so itself and return void. Similarly, now that scatterwalk_unmap() is always being passed the address field within a struct scatter_walk, make scatterwalk_unmap() take a pointer to struct scatter_walk instead of the address directly. Signed-off-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'crypto')
-rw-r--r--crypto/skcipher.c28
1 files changed, 8 insertions, 20 deletions
diff --git a/crypto/skcipher.c b/crypto/skcipher.c
index ab5d852febcd..132075a905d9 100644
--- a/crypto/skcipher.c
+++ b/crypto/skcipher.c
@@ -39,18 +39,6 @@ static const struct crypto_type crypto_skcipher_type;
static int skcipher_walk_next(struct skcipher_walk *walk);
-static inline void skcipher_map_src(struct skcipher_walk *walk)
-{
- /* XXX */
- walk->in.__addr = scatterwalk_map(&walk->in);
-}
-
-static inline void skcipher_map_dst(struct skcipher_walk *walk)
-{
- /* XXX */
- walk->out.__addr = scatterwalk_map(&walk->out);
-}
-
static inline gfp_t skcipher_walk_gfp(struct skcipher_walk *walk)
{
return walk->flags & SKCIPHER_WALK_SLEEP ? GFP_KERNEL : GFP_ATOMIC;
@@ -101,8 +89,8 @@ int skcipher_walk_done(struct skcipher_walk *walk, int res)
scatterwalk_done_src(&walk->in, n);
} else if (walk->flags & SKCIPHER_WALK_COPY) {
scatterwalk_advance(&walk->in, n);
- skcipher_map_dst(walk);
- memcpy(walk->dst.virt.addr, walk->page, n);
+ scatterwalk_map(&walk->out);
+ memcpy(walk->out.addr, walk->page, n);
} else { /* SKCIPHER_WALK_SLOW */
if (res > 0) {
/*
@@ -186,9 +174,9 @@ static int skcipher_next_copy(struct skcipher_walk *walk)
{
void *tmp = walk->page;
- skcipher_map_src(walk);
- memcpy(tmp, walk->src.virt.addr, walk->nbytes);
- scatterwalk_unmap(walk->src.virt.addr);
+ scatterwalk_map(&walk->in);
+ memcpy(tmp, walk->in.addr, walk->nbytes);
+ scatterwalk_unmap(&walk->in);
/*
* walk->in is advanced later when the number of bytes actually
* processed (which might be less than walk->nbytes) is known.
@@ -208,12 +196,12 @@ static int skcipher_next_fast(struct skcipher_walk *walk)
diff |= (u8 *)(sg_page(walk->in.sg) + (walk->in.offset >> PAGE_SHIFT)) -
(u8 *)(sg_page(walk->out.sg) + (walk->out.offset >> PAGE_SHIFT));
- skcipher_map_dst(walk);
- walk->in.__addr = walk->dst.virt.addr;
+ scatterwalk_map(&walk->out);
+ walk->in.__addr = walk->out.__addr;
if (diff) {
walk->flags |= SKCIPHER_WALK_DIFF;
- skcipher_map_src(walk);
+ scatterwalk_map(&walk->in);
}
return 0;