[PATCH 12/13] kexec: sh: use _ALIGN* to make the logic clear

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Zhang Yanfei <zhangyanfei@xxxxxxxxxxxxxx>

By replacing all the explicit align opertion with marco _ALIGN*,
the code logic could be more clear.

Signed-off-by: Zhang Yanfei <zhangyanfei at cn.fujitsu.com>
---
 kexec/arch/sh/kexec-netbsd-sh.c |    4 ++--
 kexec/arch/sh/kexec-zImage-sh.c |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/kexec/arch/sh/kexec-netbsd-sh.c b/kexec/arch/sh/kexec-netbsd-sh.c
index 8e80486..8a7e75e 100644
--- a/kexec/arch/sh/kexec-netbsd-sh.c
+++ b/kexec/arch/sh/kexec-netbsd-sh.c
@@ -121,7 +121,7 @@ int netbsd_sh_load(int argc, char **argv, const char *buf, off_t UNUSED(len),
 		        size = bbs;
 		}
 
-		size = (size + psz - 1) & ~(psz - 1);
+		size = _ALIGN(size, psz);
 		memset(&img[bbs], 0, size-bbs);
 		add_segment(info, img, size, start, size);
 		start += size;
@@ -132,7 +132,7 @@ int netbsd_sh_load(int argc, char **argv, const char *buf, off_t UNUSED(len),
 	if (miniroot) {
 		miniroot_buf = slurp_file(miniroot, &miniroot_length);
 		howto_value |= 0x200;
-		size = (miniroot_length + psz - 1) & ~(psz - 1);
+		size = _ALIGN(miniroot_length, psz);
 		add_segment(info, miniroot_buf, size, start, size);
 		start += size;
 	}
diff --git a/kexec/arch/sh/kexec-zImage-sh.c b/kexec/arch/sh/kexec-zImage-sh.c
index 1ce185a..7399052 100644
--- a/kexec/arch/sh/kexec-zImage-sh.c
+++ b/kexec/arch/sh/kexec-zImage-sh.c
@@ -138,7 +138,7 @@ int zImage_sh_load(int argc, char **argv, const char *buf, off_t len,
 	 * the zImage will relocate itself, but only up seems supported.
 	 */
 
-	image_base = (empty_zero + (0x10000 - 1)) & ~(0x10000 - 1);
+	image_base = _ALIGN(empty_zero, 0x10000);
 	add_segment(info, buf, len, image_base, len);
 	info->entry = (void *)virt_to_phys(image_base);
 	return 0;
-- 
1.7.1




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux