Skip to contentSkip to conversation

crypto: atmel-aes: use swap()

PATCH RESEND In review Salah Triki 3 participants 4 messages Jul 22, 2021 – Jul 30, 2021

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 crypto: atmel-aes: use swap()

Use swap() instead of implementing it in order to make code more clean.

---
 drivers/crypto/atmel-aes.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/crypto/atmel-aes.c +2 -6
index b1d286004295..60041022c4f5 100644
@@ -1819,12 +1819,8 @@ static int atmel_aes_xts_process_data(struct atmel_aes_dev *dd)
 	 * the order of the ciphered tweak bytes need to be reversed before
 	 * writing them into the ODATARx registers.
 	 */
-	for (i = 0; i < AES_BLOCK_SIZE/2; ++i) {
-		u8 tmp = tweak_bytes[AES_BLOCK_SIZE - 1 - i];
-
-		tweak_bytes[AES_BLOCK_SIZE - 1 - i] = tweak_bytes[i];
-		tweak_bytes[i] = tmp;
-	}
+	for (i = 0; i < AES_BLOCK_SIZE/2; ++i)
+		swap(tweak_bytes[i], tweak_bytes[AES_BLOCK_SIZE - 1 - i]);
 
 	/* Process the data. */
 	atmel_aes_write_ctrl(dd, use_dma, NULL);
Signature · 1 line
2.25.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 5 lines · Salah Triki

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Use swap() instead of implementing it in order to make code more clean.

Quoted 26 lines
---
 drivers/crypto/atmel-aes.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/crypto/atmel-aes.c +2 -7
index b1d286004295..60041022c4f5 100644
@@ -1819,12 +1819,8 @@ static int atmel_aes_xts_process_data(struct atmel_aes_dev *dd)
         * the order of the ciphered tweak bytes need to be reversed before
         * writing them into the ODATARx registers.
         */
-       for (i = 0; i < AES_BLOCK_SIZE/2; ++i) {
-               u8 tmp = tweak_bytes[AES_BLOCK_SIZE - 1 - i];
-
-               tweak_bytes[AES_BLOCK_SIZE - 1 - i] = tweak_bytes[i];
-               tweak_bytes[i] = tmp;
-       }
+       for (i = 0; i < AES_BLOCK_SIZE/2; ++i)
+               swap(tweak_bytes[i], tweak_bytes[AES_BLOCK_SIZE - 1 - i]);
 
        /* Process the data. */
        atmel_aes_write_ctrl(dd, use_dma, NULL);
--

2.25.1

#2 lore raw
In reply to Salah Triki
Quoted 14 lines · Salah Triki

EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe

Use swap() instead of implementing it in order to make code more clean.

---
 drivers/crypto/atmel-aes.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)
drivers/crypto/atmel-aes.c +0 -0
index b1d286004295..60041022c4f5 100644

drivers/crypto/atmel-aes.c static int atmel_aes_xts_process_data(struct atmel_aes_dev *dd) · line 1822

Quoted 10 lines
drivers/crypto/atmel-aes.c +1 -6
@@ -1819,12 +1819,8 @@ static int atmel_aes_xts_process_data(struct atmel_aes_dev *dd)
         * the order of the ciphered tweak bytes need to be reversed before
         * writing them into the ODATARx registers.
         */
-       for (i = 0; i < AES_BLOCK_SIZE/2; ++i) {
-               u8 tmp = tweak_bytes[AES_BLOCK_SIZE - 1 - i];
-
-               tweak_bytes[AES_BLOCK_SIZE - 1 - i] = tweak_bytes[i];
-               tweak_bytes[i] = tmp;
-       }
+       for (i = 0; i < AES_BLOCK_SIZE/2; ++i)

There could have been spaces around that '/', but I see it was kept as it was before. It's fine either way.

Quoted 7 lines
drivers/crypto/atmel-aes.c +1 -1
+               swap(tweak_bytes[i], tweak_bytes[AES_BLOCK_SIZE - 1 - i]);
 
        /* Process the data. */
        atmel_aes_write_ctrl(dd, use_dma, NULL);
--

2.25.1

maintainer
#3 lore raw
In reply to Salah Triki
Quoted 6 lines · Salah Triki

Use swap() instead of implementing it in order to make code more clean.

---
 drivers/crypto/atmel-aes.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

Patch applied. Thanks.

Signature · 3 lines
Email: Herbert Xu <[email protected]>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt