diff mbox

crypto: tcrypt - set assoc in sg_init_aead()

Message ID 20171114145915.13299-1-tudor.ambarus@microchip.com (mailing list archive)
State Accepted
Delegated to: Herbert Xu
Headers show

Commit Message

Tudor Ambarus Nov. 14, 2017, 2:59 p.m. UTC
Results better code readability.

Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
---
Should be applied after:
    crypto: tcrypt - fix S/G table for test_aead_speed()

 crypto/tcrypt.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

Comments

Horia Geanta Nov. 15, 2017, 9:11 a.m. UTC | #1
On 11/14/2017 4:59 PM, Tudor Ambarus wrote:
> Results better code readability.
         ^^ *in* better
> 
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
Reviewed-by: Horia Geantă <horia.geanta@nxp.com>

Horia
Herbert Xu Nov. 29, 2017, 6:36 a.m. UTC | #2
On Tue, Nov 14, 2017 at 04:59:15PM +0200, Tudor-Dan Ambarus wrote:
> Results better code readability.
> 
> Signed-off-by: Tudor Ambarus <tudor.ambarus@microchip.com>
> Reviewed-by: Horia Geantă <horia.geanta@nxp.com>

Patch applied.  Thanks.
diff mbox

Patch

diff --git a/crypto/tcrypt.c b/crypto/tcrypt.c
index 3ced1ba..28b4882 100644
--- a/crypto/tcrypt.c
+++ b/crypto/tcrypt.c
@@ -185,7 +185,8 @@  static void testmgr_free_buf(char *buf[XBUFSIZE])
 }
 
 static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE],
-			unsigned int buflen)
+			 unsigned int buflen, const void *assoc,
+			 unsigned int aad_size)
 {
 	int np = (buflen + PAGE_SIZE - 1)/PAGE_SIZE;
 	int k, rem;
@@ -198,6 +199,9 @@  static void sg_init_aead(struct scatterlist *sg, char *xbuf[XBUFSIZE],
 	}
 
 	sg_init_table(sg, np + 1);
+
+	sg_set_buf(&sg[0], assoc, aad_size);
+
 	if (rem)
 		np--;
 	for (k = 0; k < np; k++)
@@ -318,14 +322,12 @@  static void test_aead_speed(const char *algo, int enc, unsigned int secs,
 				goto out;
 			}
 
-			sg_init_aead(sg, xbuf,
-				    *b_size + (enc ? 0 : authsize));
+			sg_init_aead(sg, xbuf, *b_size + (enc ? 0 : authsize),
+				     assoc, aad_size);
 
 			sg_init_aead(sgout, xoutbuf,
-				    *b_size + (enc ? authsize : 0));
-
-			sg_set_buf(&sg[0], assoc, aad_size);
-			sg_set_buf(&sgout[0], assoc, aad_size);
+				     *b_size + (enc ? authsize : 0), assoc,
+				     aad_size);
 
 			aead_request_set_crypt(req, sg, sgout,
 					       *b_size + (enc ? 0 : authsize),