]> git.karo-electronics.de Git - mv-sheeva.git/blobdiff - include/crypto/scatterwalk.h
Merge branch 'for-2.6.38/drivers' of git://git.kernel.dk/linux-2.6-block
[mv-sheeva.git] / include / crypto / scatterwalk.h
index 07b6f17122d2e968ddede9281f94fb65754e806c..4fd95a323beb295ddf9efbe1dfb8a63db15c3a09 100644 (file)
@@ -23,6 +23,7 @@
 #include <linux/kernel.h>
 #include <linux/mm.h>
 #include <linux/scatterlist.h>
+#include <linux/sched.h>
 
 static inline enum km_type crypto_kmap_type(int out)
 {
@@ -52,6 +53,36 @@ static inline void crypto_yield(u32 flags)
                cond_resched();
 }
 
+static inline void scatterwalk_sg_chain(struct scatterlist *sg1, int num,
+                                       struct scatterlist *sg2)
+{
+       sg_set_page(&sg1[num - 1], (void *)sg2, 0, 0);
+       sg1[num - 1].page_link &= ~0x02;
+}
+
+static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg)
+{
+       if (sg_is_last(sg))
+               return NULL;
+
+       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)
 {