These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / crypto / caam / sg_sw_sec4.h
index 3b91821..12ec661 100644 (file)
@@ -15,7 +15,6 @@ static inline void dma_to_sec4_sg_one(struct sec4_sg_entry *sec4_sg_ptr,
 {
        sec4_sg_ptr->ptr = dma;
        sec4_sg_ptr->len = len;
-       sec4_sg_ptr->reserved = 0;
        sec4_sg_ptr->buf_pool_id = 0;
        sec4_sg_ptr->offset = offset;
 #ifdef DEBUG
@@ -55,64 +54,28 @@ static inline void sg_to_sec4_sg_last(struct scatterlist *sg, int sg_count,
        sec4_sg_ptr->len |= SEC4_SG_LEN_FIN;
 }
 
-/* count number of elements in scatterlist */
-static inline int __sg_count(struct scatterlist *sg_list, int nbytes,
-                            bool *chained)
+static inline struct sec4_sg_entry *sg_to_sec4_sg_len(
+       struct scatterlist *sg, unsigned int total,
+       struct sec4_sg_entry *sec4_sg_ptr)
 {
-       struct scatterlist *sg = sg_list;
-       int sg_nents = 0;
+       do {
+               unsigned int len = min(sg_dma_len(sg), total);
 
-       while (nbytes > 0) {
-               sg_nents++;
-               nbytes -= sg->length;
-               if (!sg_is_last(sg) && (sg + 1)->length == 0)
-                       *chained = true;
+               dma_to_sec4_sg_one(sec4_sg_ptr, sg_dma_address(sg), len, 0);
+               sec4_sg_ptr++;
                sg = sg_next(sg);
-       }
-
-       return sg_nents;
+               total -= len;
+       } while (total);
+       return sec4_sg_ptr - 1;
 }
 
 /* derive number of elements in scatterlist, but return 0 for 1 */
-static inline int sg_count(struct scatterlist *sg_list, int nbytes,
-                            bool *chained)
+static inline int sg_count(struct scatterlist *sg_list, int nbytes)
 {
-       int sg_nents = __sg_count(sg_list, nbytes, chained);
+       int sg_nents = sg_nents_for_len(sg_list, nbytes);
 
        if (likely(sg_nents == 1))
                return 0;
 
        return sg_nents;
 }
-
-static int dma_map_sg_chained(struct device *dev, struct scatterlist *sg,
-                             unsigned int nents, enum dma_data_direction dir,
-                             bool chained)
-{
-       if (unlikely(chained)) {
-               int i;
-               for (i = 0; i < nents; i++) {
-                       dma_map_sg(dev, sg, 1, dir);
-                       sg = sg_next(sg);
-               }
-       } else {
-               dma_map_sg(dev, sg, nents, dir);
-       }
-       return nents;
-}
-
-static int dma_unmap_sg_chained(struct device *dev, struct scatterlist *sg,
-                               unsigned int nents, enum dma_data_direction dir,
-                               bool chained)
-{
-       if (unlikely(chained)) {
-               int i;
-               for (i = 0; i < nents; i++) {
-                       dma_unmap_sg(dev, sg, 1, dir);
-                       sg = sg_next(sg);
-               }
-       } else {
-               dma_unmap_sg(dev, sg, nents, dir);
-       }
-       return nents;
-}