crypto: replace scatterwalk_sg_next with sg_next
authorCristian Stoica <cristian.stoica@freescale.com>
Tue, 20 Jan 2015 08:06:16 +0000 (10:06 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Mon, 26 Jan 2015 00:34:22 +0000 (11:34 +1100)
Modify crypto drivers to use the generic SG helper since
both of them are equivalent and the one from crypto is redundant.

See also:
  468577abe37ff7b453a9ac613e0ea155349203ae   reverted in
  b2ab4a57b018aafbba35bff088218f5cc3d2142e

Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
15 files changed:
crypto/ablkcipher.c
crypto/ahash.c
crypto/scatterwalk.c
drivers/crypto/bfin_crc.c
drivers/crypto/caam/sg_sw_sec4.h
drivers/crypto/ixp4xx_crypto.c
drivers/crypto/nx/nx.c
drivers/crypto/omap-aes.c
drivers/crypto/omap-des.c
drivers/crypto/qce/dma.c
drivers/crypto/qce/sha.c
drivers/crypto/sahara.c
drivers/crypto/talitos.c
drivers/crypto/ux500/cryp/cryp_core.c
include/crypto/scatterwalk.h

index 7bbc8b4ef2e99326201fd02a4ddc36e3c9d14f82..db201bca1581934f4b43bdffda642cec27ff816a 100644 (file)
@@ -87,8 +87,7 @@ static inline unsigned int ablkcipher_done_slow(struct ablkcipher_walk *walk,
                if (n == len_this_page)
                        break;
                n -= len_this_page;
-               scatterwalk_start(&walk->out, scatterwalk_sg_next(
-                       walk->out.sg));
+               scatterwalk_start(&walk->out, sg_next(walk->out.sg));
        }
 
        return bsize;
index dd2890608aebaaf0ae48848c7a42a49808ca3d85..8acb886032ae7a604fe0e965eb5d3ce07dd4845b 100644 (file)
@@ -121,7 +121,7 @@ int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err)
        if (!walk->total)
                return 0;
 
-       walk->sg = scatterwalk_sg_next(walk->sg);
+       walk->sg = sg_next(walk->sg);
 
        return hash_walk_new_entry(walk);
 }
index 79ca2278c2a38a6c022d7d3ccbae30981434e238..3bd749c7bb7062d33ee694e4131d13ce7c051c31 100644 (file)
@@ -62,7 +62,7 @@ static void scatterwalk_pagedone(struct scatter_walk *walk, int out,
                walk->offset += PAGE_SIZE - 1;
                walk->offset &= PAGE_MASK;
                if (walk->offset >= walk->sg->offset + walk->sg->length)
-                       scatterwalk_start(walk, scatterwalk_sg_next(walk->sg));
+                       scatterwalk_start(walk, sg_next(walk->sg));
        }
 }
 
@@ -116,7 +116,7 @@ void scatterwalk_map_and_copy(void *buf, struct scatterlist *sg,
                        break;
 
                offset += sg->length;
-               sg = scatterwalk_sg_next(sg);
+               sg = sg_next(sg);
        }
 
        scatterwalk_advance(&walk, start - offset);
