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>
Cc: Thorsten Blum <thorsten.blum@linux.dev>,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] crypto: omap - use min3 to simplify omap_crypto_copy_data
Date: Thu,  4 Jun 2026 02:10:36 +0200	[thread overview]
Message-ID: <20260604001035.1256238-3-thorsten.blum@linux.dev> (raw)

Replace two consecutive min() calls with min3() to simplify the code.

Change the function parameters and local variables from int to size_t
since these represent unsigned values and to prevent a signedness error.

Signed-off-by: Thorsten Blum <thorsten.blum@linux.dev>
---
 drivers/crypto/omap-crypto.c | 12 ++++++------
 drivers/crypto/omap-crypto.h |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/crypto/omap-crypto.c b/drivers/crypto/omap-crypto.c
index 0345c9383d50..c0400fbe313e 100644
--- a/drivers/crypto/omap-crypto.c
+++ b/drivers/crypto/omap-crypto.c
@@ -156,11 +157,11 @@ EXPORT_SYMBOL_GPL(omap_crypto_align_sg);
 
 static void omap_crypto_copy_data(struct scatterlist *src,
 				  struct scatterlist *dst,
-				  int offset, int len)
+				  size_t offset, size_t len)
 {
-	int amt;
+	size_t amt;
 	void *srcb, *dstb;
-	int srco = 0, dsto = offset;
+	size_t srco = 0, dsto = offset;
 
 	while (src && dst && len) {
 		if (srco >= src->length) {
@@ -175,8 +176,7 @@ static void omap_crypto_copy_data(struct scatterlist *src,
 			continue;
 		}
 
-		amt = min(src->length - srco, dst->length - dsto);
-		amt = min(len, amt);
+		amt = min3(src->length - srco, dst->length - dsto, len);
 
 		srcb = kmap_atomic(sg_page(src)) + srco + src->offset;
 		dstb = kmap_atomic(sg_page(dst)) + dsto + dst->offset;
@@ -195,7 +195,7 @@ static void omap_crypto_copy_data(struct scatterlist *src,
 }
 
 void omap_crypto_cleanup(struct scatterlist *sg, struct scatterlist *orig,
-			 int offset, int len, u8 flags_shift,
+			 size_t offset, size_t len, u8 flags_shift,
 			 unsigned long flags)
 {
 	void *buf;
diff --git a/drivers/crypto/omap-crypto.h b/drivers/crypto/omap-crypto.h
index 506ccde6f380..436f45f3bb7d 100644
--- a/drivers/crypto/omap-crypto.h
+++ b/drivers/crypto/omap-crypto.h
@@ -28,7 +28,7 @@ int omap_crypto_align_sg(struct scatterlist **sg, int total, int bs,
 			 struct scatterlist *new_sg, u16 flags,
 			 u8 flags_shift, unsigned long *dd_flags);
 void omap_crypto_cleanup(struct scatterlist *sg, struct scatterlist *orig,
-			 int offset, int len, u8 flags_shift,
+			 size_t offset, size_t len, u8 flags_shift,
 			 unsigned long flags);
 
 #endif

             reply	other threads:[~2026-06-04  0:11 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-04  0:10 Thorsten Blum [this message]
2026-06-11  5:37 ` [PATCH] crypto: omap - use min3 to simplify omap_crypto_copy_data Herbert Xu

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=20260604001035.1256238-3-thorsten.blum@linux.dev \
    --to=thorsten.blum@linux.dev \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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