kexec: use ALIGN macro instead of open-coding it
authorYuntao Wang <ytcoode@gmail.com>
Tue, 12 Dec 2023 14:27:06 +0000 (22:27 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 20 Dec 2023 23:02:58 +0000 (15:02 -0800)
Use ALIGN macro instead of open-coding it to improve code readability.

Link: https://lkml.kernel.org/r/20231212142706.25149-1-ytcoode@gmail.com
Signed-off-by: Yuntao Wang <ytcoode@gmail.com>
Acked-by: Baoquan He <bhe@redhat.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
kernel/kexec_core.c

index 64072acef2b6e30ccfe0f4bf22e49f1a6046a3f0..6e0f022987ff3b818edc87edc55b0a6d08a25c5a 100644 (file)
@@ -432,7 +432,7 @@ static struct page *kimage_alloc_crash_control_pages(struct kimage *image,
 
        pages = NULL;
        size = (1 << order) << PAGE_SHIFT;
-       hole_start = (image->control_page + (size - 1)) & ~(size - 1);
+       hole_start = ALIGN(image->control_page, size);
        hole_end   = hole_start + size - 1;
        while (hole_end <= crashk_res.end) {
                unsigned long i;
@@ -449,7 +449,7 @@ static struct page *kimage_alloc_crash_control_pages(struct kimage *image,
                        mend   = mstart + image->segment[i].memsz - 1;
                        if ((hole_end >= mstart) && (hole_start <= mend)) {
                                /* Advance the hole to the end of the segment */
-                               hole_start = (mend + (size - 1)) & ~(size - 1);
+                               hole_start = ALIGN(mend, size);
                                hole_end   = hole_start + size - 1;
                                break;
                        }