linux/kernel.h: Add ALIGN_DOWN macro
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>
This commit is contained in:
parent
7e207d8550
commit
ed067d4a85
|
@ -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,
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue