]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
linux/kernel.h: Add ALIGN_DOWN macro
authorKrzysztof Kozlowski <krzk@kernel.org>
Tue, 11 Apr 2017 18:08:34 +0000 (20:08 +0200)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 21 Apr 2017 12:30:44 +0000 (20:30 +0800)
Few parts of kernel define their own macro for aligning down so provide
a common define for this, with the same usage and assumptions as existing
ALIGN.

Convert also three existing implementations to this one.

Signed-off-by: Krzysztof Kozlowski <krzk@kernel.org>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
arch/metag/kernel/stacktrace.c
drivers/gpu/drm/udl/udl_fb.c
include/linux/kernel.h
include/video/udlfb.h

index 91ffc4b75c332b50f41ced4e84d1814e91cd1f1c..09d67b7f51caf5ea50ed15308f561f6a370e0574 100644 (file)
@@ -31,8 +31,6 @@ static void tbi_boing_init(void)
 }
 #endif
 
-#define ALIGN_DOWN(addr, size)  ((addr)&(~((size)-1)))
-
 /*
  * Unwind the current stack frame and store the new register values in the
  * structure passed as argument. Unwinding is equivalent to a function return,
index 8e8d60e9a1a26ba512932d865fac63cc3c476eb3..b1f0d523dff91557cd94137c226c6def48ac3255 100644 (file)
@@ -37,7 +37,7 @@ struct udl_fbdev {
 };
 
 #define DL_ALIGN_UP(x, a) ALIGN(x, a)
-#define DL_ALIGN_DOWN(x, a) ALIGN(x-(a-1), a)
+#define DL_ALIGN_DOWN(x, a) ALIGN_DOWN(x, a)
 
 /** Read the red component (0..255) of a 32 bpp colour. */
 #define DLO_RGB_GETRED(col) (uint8_t)((col) & 0xFF)
index 4c26dc3a8295a9fb2910dcb18946ee86f54ceac8..3d9f8420f9735f182cf09ddfbb21ba6099d5a881 100644 (file)
@@ -47,6 +47,7 @@
 
 /* @a is a power of 2 value */
 #define ALIGN(x, a)            __ALIGN_KERNEL((x), (a))
+#define ALIGN_DOWN(x, a)       __ALIGN_KERNEL((x) - ((a) - 1), (a))
 #define __ALIGN_MASK(x, mask)  __ALIGN_KERNEL_MASK((x), (mask))
 #define PTR_ALIGN(p, a)                ((typeof(p))ALIGN((unsigned long)(p), (a)))
 #define IS_ALIGNED(x, a)               (((x) & ((typeof(x))(a) - 1)) == 0)
index f9466fa54ba4bd626fe618aef5b95f3b30dfde9b..3ea90aea5617cb359423fefc6140e381d2e78e20 100644 (file)
@@ -92,6 +92,6 @@ struct dlfb_data {
 
 /* remove these once align.h patch is taken into kernel */
 #define DL_ALIGN_UP(x, a) ALIGN(x, a)
-#define DL_ALIGN_DOWN(x, a) ALIGN(x-(a-1), a)
+#define DL_ALIGN_DOWN(x, a) ALIGN_DOWN(x, a)
 
 #endif