crypto: replace scatterwalk_sg_next with sg_next
Modify crypto drivers to use the generic SG helper since both of them are equivalent and the one from crypto is redundant. See also:468577abe3
reverted inb2ab4a57b0
Signed-off-by: Cristian Stoica <cristian.stoica@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
This commit is contained in:
Родитель
088f628cc0
Коммит
5be4d4c94b
|
@ -87,8 +87,7 @@ static inline unsigned int ablkcipher_done_slow(struct ablkcipher_walk *walk,
|
||||||
if (n == len_this_page)
|
if (n == len_this_page)
|
||||||
break;
|
break;
|
||||||
n -= len_this_page;
|
n -= len_this_page;
|
||||||
scatterwalk_start(&walk->out, scatterwalk_sg_next(
|
scatterwalk_start(&walk->out, sg_next(walk->out.sg));
|
||||||
walk->out.sg));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return bsize;
|
return bsize;
|
||||||
|
|
|
@ -121,7 +121,7 @@ int crypto_hash_walk_done(struct crypto_hash_walk *walk, int err)
|
||||||
if (!walk->total)
|
if (!walk->total)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
walk->sg = scatterwalk_sg_next(walk->sg);
|
walk->sg = sg_next(walk->sg);
|
||||||
|
|
||||||
return hash_walk_new_entry(walk);
|
return hash_walk_new_entry(walk);
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ static void scatterwalk_pagedone(struct scatter_walk *walk, int out,
|
||||||
walk->offset += PAGE_SIZE - 1;
|
walk->offset += PAGE_SIZE - 1;
|
||||||
walk->offset &= PAGE_MASK;
|
walk->offset &= PAGE_MASK;
|
||||||
if (walk->offset >= walk->sg->offset + walk->sg->length)
|
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;
|
break;
|
||||||
|
|
||||||
offset += sg->length;
|
offset += sg->length;
|
||||||
sg = scatterwalk_sg_next(sg);
|
sg = sg_next(sg);
|
||||||
}
|
}
|
||||||
|
|
||||||
scatterwalk_advance(&walk, start - offset);
|
scatterwalk_advance(&walk, start - offset);
|
||||||
|
@ -136,7 +136,7 @@ int scatterwalk_bytes_sglen(struct scatterlist *sg, int num_bytes)
|
||||||
do {
|
do {
|
||||||
offset += sg->length;
|
offset += sg->length;
|
||||||
n++;
|
n++;
|
||||||
sg = scatterwalk_sg_next(sg);
|
sg = sg_next(sg);
|
||||||
|
|
||||||
/* num_bytes is too large */
|
/* num_bytes is too large */
|
||||||
if (unlikely(!sg && (num_bytes < offset)))
|
if (unlikely(!sg && (num_bytes < offset)))
|
||||||
|
|
|
@ -110,7 +110,7 @@ static int sg_count(struct scatterlist *sg_list)
|
||||||
|
|
||||||
while (!sg_is_last(sg)) {
|
while (!sg_is_last(sg)) {
|
||||||
sg_nents++;
|
sg_nents++;
|
||||||
sg = scatterwalk_sg_next(sg);
|
sg = sg_next(sg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sg_nents;
|
return sg_nents;
|
||||||
|
|
|
@ -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),
|
dma_to_sec4_sg_one(sec4_sg_ptr, sg_dma_address(sg),
|
||||||
sg_dma_len(sg), offset);
|
sg_dma_len(sg), offset);
|
||||||
sec4_sg_ptr++;
|
sec4_sg_ptr++;
|
||||||
sg = scatterwalk_sg_next(sg);
|
sg = sg_next(sg);
|
||||||
sg_count--;
|
sg_count--;
|
||||||
}
|
}
|
||||||
return sec4_sg_ptr - 1;
|
return sec4_sg_ptr - 1;
|
||||||
|
@ -67,7 +67,7 @@ static inline int __sg_count(struct scatterlist *sg_list, int nbytes,
|
||||||
nbytes -= sg->length;
|
nbytes -= sg->length;
|
||||||
if (!sg_is_last(sg) && (sg + 1)->length == 0)
|
if (!sg_is_last(sg) && (sg + 1)->length == 0)
|
||||||
*chained = true;
|
*chained = true;
|
||||||
sg = scatterwalk_sg_next(sg);
|
sg = sg_next(sg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sg_nents;
|
return sg_nents;
|
||||||
|
@ -93,7 +93,7 @@ static int dma_map_sg_chained(struct device *dev, struct scatterlist *sg,
|
||||||
int i;
|
int i;
|
||||||
for (i = 0; i < nents; i++) {
|
for (i = 0; i < nents; i++) {
|
||||||
dma_map_sg(dev, sg, 1, dir);
|
dma_map_sg(dev, sg, 1, dir);
|
||||||
sg = scatterwalk_sg_next(sg);
|
sg = sg_next(sg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dma_map_sg(dev, sg, nents, dir);
|
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;
|
int i;
|
||||||
for (i = 0; i < nents; i++) {
|
for (i = 0; i < nents; i++) {
|
||||||
dma_unmap_sg(dev, sg, 1, dir);
|
dma_unmap_sg(dev, sg, 1, dir);
|
||||||
sg = scatterwalk_sg_next(sg);
|
sg = sg_next(sg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
dma_unmap_sg(dev, sg, nents, dir);
|
dma_unmap_sg(dev, sg, nents, dir);
|
||||||
|
|
|
@ -784,7 +784,7 @@ static struct buffer_desc *chainup_buffers(struct device *dev,
|
||||||
struct buffer_desc *buf, gfp_t flags,
|
struct buffer_desc *buf, gfp_t flags,
|
||||||
enum dma_data_direction dir)
|
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);
|
unsigned len = min(nbytes, sg->length);
|
||||||
struct buffer_desc *next_buf;
|
struct buffer_desc *next_buf;
|
||||||
u32 next_buf_phys;
|
u32 next_buf_phys;
|
||||||
|
@ -982,7 +982,7 @@ static int hmac_inconsistent(struct scatterlist *sg, unsigned start,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
offset += sg->length;
|
offset += sg->length;
|
||||||
sg = scatterwalk_sg_next(sg);
|
sg = sg_next(sg);
|
||||||
}
|
}
|
||||||
return (start + nbytes > offset + sg->length);
|
return (start + nbytes > offset + sg->length);
|
||||||
}
|
}
|
||||||
|
|
|
@ -177,7 +177,7 @@ struct nx_sg *nx_walk_and_build(struct nx_sg *nx_dst,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
offset += sg_src->length;
|
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
|
/* 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) {
|
while (len && (nx_sg - nx_dst) < sglen) {
|
||||||
n = scatterwalk_clamp(&walk, len);
|
n = scatterwalk_clamp(&walk, len);
|
||||||
if (!n) {
|
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 */
|
* handles with it properly */
|
||||||
scatterwalk_start(&walk, scatterwalk_sg_next(walk.sg));
|
scatterwalk_start(&walk, sg_next(walk.sg));
|
||||||
n = scatterwalk_clamp(&walk, len);
|
n = scatterwalk_clamp(&walk, len);
|
||||||
}
|
}
|
||||||
dst = scatterwalk_map(&walk);
|
dst = scatterwalk_map(&walk);
|
||||||
|
|
|
@ -994,7 +994,7 @@ static irqreturn_t omap_aes_irq(int irq, void *dev_id)
|
||||||
|
|
||||||
scatterwalk_advance(&dd->in_walk, 4);
|
scatterwalk_advance(&dd->in_walk, 4);
|
||||||
if (dd->in_sg->length == _calc_walked(in)) {
|
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) {
|
if (dd->in_sg) {
|
||||||
scatterwalk_start(&dd->in_walk,
|
scatterwalk_start(&dd->in_walk,
|
||||||
dd->in_sg);
|
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));
|
*dst = omap_aes_read(dd, AES_REG_DATA_N(dd, i));
|
||||||
scatterwalk_advance(&dd->out_walk, 4);
|
scatterwalk_advance(&dd->out_walk, 4);
|
||||||
if (dd->out_sg->length == _calc_walked(out)) {
|
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) {
|
if (dd->out_sg) {
|
||||||
scatterwalk_start(&dd->out_walk,
|
scatterwalk_start(&dd->out_walk,
|
||||||
dd->out_sg);
|
dd->out_sg);
|
||||||
|
|
|
@ -921,7 +921,7 @@ static irqreturn_t omap_des_irq(int irq, void *dev_id)
|
||||||
|
|
||||||
scatterwalk_advance(&dd->in_walk, 4);
|
scatterwalk_advance(&dd->in_walk, 4);
|
||||||
if (dd->in_sg->length == _calc_walked(in)) {
|
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) {
|
if (dd->in_sg) {
|
||||||
scatterwalk_start(&dd->in_walk,
|
scatterwalk_start(&dd->in_walk,
|
||||||
dd->in_sg);
|
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));
|
*dst = omap_des_read(dd, DES_REG_DATA_N(dd, i));
|
||||||
scatterwalk_advance(&dd->out_walk, 4);
|
scatterwalk_advance(&dd->out_walk, 4);
|
||||||
if (dd->out_sg->length == _calc_walked(out)) {
|
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) {
|
if (dd->out_sg) {
|
||||||
scatterwalk_start(&dd->out_walk,
|
scatterwalk_start(&dd->out_walk,
|
||||||
dd->out_sg);
|
dd->out_sg);
|
||||||
|
|
|
@ -64,7 +64,7 @@ int qce_mapsg(struct device *dev, struct scatterlist *sg, int nents,
|
||||||
err = dma_map_sg(dev, sg, 1, dir);
|
err = dma_map_sg(dev, sg, 1, dir);
|
||||||
if (!err)
|
if (!err)
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
sg = scatterwalk_sg_next(sg);
|
sg = sg_next(sg);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
err = dma_map_sg(dev, sg, nents, dir);
|
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)
|
if (chained)
|
||||||
while (sg) {
|
while (sg) {
|
||||||
dma_unmap_sg(dev, sg, 1, dir);
|
dma_unmap_sg(dev, sg, 1, dir);
|
||||||
sg = scatterwalk_sg_next(sg);
|
sg = sg_next(sg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dma_unmap_sg(dev, sg, nents, dir);
|
dma_unmap_sg(dev, sg, nents, dir);
|
||||||
|
@ -100,7 +100,7 @@ int qce_countsg(struct scatterlist *sglist, int nbytes, bool *chained)
|
||||||
nbytes -= sg->length;
|
nbytes -= sg->length;
|
||||||
if (!sg_is_last(sg) && (sg + 1)->length == 0 && chained)
|
if (!sg_is_last(sg) && (sg + 1)->length == 0 && chained)
|
||||||
*chained = true;
|
*chained = true;
|
||||||
sg = scatterwalk_sg_next(sg);
|
sg = sg_next(sg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nents;
|
return nents;
|
||||||
|
|
|
@ -285,7 +285,7 @@ static int qce_ahash_update(struct ahash_request *req)
|
||||||
break;
|
break;
|
||||||
len += sg_dma_len(sg);
|
len += sg_dma_len(sg);
|
||||||
sg_last = sg;
|
sg_last = sg;
|
||||||
sg = scatterwalk_sg_next(sg);
|
sg = sg_next(sg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!sg_last)
|
if (!sg_last)
|
||||||
|
|
|
@ -940,7 +940,7 @@ static int sahara_walk_and_recalc(struct scatterlist *sg, unsigned int nbytes)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
nbytes -= sg->length;
|
nbytes -= sg->length;
|
||||||
sg = scatterwalk_sg_next(sg);
|
sg = sg_next(sg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return nbytes;
|
return nbytes;
|
||||||
|
|
|
@ -743,7 +743,7 @@ static int talitos_map_sg(struct device *dev, struct scatterlist *sg,
|
||||||
if (unlikely(chained))
|
if (unlikely(chained))
|
||||||
while (sg) {
|
while (sg) {
|
||||||
dma_map_sg(dev, sg, 1, dir);
|
dma_map_sg(dev, sg, 1, dir);
|
||||||
sg = scatterwalk_sg_next(sg);
|
sg = sg_next(sg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
dma_map_sg(dev, sg, nents, dir);
|
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) {
|
while (sg) {
|
||||||
dma_unmap_sg(dev, sg, 1, dir);
|
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->j_extent = 0;
|
||||||
link_tbl_ptr++;
|
link_tbl_ptr++;
|
||||||
cryptlen -= sg_dma_len(sg);
|
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 */
|
/* 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;
|
nbytes -= sg->length;
|
||||||
if (!sg_is_last(sg) && (sg + 1)->length == 0)
|
if (!sg_is_last(sg) && (sg + 1)->length == 0)
|
||||||
*chained = true;
|
*chained = true;
|
||||||
sg = scatterwalk_sg_next(sg);
|
sg = sg_next(sg);
|
||||||
}
|
}
|
||||||
|
|
||||||
return sg_nents;
|
return sg_nents;
|
||||||
|
|
|
@ -814,7 +814,7 @@ static int get_nents(struct scatterlist *sg, int nbytes)
|
||||||
|
|
||||||
while (nbytes > 0) {
|
while (nbytes > 0) {
|
||||||
nbytes -= sg->length;
|
nbytes -= sg->length;
|
||||||
sg = scatterwalk_sg_next(sg);
|
sg = sg_next(sg);
|
||||||
nents++;
|
nents++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,21 +33,13 @@ static inline void scatterwalk_sg_chain(struct scatterlist *sg1, int num,
|
||||||
sg1[num - 1].page_link |= 0x01;
|
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,
|
static inline void scatterwalk_crypto_chain(struct scatterlist *head,
|
||||||
struct scatterlist *sg,
|
struct scatterlist *sg,
|
||||||
int chain, int num)
|
int chain, int num)
|
||||||
{
|
{
|
||||||
if (chain) {
|
if (chain) {
|
||||||
head->length += sg->length;
|
head->length += sg->length;
|
||||||
sg = scatterwalk_sg_next(sg);
|
sg = sg_next(sg);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sg)
|
if (sg)
|
||||||
|
|
Загрузка…
Ссылка в новой задаче