diff options
Diffstat (limited to 'drivers/crypto')
-rw-r--r-- | drivers/crypto/caam/caamhash.c | 2 | ||||
-rw-r--r-- | drivers/crypto/talitos.c | 60 |
2 files changed, 2 insertions, 60 deletions
diff --git a/drivers/crypto/caam/caamhash.c b/drivers/crypto/caam/caamhash.c index aa65c6e0c430..e732bd962e98 100644 --- a/drivers/crypto/caam/caamhash.c +++ b/drivers/crypto/caam/caamhash.c | |||
@@ -428,7 +428,7 @@ static int hash_digest_key(struct caam_hash_ctx *ctx, const u8 *key_in, | |||
428 | dma_addr_t src_dma, dst_dma; | 428 | dma_addr_t src_dma, dst_dma; |
429 | int ret = 0; | 429 | int ret = 0; |
430 | 430 | ||
431 | desc = kmalloc(CAAM_CMD_SZ * 6 + CAAM_PTR_SZ * 2, GFP_KERNEL | GFP_DMA); | 431 | desc = kmalloc(CAAM_CMD_SZ * 8 + CAAM_PTR_SZ * 2, GFP_KERNEL | GFP_DMA); |
432 | if (!desc) { | 432 | if (!desc) { |
433 | dev_err(jrdev, "unable to allocate key input memory\n"); | 433 | dev_err(jrdev, "unable to allocate key input memory\n"); |
434 | return -ENOMEM; | 434 | return -ENOMEM; |
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 5b2b5e61e4f9..661dc3eb1d66 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c | |||
@@ -1112,64 +1112,6 @@ static int sg_count(struct scatterlist *sg_list, int nbytes, bool *chained) | |||
1112 | return sg_nents; | 1112 | return sg_nents; |
1113 | } | 1113 | } |
1114 | 1114 | ||
1115 | /** | ||
1116 | * sg_copy_end_to_buffer - Copy end data from SG list to a linear buffer | ||
1117 | * @sgl: The SG list | ||
1118 | * @nents: Number of SG entries | ||
1119 | * @buf: Where to copy to | ||
1120 | * @buflen: The number of bytes to copy | ||
1121 | * @skip: The number of bytes to skip before copying. | ||
1122 | * Note: skip + buflen should equal SG total size. | ||
1123 | * | ||
1124 | * Returns the number of copied bytes. | ||
1125 | * | ||
1126 | **/ | ||
1127 | static size_t sg_copy_end_to_buffer(struct scatterlist *sgl, unsigned int nents, | ||
1128 | void *buf, size_t buflen, unsigned int skip) | ||
1129 | { | ||
1130 | unsigned int offset = 0; | ||
1131 | unsigned int boffset = 0; | ||
1132 | struct sg_mapping_iter miter; | ||
1133 | unsigned long flags; | ||
1134 | unsigned int sg_flags = SG_MITER_ATOMIC; | ||
1135 | size_t total_buffer = buflen + skip; | ||
1136 | |||
1137 | sg_flags |= SG_MITER_FROM_SG; | ||
1138 | |||
1139 | sg_miter_start(&miter, sgl, nents, sg_flags); | ||
1140 | |||
1141 | local_irq_save(flags); | ||
1142 | |||
1143 | while (sg_miter_next(&miter) && offset < total_buffer) { | ||
1144 | unsigned int len; | ||
1145 | unsigned int ignore; | ||
1146 | |||
1147 | if ((offset + miter.length) > skip) { | ||
1148 | if (offset < skip) { | ||
1149 | /* Copy part of this segment */ | ||
1150 | ignore = skip - offset; | ||
1151 | len = miter.length - ignore; | ||
1152 | if (boffset + len > buflen) | ||
1153 | len = buflen - boffset; | ||
1154 | memcpy(buf + boffset, miter.addr + ignore, len); | ||
1155 | } else { | ||
1156 | /* Copy all of this segment (up to buflen) */ | ||
1157 | len = miter.length; | ||
1158 | if (boffset + len > buflen) | ||
1159 | len = buflen - boffset; | ||
1160 | memcpy(buf + boffset, miter.addr, len); | ||
1161 | } | ||
1162 | boffset += len; | ||
1163 | } | ||
1164 | offset += miter.length; | ||
1165 | } | ||
1166 | |||
1167 | sg_miter_stop(&miter); | ||
1168 | |||
1169 | local_irq_restore(flags); | ||
1170 | return boffset; | ||
1171 | } | ||
1172 | |||
1173 | /* | 1115 | /* |
1174 | * allocate and map the extended descriptor | 1116 | * allocate and map the extended descriptor |
1175 | */ | 1117 | */ |
@@ -1800,7 +1742,7 @@ static int ahash_process_req(struct ahash_request *areq, unsigned int nbytes) | |||
1800 | 1742 | ||
1801 | if (to_hash_later) { | 1743 | if (to_hash_later) { |
1802 | int nents = sg_count(areq->src, nbytes, &chained); | 1744 | int nents = sg_count(areq->src, nbytes, &chained); |
1803 | sg_copy_end_to_buffer(areq->src, nents, | 1745 | sg_pcopy_to_buffer(areq->src, nents, |
1804 | req_ctx->bufnext, | 1746 | req_ctx->bufnext, |
1805 | to_hash_later, | 1747 | to_hash_later, |
1806 | nbytes - to_hash_later); | 1748 | nbytes - to_hash_later); |