Linux cryptographic layer development
 help / color / mirror / Atom feed
From: Thorsten Blum <thorsten.blum@linux.dev>
To: Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Nicolas Ferre <nicolas.ferre@microchip.com>,
	Alexandre Belloni <alexandre.belloni@bootlin.com>,
	Claudiu Beznea <claudiu.beznea@tuxon.dev>
Cc: linux-crypto@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] crypto: atmel-tdes - use min3 to simplify sg_copy and crypt_start
Date: Mon, 1 Jun 2026 21:13:49 +0200	[thread overview]
Message-ID: <ah3Z7bFWz512AgTU@linux.dev> (raw)
In-Reply-To: <20260525092927.818586-2-thorsten.blum@linux.dev>

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

      reply	other threads:[~2026-06-01 19:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ah3Z7bFWz512AgTU@linux.dev \
    --to=thorsten.blum@linux.dev \
    --cc=alexandre.belloni@bootlin.com \
    --cc=claudiu.beznea@tuxon.dev \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nicolas.ferre@microchip.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox