* [PATCH] crypto: atmel-tdes - use min3 to simplify sg_copy and crypt_start
@ 2026-05-25 9:29 Thorsten Blum
2026-06-01 19:13 ` Thorsten Blum
0 siblings, 1 reply; 2+ messages in thread
From: Thorsten Blum @ 2026-05-25 9:29 UTC (permalink / raw)
To: Herbert Xu, David S. Miller, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea
Cc: Thorsten Blum, linux-crypto, linux-arm-kernel, linux-kernel
Replace multiple min() and min_t() calls with min3() to simplify the
code. Using min3() instead of min_t() in atmel_tdes_crypt_start() is
safe since the values are all unsigned and compatible.
Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
drivers/crypto/atmel-tdes.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/atmel-tdes.c b/drivers/crypto/atmel-tdes.c
index 643e507f9c02..834c6d3e1b06 100644
--- a/drivers/crypto/atmel-tdes.c
+++ b/drivers/crypto/atmel-tdes.c
@@ -143,8 +143,7 @@ static int atmel_tdes_sg_copy(struct scatterlist **sg, size_t *offset,
size_t count, off = 0;
while (buflen && total) {
- count = min((*sg)->length - *offset, total);
- count = min(count, buflen);
+ count = min3((*sg)->length - *offset, total, buflen);
if (!count)
return off;
@@ -469,8 +468,8 @@ static int atmel_tdes_crypt_start(struct atmel_tdes_dev *dd)
if (fast) {
- count = min_t(size_t, dd->total, sg_dma_len(dd->in_sg));
- count = min_t(size_t, count, sg_dma_len(dd->out_sg));
+ count = min3(sg_dma_len(dd->in_sg), sg_dma_len(dd->out_sg),
+ dd->total);
err = dma_map_sg(dd->dev, dd->in_sg, 1, DMA_TO_DEVICE);
if (!err) {
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] crypto: atmel-tdes - use min3 to simplify sg_copy and crypt_start
2026-05-25 9:29 [PATCH] crypto: atmel-tdes - use min3 to simplify sg_copy and crypt_start Thorsten Blum
@ 2026-06-01 19:13 ` Thorsten Blum
0 siblings, 0 replies; 2+ messages in thread
From: Thorsten Blum @ 2026-06-01 19:13 UTC (permalink / raw)
To: Herbert Xu, David S. Miller, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea
Cc: linux-crypto, linux-arm-kernel, linux-kernel
On Mon, May 25, 2026 at 11:29:27AM +0200, Thorsten Blum wrote:
> Replace multiple min() and min_t() calls with min3() to simplify the
> code. Using min3() instead of min_t() in atmel_tdes_crypt_start() is
> safe since the values are all unsigned and compatible.
>
> Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
> ---
> drivers/crypto/atmel-tdes.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/crypto/atmel-tdes.c b/drivers/crypto/atmel-tdes.c
> index 643e507f9c02..834c6d3e1b06 100644
> --- a/drivers/crypto/atmel-tdes.c
> +++ b/drivers/crypto/atmel-tdes.c
> @@ -143,8 +143,7 @@ static int atmel_tdes_sg_copy(struct scatterlist **sg, size_t *offset,
> size_t count, off = 0;
>
> while (buflen && total) {
> - count = min((*sg)->length - *offset, total);
> - count = min(count, buflen);
> + count = min3((*sg)->length - *offset, total, buflen);
>
> if (!count)
> return off;
> @@ -469,8 +468,8 @@ static int atmel_tdes_crypt_start(struct atmel_tdes_dev *dd)
>
>
> if (fast) {
> - count = min_t(size_t, dd->total, sg_dma_len(dd->in_sg));
> - count = min_t(size_t, count, sg_dma_len(dd->out_sg));
> + count = min3(sg_dma_len(dd->in_sg), sg_dma_len(dd->out_sg),
> + dd->total);
>
> err = dma_map_sg(dd->dev, dd->in_sg, 1, DMA_TO_DEVICE);
> if (!err) {
This should probably be dropped for now because of this fix:
https://lore.kernel.org/lkml/20260531204115.689052-3-thorsten.blum@linux.dev/
Thanks,
Thorsten
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-06-01 19:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-25 9:29 [PATCH] crypto: atmel-tdes - use min3 to simplify sg_copy and crypt_start Thorsten Blum
2026-06-01 19:13 ` Thorsten Blum
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox