ChangeSet 1.2199.14.26, 2005/03/23 12:08:10-08:00, [EMAIL PROTECTED]

        [CRYPTO]: Split src/dst handling out from crypt()
        
        Move src/dst handling from crypt() into the helpers prepare_src,
        prepare_dst, complete_src and complete_dst.  complete_src doesn't
        actually do anything at the moment but is included for completeness.
        
        This sets the stage for further optimisations down the track without
        polluting crypt() itself.
        
        These helpers don't belong in scatterwalk.[ch] since they only help
        the particular way that crypt() is walking the scatter lists.
        Signed-off-by: David S. Miller <[EMAIL PROTECTED]>



 cipher.c |   46 +++++++++++++++++++++++++++++++++++-----------
 1 files changed, 35 insertions(+), 11 deletions(-)


diff -Nru a/crypto/cipher.c b/crypto/cipher.c
--- a/crypto/cipher.c   2005-03-26 17:23:13 -08:00
+++ b/crypto/cipher.c   2005-03-26 17:23:13 -08:00
@@ -38,7 +38,38 @@
        ((u32 *)a)[2] ^= ((u32 *)b)[2];
        ((u32 *)a)[3] ^= ((u32 *)b)[3];
 }
+ 
+static inline void *prepare_src(struct scatter_walk *walk, int bsize,
+                               void *tmp, int in_place)
+{
+       void *src = walk->data;
+
+       if (unlikely(scatterwalk_across_pages(walk, bsize)))
+               src = tmp;
+       scatterwalk_copychunks(src, walk, bsize, 0);
+       return src;
+}
 
+static inline void *prepare_dst(struct scatter_walk *walk, int bsize,
+                               void *tmp, int in_place)
+{
+       void *dst = walk->data;
+
+       if (unlikely(scatterwalk_across_pages(walk, bsize)) || in_place)
+               dst = tmp;
+       return dst;
+}
+
+static inline void complete_src(struct scatter_walk *walk, int bsize,
+                               void *src, int in_place)
+{
+}
+
+static inline void complete_dst(struct scatter_walk *walk, int bsize,
+                               void *dst, int in_place)
+{
+       scatterwalk_copychunks(dst, walk, bsize, 1);
+}
 
 /* 
  * Generic encrypt/decrypt wrapper for ciphers, handles operations across
@@ -76,24 +107,17 @@
 
                in_place = scatterwalk_samebuf(&walk_in, &walk_out);
 
-               src_p = walk_in.data;
-               if (unlikely(scatterwalk_across_pages(&walk_in, bsize)))
-                       src_p = tmp_src;
-
-               dst_p = walk_out.data;
-               if (unlikely(scatterwalk_across_pages(&walk_out, bsize)) ||
-                   in_place)
-                       dst_p = tmp_dst;
+               src_p = prepare_src(&walk_in, bsize, tmp_src, in_place);
+               dst_p = prepare_dst(&walk_out, bsize, tmp_dst, in_place);
 
                nbytes -= bsize;
 
-               scatterwalk_copychunks(src_p, &walk_in, bsize, 0);
-
                prfn(tfm, dst_p, src_p, crfn, enc, info);
 
+               complete_src(&walk_in, bsize, src_p, in_place);
                scatterwalk_done(&walk_in, 0, nbytes);
 
-               scatterwalk_copychunks(dst_p, &walk_out, bsize, 1);
+               complete_dst(&walk_out, bsize, dst_p, in_place);
                scatterwalk_done(&walk_out, 1, nbytes);
 
                if (!nbytes)
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to