From: Thorsten Blum Date: Fri, 26 Jul 2024 13:12:46 +0000 (+0200) Subject: lib: test_hmm: use min() to improve dmirror_exclusive() X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=9e516a94e720f0313779ca610fe6c422feb156aa;p=users%2Fjedix%2Flinux-maple.git lib: test_hmm: use min() to improve dmirror_exclusive() 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 Reviewed-by: David Hildenbrand Cc: Jérôme Glisse Signed-off-by: Andrew Morton --- diff --git a/lib/test_hmm.c b/lib/test_hmm.c index ee20e1f9bae92..056f2e411d7b4 100644 --- a/lib/test_hmm.c +++ b/lib/test_hmm.c @@ -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); /*