@@ -187,7 +187,7 @@ static int sun4i_hash(struct ahash_request *areq)
187
187
*/
188
188
unsigned int i = 0 , end , fill , min_fill , nwait , nbw = 0 , j = 0 , todo ;
189
189
unsigned int in_i = 0 ;
190
- u32 spaces , rx_cnt = SS_RX_DEFAULT , bf [32 ] = {0 }, wb = 0 , v , ivmode = 0 ;
190
+ u32 spaces , rx_cnt = SS_RX_DEFAULT , bf [32 ] = {0 }, v , ivmode = 0 ;
191
191
struct sun4i_req_ctx * op = ahash_request_ctx (areq );
192
192
struct crypto_ahash * tfm = crypto_ahash_reqtfm (areq );
193
193
struct sun4i_tfm_ctx * tfmctx = crypto_ahash_ctx (tfm );
@@ -196,6 +196,7 @@ static int sun4i_hash(struct ahash_request *areq)
196
196
struct sg_mapping_iter mi ;
197
197
int in_r , err = 0 ;
198
198
size_t copied = 0 ;
199
+ __le32 wb = 0 ;
199
200
200
201
dev_dbg (ss -> dev , "%s %s bc=%llu len=%u mode=%x wl=%u h0=%0x" ,
201
202
__func__ , crypto_tfm_alg_name (areq -> base .tfm ),
@@ -407,7 +408,7 @@ static int sun4i_hash(struct ahash_request *areq)
407
408
408
409
nbw = op -> len - 4 * nwait ;
409
410
if (nbw ) {
410
- wb = * (u32 * )(op -> buf + nwait * 4 );
411
+ wb = cpu_to_le32 ( * (u32 * )(op -> buf + nwait * 4 ) );
411
412
wb &= GENMASK ((nbw * 8 ) - 1 , 0 );
412
413
413
414
op -> byte_count += nbw ;
@@ -416,7 +417,7 @@ static int sun4i_hash(struct ahash_request *areq)
416
417
417
418
/* write the remaining bytes of the nbw buffer */
418
419
wb |= ((1 << 7 ) << (nbw * 8 ));
419
- bf [j ++ ] = wb ;
420
+ bf [j ++ ] = le32_to_cpu ( wb ) ;
420
421
421
422
/*
422
423
* number of space to pad to obtain 64o minus 8(size) minus 4 (final 1)
@@ -435,13 +436,13 @@ static int sun4i_hash(struct ahash_request *areq)
435
436
436
437
/* write the length of data */
437
438
if (op -> mode == SS_OP_SHA1 ) {
438
- __be64 bits = cpu_to_be64 ( op -> byte_count << 3 ) ;
439
- bf [ j ++ ] = lower_32_bits ( bits );
440
- bf [ j ++ ] = upper_32_bits ( bits ) ;
439
+ __be64 * bits = ( __be64 * ) & bf [ j ] ;
440
+ * bits = cpu_to_be64 ( op -> byte_count << 3 );
441
+ j += 2 ;
441
442
} else {
442
- __le64 bits = op -> byte_count << 3 ;
443
- bf [ j ++ ] = lower_32_bits ( bits );
444
- bf [ j ++ ] = upper_32_bits ( bits ) ;
443
+ __le64 * bits = ( __le64 * ) & bf [ j ] ;
444
+ * bits = cpu_to_le64 ( op -> byte_count << 3 );
445
+ j += 2 ;
445
446
}
446
447
writesl (ss -> base + SS_RXFIFO , bf , j );
447
448
@@ -483,7 +484,7 @@ static int sun4i_hash(struct ahash_request *areq)
483
484
}
484
485
} else {
485
486
for (i = 0 ; i < 4 ; i ++ ) {
486
- v = readl (ss -> base + SS_MD0 + i * 4 );
487
+ v = cpu_to_le32 ( readl (ss -> base + SS_MD0 + i * 4 ) );
487
488
memcpy (areq -> result + i * 4 , & v , 4 );
488
489
}
489
490
}
0 commit comments