aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/crypto/talitos.c
diff options
context:
space:
mode:
authorHoria Geanta <horia.geanta@freescale.com>2012-08-02 10:16:39 -0400
committerHerbert Xu <herbert@gondor.apana.org.au>2012-08-28 11:56:26 -0400
commit2a1cfe46b17f6dd43fcd8eb2b5e5deaa2a94e4bb (patch)
treee09ecb81f77bad938b737ce059f2755afd9c5b8a /drivers/crypto/talitos.c
parent602499a34247a890fd018c364c9bb6f9b931c1db (diff)
crypto: talitos - change type and name for [src|dst]_is_chained
It's more natural to think of these vars as bool rather than int. Signed-off-by: Horia Geanta <horia.geanta@freescale.com> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Diffstat (limited to 'drivers/crypto/talitos.c')
-rw-r--r--drivers/crypto/talitos.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c
index f0507d167c2f..2cba392f1682 100644
--- a/drivers/crypto/talitos.c
+++ b/drivers/crypto/talitos.c
@@ -716,6 +716,8 @@ badkey:
716 * talitos_edesc - s/w-extended descriptor 716 * talitos_edesc - s/w-extended descriptor
717 * @src_nents: number of segments in input scatterlist 717 * @src_nents: number of segments in input scatterlist
718 * @dst_nents: number of segments in output scatterlist 718 * @dst_nents: number of segments in output scatterlist
719 * @src_chained: whether src is chained or not
720 * @dst_chained: whether dst is chained or not
719 * @dma_len: length of dma mapped link_tbl space 721 * @dma_len: length of dma mapped link_tbl space
720 * @dma_link_tbl: bus physical address of link_tbl 722 * @dma_link_tbl: bus physical address of link_tbl
721 * @desc: h/w descriptor 723 * @desc: h/w descriptor
@@ -728,8 +730,8 @@ badkey:
728struct talitos_edesc { 730struct talitos_edesc {
729 int src_nents; 731 int src_nents;
730 int dst_nents; 732 int dst_nents;
731 int src_is_chained; 733 bool src_chained;
732 int dst_is_chained; 734 bool dst_chained;
733 int dma_len; 735 int dma_len;
734 dma_addr_t dma_link_tbl; 736 dma_addr_t dma_link_tbl;
735 struct talitos_desc desc; 737 struct talitos_desc desc;
@@ -738,7 +740,7 @@ struct talitos_edesc {
738 740
739static int talitos_map_sg(struct device *dev, struct scatterlist *sg, 741static int talitos_map_sg(struct device *dev, struct scatterlist *sg,
740 unsigned int nents, enum dma_data_direction dir, 742 unsigned int nents, enum dma_data_direction dir,
741 int chained) 743 bool chained)
742{ 744{
743 if (unlikely(chained)) 745 if (unlikely(chained))
744 while (sg) { 746 while (sg) {
@@ -768,13 +770,13 @@ static void talitos_sg_unmap(struct device *dev,
768 unsigned int dst_nents = edesc->dst_nents ? : 1; 770 unsigned int dst_nents = edesc->dst_nents ? : 1;
769 771
770 if (src != dst) { 772 if (src != dst) {
771 if (edesc->src_is_chained) 773 if (edesc->src_chained)
772 talitos_unmap_sg_chain(dev, src, DMA_TO_DEVICE); 774 talitos_unmap_sg_chain(dev, src, DMA_TO_DEVICE);
773 else 775 else
774 dma_unmap_sg(dev, src, src_nents, DMA_TO_DEVICE); 776 dma_unmap_sg(dev, src, src_nents, DMA_TO_DEVICE);
775 777
776 if (dst) { 778 if (dst) {
777 if (edesc->dst_is_chained) 779 if (edesc->dst_chained)
778 talitos_unmap_sg_chain(dev, dst, 780 talitos_unmap_sg_chain(dev, dst,
779 DMA_FROM_DEVICE); 781 DMA_FROM_DEVICE);
780 else 782 else
@@ -782,7 +784,7 @@ static void talitos_sg_unmap(struct device *dev,
782 DMA_FROM_DEVICE); 784 DMA_FROM_DEVICE);
783 } 785 }
784 } else 786 } else
785 if (edesc->src_is_chained) 787 if (edesc->src_chained)
786 talitos_unmap_sg_chain(dev, src, DMA_BIDIRECTIONAL); 788 talitos_unmap_sg_chain(dev, src, DMA_BIDIRECTIONAL);
787 else 789 else
788 dma_unmap_sg(dev, src, src_nents, DMA_BIDIRECTIONAL); 790 dma_unmap_sg(dev, src, src_nents, DMA_BIDIRECTIONAL);
@@ -974,7 +976,7 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
974 sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1, 976 sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1,
975 (areq->src == areq->dst) ? DMA_BIDIRECTIONAL 977 (areq->src == areq->dst) ? DMA_BIDIRECTIONAL
976 : DMA_TO_DEVICE, 978 : DMA_TO_DEVICE,
977 edesc->src_is_chained); 979 edesc->src_chained);
978 980
979 if (sg_count == 1) { 981 if (sg_count == 1) {
980 to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->src)); 982 to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->src));
@@ -1006,8 +1008,7 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
1006 if (areq->src != areq->dst) 1008 if (areq->src != areq->dst)
1007 sg_count = talitos_map_sg(dev, areq->dst, 1009 sg_count = talitos_map_sg(dev, areq->dst,
1008 edesc->dst_nents ? : 1, 1010 edesc->dst_nents ? : 1,
1009 DMA_FROM_DEVICE, 1011 DMA_FROM_DEVICE, edesc->dst_chained);
1010 edesc->dst_is_chained);
1011 1012
1012 if (sg_count == 1) { 1013 if (sg_count == 1) {
1013 to_talitos_ptr(&desc->ptr[5], sg_dma_address(areq->dst)); 1014 to_talitos_ptr(&desc->ptr[5], sg_dma_address(areq->dst));
@@ -1053,17 +1054,17 @@ static int ipsec_esp(struct talitos_edesc *edesc, struct aead_request *areq,
1053/* 1054/*
1054 * derive number of elements in scatterlist 1055 * derive number of elements in scatterlist
1055 */ 1056 */
1056static int sg_count(struct scatterlist *sg_list, int nbytes, int *chained) 1057static int sg_count(struct scatterlist *sg_list, int nbytes, bool *chained)
1057{ 1058{
1058 struct scatterlist *sg = sg_list; 1059 struct scatterlist *sg = sg_list;
1059 int sg_nents = 0; 1060 int sg_nents = 0;
1060 1061
1061 *chained = 0; 1062 *chained = false;
1062 while (nbytes > 0) { 1063 while (nbytes > 0) {
1063 sg_nents++; 1064 sg_nents++;
1064 nbytes -= sg->length; 1065 nbytes -= sg->length;
1065 if (!sg_is_last(sg) && (sg + 1)->length == 0) 1066 if (!sg_is_last(sg) && (sg + 1)->length == 0)
1066 *chained = 1; 1067 *chained = true;
1067 sg = scatterwalk_sg_next(sg); 1068 sg = scatterwalk_sg_next(sg);
1068 } 1069 }
1069 1070
@@ -1141,7 +1142,7 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
1141{ 1142{
1142 struct talitos_edesc *edesc; 1143 struct talitos_edesc *edesc;
1143 int src_nents, dst_nents, alloc_len, dma_len; 1144 int src_nents, dst_nents, alloc_len, dma_len;
1144 int src_chained, dst_chained = 0; 1145 bool src_chained, dst_chained = false;
1145 gfp_t flags = cryptoflags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL : 1146 gfp_t flags = cryptoflags & CRYPTO_TFM_REQ_MAY_SLEEP ? GFP_KERNEL :
1146 GFP_ATOMIC; 1147 GFP_ATOMIC;
1147 1148
@@ -1188,8 +1189,8 @@ static struct talitos_edesc *talitos_edesc_alloc(struct device *dev,
1188 1189
1189 edesc->src_nents = src_nents; 1190 edesc->src_nents = src_nents;
1190 edesc->dst_nents = dst_nents; 1191 edesc->dst_nents = dst_nents;
1191 edesc->src_is_chained = src_chained; 1192 edesc->src_chained = src_chained;
1192 edesc->dst_is_chained = dst_chained; 1193 edesc->dst_chained = dst_chained;
1193 edesc->dma_len = dma_len; 1194 edesc->dma_len = dma_len;
1194 if (dma_len) 1195 if (dma_len)
1195 edesc->dma_link_tbl = dma_map_single(dev, &edesc->link_tbl[0], 1196 edesc->dma_link_tbl = dma_map_single(dev, &edesc->link_tbl[0],
@@ -1381,7 +1382,7 @@ static int common_nonsnoop(struct talitos_edesc *edesc,
1381 sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1, 1382 sg_count = talitos_map_sg(dev, areq->src, edesc->src_nents ? : 1,
1382 (areq->src == areq->dst) ? DMA_BIDIRECTIONAL 1383 (areq->src == areq->dst) ? DMA_BIDIRECTIONAL
1383 : DMA_TO_DEVICE, 1384 : DMA_TO_DEVICE,
1384 edesc->src_is_chained); 1385 edesc->src_chained);
1385 1386
1386 if (sg_count == 1) { 1387 if (sg_count == 1) {
1387 to_talitos_ptr(&desc->ptr[3], sg_dma_address(areq->src)); 1388 to_talitos_ptr(&desc->ptr[3], sg_dma_address(areq->src));
@@ -1408,8 +1409,7 @@ static int common_nonsnoop(struct talitos_edesc *edesc,
1408 if (areq->src != areq->dst) 1409 if (areq->src != areq->dst)
1409 sg_count = talitos_map_sg(dev, areq->dst, 1410 sg_count = talitos_map_sg(dev, areq->dst,
1410 edesc->dst_nents ? : 1, 1411 edesc->dst_nents ? : 1,
1411 DMA_FROM_DEVICE, 1412 DMA_FROM_DEVICE, edesc->dst_chained);
1412 edesc->dst_is_chained);
1413 1413
1414 if (sg_count == 1) { 1414 if (sg_count == 1) {
1415 to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->dst)); 1415 to_talitos_ptr(&desc->ptr[4], sg_dma_address(areq->dst));
@@ -1577,8 +1577,7 @@ static int common_nonsnoop_hash(struct talitos_edesc *edesc,
1577 1577
1578 sg_count = talitos_map_sg(dev, req_ctx->psrc, 1578 sg_count = talitos_map_sg(dev, req_ctx->psrc,
1579 edesc->src_nents ? : 1, 1579 edesc->src_nents ? : 1,
1580 DMA_TO_DEVICE, 1580 DMA_TO_DEVICE, edesc->src_chained);
1581 edesc->src_is_chained);
1582 1581
1583 if (sg_count == 1) { 1582 if (sg_count == 1) {
1584 to_talitos_ptr(&desc->ptr[3], sg_dma_address(req_ctx->psrc)); 1583 to_talitos_ptr(&desc->ptr[3], sg_dma_address(req_ctx->psrc));
@@ -1689,7 +1688,7 @@ static int ahash_process_req(struct ahash_request *areq, unsigned int nbytes)
1689 unsigned int nbytes_to_hash; 1688 unsigned int nbytes_to_hash;
1690 unsigned int to_hash_later; 1689 unsigned int to_hash_later;
1691 unsigned int nsg; 1690 unsigned int nsg;
1692 int chained; 1691 bool chained;
1693 1692
1694 if (!req_ctx->last && (nbytes + req_ctx->nbuf <= blocksize)) { 1693 if (!req_ctx->last && (nbytes + req_ctx->nbuf <= blocksize)) {
1695 /* Buffer up to one whole block */ 1694 /* Buffer up to one whole block */