@@ -136,7 +136,7 @@ int scatterwalk_bytes_sglen(struct scatterlist *sg, int num_bytes)
        do {
                offset += sg->length;
                n++;
-               sg = scatterwalk_sg_next(sg);
+               sg = sg_next(sg);
 
                /* num_bytes is too large */
                if (unlikely(!sg && (num_bytes < offset)))
index 33cf9eb87344d67fc1d5ec1d9927332643603b5d..d9af9403ab6cd3fdfd293699b46ae6836767c61d 100644 (file)
@@ -110,7 +110,7 @@ static int sg_count(struct scatterlist *sg_list)
 
        while (!sg_is_last(sg)) {
                sg_nents++;
-               sg = scatterwalk_sg_next(sg);
+               sg = sg_next(sg);
        }
 
        return sg_nents;
index ce28a563effc429487e154f6ce76d062dd421577..3b918218aa4c56436e378f595f45d2f2cc067e1a 100644 (file)
@@ -37,7 +37,7 @@ sg_to_sec4_sg(struct scatterlist *sg, int sg_count,
                dma_to_sec4_sg_one(sec4_sg_ptr, sg_dma_address(sg),
                                   sg_dma_len(sg), offset);
                sec4_sg_ptr++;
-               sg = scatterwalk_sg_next(sg);
+               sg = sg_next(sg);
                sg_count--;
        }
        return sec4_sg_ptr - 1;
@@ -67,7 +67,7 @@ static inline int __sg_count(struct scatterlist *sg_list, int nbytes,
                nbytes -= sg->length;
                if (!sg_is_last(sg) && (sg + 1)->length == 0)
                        *chained = true;
-               sg = scatterwalk_sg_next(sg);
+               sg = sg_next(sg);
        }
 
        return sg_nents;
@@ -93,7 +93,7 @@ static int dma_map_sg_chained(struct device *dev, struct scatterlist *sg,
                int i;
                for (i = 0; i < nents; i++) {
                        dma_map_sg(dev, sg, 1, dir);
-                       sg = scatterwalk_sg_next(sg);
+                       sg = sg_next(sg);
                }
        } else {
                dma_map_sg(dev, sg, nents, dir);
@@ -109,7 +109,7 @@ static int dma_unmap_sg_chained(struct device *dev, struct scatterlist *sg,
                int i;
                for (i = 0; i < nents; i++) {
                        dma_unmap_sg(dev, sg, 1, dir);
-                       sg = scatterwalk_sg_next(sg);
+                       sg = sg_next(sg);
                }
        } else {
                dma_unmap_sg(dev, sg, nents, dir);
index f757a0f428bde807a8e5402af8404e98314c2bf8..48f453555f1fe4572d4b3619b41e8b7dbb30d8a7 100644 (file)
@@ -784,7 +784,7 @@ static struct buffer_desc *chainup_buffers(struct device *dev,
                struct buffer_desc *buf, gfp_t flags,
                enum dma_data_direction dir)
 {
-       for (;nbytes > 0; sg = scatterwalk_sg_next(sg)) {
+       for (; nbytes > 0; sg = sg_next(sg)) {
                unsigned len = min(nbytes, sg->length);
                struct buffer_desc *next_buf;
                u32 next_buf_phys;
@@ -982,7 +982,7 @@ static int hmac_inconsistent(struct scatterlist *sg, unsigned start,
                        break;
 
                offset += sg->length;
-               sg = scatterwalk_sg_next(sg);
+               sg = sg_next(sg);
        }
        return (start + nbytes > offset + sg->length);
 }
index a392465d3e3fc5ef38cde9c09b56bef87a4ba2e7..1da6dc59d0dd1ccdbaae806fb0c5d23813c6772a 100644 (file)
@@ -177,7 +177,7 @@ struct nx_sg *nx_walk_and_build(struct nx_sg       *nx_dst,
                        break;
 
                offset += sg_src->length;
-               sg_src = scatterwalk_sg_next(sg_src);
+               sg_src = sg_next(sg_src);
        }
 
        /* start - offset is the number of bytes to advance in the scatterlist
@@ -187,9 +187,9 @@ struct nx_sg *nx_walk_and_build(struct nx_sg       *nx_dst,
        while (len && (nx_sg - nx_dst) < sglen) {
                n = scatterwalk_clamp(&walk, len);
                if (!n) {
-                       /* In cases where we have scatterlist chain scatterwalk_sg_next
+                       /* In cases where we have scatterlist chain sg_next
                         * handles with it properly */
-                       scatterwalk_start(&walk, scatterwalk_sg_next(walk.sg));
+                       scatterwalk_start(&walk, sg_next(walk.sg));
                        n = scatterwalk_clamp(&walk, len);
                }
                dst = scatterwalk_map(&walk);
index f79dd410dede65c90b03e008b376375f4bb8e5d4..42f95a4326b0717fb4b55626add069037ecca9e8 100644 (file)
@@ -994,7 +994,7 @@ static irqreturn_t omap_aes_irq(int irq, void *dev_id)
 
                        scatterwalk_advance(&dd->in_walk, 4);
                        if (dd->in_sg->length == _calc_walked(in)) {
-                               dd->in_sg = scatterwalk_sg_next(dd->in_sg);
+                               dd->in_sg = sg_next(dd->in_sg);
                                if (dd->in_sg) {
                                        scatterwalk_start(&dd->in_walk,
                                                          dd->in_sg);
@@ -1026,7 +1026,7 @@ static irqreturn_t omap_aes_irq(int irq, void *dev_id)
                        *dst = omap_aes_read(dd, AES_REG_DATA_N(dd, i));
                        scatterwalk_advance(&dd->out_walk, 4);
                        if (dd->out_sg->length == _calc_walked(out)) {
-                               dd->out_sg = scatterwalk_sg_next(dd->out_sg);
+                               dd->out_sg = sg_next(dd->out_sg);
                                if (dd->out_sg) {
                                        scatterwalk_start(&dd->out_walk,
                                                          dd->out_sg);
index 0b8dcf5eb74eb223c75b2d863fd79f1b7c11e021..46307098f8bab497734ca5dbbfb7fe2502ed082f 100644 (file)
@@ -921,7 +921,7 @@ static irqreturn_t omap_des_irq(int irq, void *dev_id)
 
                        scatterwalk_advance(&dd->in_walk, 4);
                        if (dd->in_sg->length == _calc_walked(in)) {
-                               dd->in_sg = scatterwalk_sg_next(dd->in_sg);
+                               dd->in_sg = sg_next(dd->in_sg);
                                if (dd->in_sg) {
                                        scatterwalk_start(&dd->in_walk,
                                                          dd->in_sg);
@@ -953,7 +953,7 @@ static irqreturn_t omap_des_irq(int irq, void *dev_id)
                        *dst = omap_des_read(dd, DES_REG_DATA_N(dd, i));
                        scatterwalk_advance(&dd->out_walk, 4);
                        if (dd->out_sg->length == _calc_walked(out)) {
-                               dd->out_sg = scatterwalk_sg_next(dd->out_sg);
+                               dd->out_sg = sg_next(dd->out_sg);
                                if (dd->out_sg) {
                                        scatterwalk_start(&dd->out_walk,
                                                          dd->out_sg);
index 0fb21e13f247086375b0939fbd368dbe8d103a8d..378cb768647f6f7306c94485cc4a5c5347ffe173 100644 (file)
@@ -64,7 +64,7 @@ int qce_mapsg(struct device *dev, struct scatterlist *sg, int nents,
                        err = dma_map_sg(dev, sg, 1, dir);
                        if (!err)
                                return -EFAULT;
-                       sg = scatterwalk_sg_next(sg);
+                       sg = sg_next(sg);
                }
        } else {
                err = dma_map_sg(dev, sg, nents, dir);
@@ -81,7 +81,7 @@ void qce_unmapsg(struct device *dev, struct scatterlist *sg, int nents,
        if (chained)
                while (sg) {
                        dma_unmap_sg(dev, sg, 1, dir);
-                       sg = scatterwalk_sg_next(sg);
+                       sg = sg_next(sg);
                }
        else
                dma_unmap_sg(dev, sg, nents, dir);
@@ -100,7 +100,7 @@ int qce_countsg(struct scatterlist *sglist, int nbytes, bool *chained)
                nbytes -= sg->length;
                if (!sg_is_last(sg) && (sg + 1)->length == 0 && chained)
                        *chained = true;
-               sg = scatterwalk_sg_next(sg);
+               sg = sg_next(sg);
        }
 
        return nents;
index f3385934eed2334de7efa95f2e9d0c41d30209fe..5c5df1d17f90036d95b90247fe9e0c4d164968c9 100644 (file)
@@ -285,7 +285,7 @@ static int qce_ahash_update(struct ahash_request *req)
                        break;
                len += sg_dma_len(sg);
                sg_last = sg;
-               sg = scatterwalk_sg_next(sg);
+               sg = sg_next(sg);
        }
 
        if (!sg_last)
index 220b92f7eabcabfee7cdc85014d79582c0273c4b..290a7f0a681fb878aa922056d4ad1cf2216836ec 100644 (file)
@@ -940,7 +940,7 @@ static int sahara_walk_and_recalc(struct scatterlist *sg, unsigned int nbytes)
                        break;
                }
                nbytes -= sg->length;
-               sg = scatterwalk_sg_next(sg);
+               sg = sg_next(sg);
        }
 
        return nbytes;
index 067ec2193d718dbb05d4b45fe4a53a11224ad989..ebbae8d3ce0dcb1aa7fc0e1fcc99c465f9731fb0 100644 (file)
@@ -743,7 +743,7 @@ static int talitos_map_sg(struct device *dev, struct scatterlist *sg,
        if (unlikely(chained))
                while (sg) {
                        dma_map_sg(dev, sg, 1, dir);
-                       sg = scatterwalk_sg_next(sg);
+                       sg = sg_next(sg);
                }
        else
                dma_map_sg(dev, sg, nents, dir);
@@ -755,7 +755,7 @@ static void talitos_unmap_sg_chain(struct device *dev, struct scatterlist *sg,
 {
        while (sg) {
                dma_unmap_sg(dev, sg, 1, dir);
-               sg = scatterwalk_sg_next(sg);
+               sg = sg_next(sg);
        }
 }
 
@@ -915,7 +915,7 @@ static int sg_to_link_tbl(struct scatterlist *sg, int sg_count,
                link_tbl_ptr->j_extent = 0;
                link_tbl_ptr++;
                cryptlen -= sg_dma_len(sg);
-               sg = scatterwalk_sg_next(sg);
+               sg = sg_next(sg);
        }
 
        /* adjust (decrease) last one (or two) entry's len to cryptlen */
@@ -1102,7 +1102,7 @@ static int sg_count(struct scatterlist *sg_list, int nbytes, bool *chained)
                nbytes -= sg->length;
                if (!sg_is_last(sg) && (sg + 1)->length == 0)
                        *chained = true;
-               sg = scatterwalk_sg_next(sg);
+               sg = sg_next(sg);
        }
 
        return sg_nents;
index f087f37b2c6751b7d67869c9a9d346554a222d58..d594ae962ed28305a0a610698fbfbede4c80c8ea 100644 (file)
@@ -814,7 +814,7 @@ static int get_nents(struct scatterlist *sg, int nbytes)
 
        while (nbytes > 0) {
                nbytes -= sg->length;
-               sg = scatterwalk_sg_next(sg);
+               sg = sg_next(sg);
                nents++;
        }
 
index 7ef512f8631c134be5f37589a57f1824bc42742b..20e4226a2e14e68e3a5e6fc6541993ff228919d7 100644 (file)
@@ -33,21 +33,13 @@ static inline void scatterwalk_sg_chain(struct scatterlist *sg1, int num,
        sg1[num - 1].page_link |= 0x01;
 }
 
-static inline struct scatterlist *scatterwalk_sg_next(struct scatterlist *sg)
-{
-       if (sg_is_last(sg))
-               return NULL;
-
-       return (++sg)->length ? sg : sg_chain_ptr(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);
+               sg = sg_next(sg);
        }
 
        if (sg)