]> www.infradead.org Git - users/hch/misc.git/commitdiff
lib: test_hmm: use min() to improve dmirror_exclusive()
authorThorsten Blum <thorsten.blum@toblux.com>
Fri, 26 Jul 2024 13:12:46 +0000 (15:12 +0200)
committerAndrew Morton <akpm@linux-foundation.org>
Mon, 2 Sep 2024 03:25:52 +0000 (20:25 -0700)
Use min() to simplify the dmirror_exclusive() function and improve its
readability.

Link: https://lkml.kernel.org/r/20240726131245.161695-1-thorsten.blum@toblux.com
Signed-off-by: Thorsten Blum <thorsten.blum@toblux.com>
Reviewed-by: David Hildenbrand <david@redhat.com>
Cc: Jérôme Glisse <jglisse@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
lib/test_hmm.c

index ee20e1f9bae92804b00bb9ecbf2d1c2b66dcd21a..056f2e411d7b403d9d76a2379c972f221bda5a0e 100644 (file)
@@ -799,10 +799,7 @@ static int dmirror_exclusive(struct dmirror *dmirror,
                unsigned long mapped = 0;
                int i;
 
-               if (end < addr + (ARRAY_SIZE(pages) << PAGE_SHIFT))
-                       next = end;
-               else
-                       next = addr + (ARRAY_SIZE(pages) << PAGE_SHIFT);
+               next = min(end, addr + (ARRAY_SIZE(pages) << PAGE_SHIFT));
 
                ret = make_device_exclusive_range(mm, addr, next, pages, NULL);
                /*