@@ -299,21 +299,20 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
299
299
300
300
struct scatterlist * dst = req -> dst ;
301
301
struct scatterlist * src = req -> src ;
302
- const int nents = sg_nents (req -> src );
302
+ int dst_nents = sg_nents (dst );
303
303
304
304
const int out_off = DCP_BUF_SZ ;
305
305
uint8_t * in_buf = sdcp -> coh -> aes_in_buf ;
306
306
uint8_t * out_buf = sdcp -> coh -> aes_out_buf ;
307
307
308
- uint8_t * out_tmp , * src_buf , * dst_buf = NULL ;
309
308
uint32_t dst_off = 0 ;
309
+ uint8_t * src_buf = NULL ;
310
310
uint32_t last_out_len = 0 ;
311
311
312
312
uint8_t * key = sdcp -> coh -> aes_key ;
313
313
314
314
int ret = 0 ;
315
- int split = 0 ;
316
- unsigned int i , len , clen , rem = 0 , tlen = 0 ;
315
+ unsigned int i , len , clen , tlen = 0 ;
317
316
int init = 0 ;
318
317
bool limit_hit = false;
319
318
@@ -331,7 +330,7 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
331
330
memset (key + AES_KEYSIZE_128 , 0 , AES_KEYSIZE_128 );
332
331
}
333
332
334
- for_each_sg (req -> src , src , nents , i ) {
333
+ for_each_sg (req -> src , src , sg_nents ( src ) , i ) {
335
334
src_buf = sg_virt (src );
336
335
len = sg_dma_len (src );
337
336
tlen += len ;
@@ -356,34 +355,17 @@ static int mxs_dcp_aes_block_crypt(struct crypto_async_request *arq)
356
355
* submit the buffer.
357
356
*/
358
357
if (actx -> fill == out_off || sg_is_last (src ) ||
359
- limit_hit ) {
358
+ limit_hit ) {
360
359
ret = mxs_dcp_run_aes (actx , req , init );
361
360
if (ret )
362
361
return ret ;
363
362
init = 0 ;
364
363
365
- out_tmp = out_buf ;
364
+ sg_pcopy_from_buffer (dst , dst_nents , out_buf ,
365
+ actx -> fill , dst_off );
366
+ dst_off += actx -> fill ;
366
367
last_out_len = actx -> fill ;
367
- while (dst && actx -> fill ) {
368
- if (!split ) {
369
- dst_buf = sg_virt (dst );
370
- dst_off = 0 ;
371
- }
372
- rem = min (sg_dma_len (dst ) - dst_off ,
373
- actx -> fill );
374
-
375
- memcpy (dst_buf + dst_off , out_tmp , rem );
376
- out_tmp += rem ;
377
- dst_off += rem ;
378
- actx -> fill -= rem ;
379
-
380
- if (dst_off == sg_dma_len (dst )) {
381
- dst = sg_next (dst );
382
- split = 0 ;
383
- } else {
384
- split = 1 ;
385
- }
386
- }
368
+ actx -> fill = 0 ;
387
369
}
388
370
} while (len );
389
371
0 commit comments