linux/kernel.h: Add PTR_ALIGN_DOWN macro
authorKishon Vijay Abraham I <kishon@ti.com>
Wed, 22 Jul 2020 11:03:05 +0000 (16:33 +0530)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Mon, 27 Jul 2020 14:46:16 +0000 (15:46 +0100)
Add a macro for aligning down a pointer. This is useful to get an
aligned register address when a device allows only word access and
doesn't allow half word or byte access.

Link: https://lore.kernel.org/r/20200722110317.4744-4-kishon@ti.com
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Rob Herring <robh@kernel.org>
include/linux/kernel.h

index 82d9154..7339a00 100644 (file)
@@ -34,6 +34,7 @@
 #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 PTR_ALIGN_DOWN(p, a)   ((typeof(p))ALIGN_DOWN((unsigned long)(p), (a)))
 #define IS_ALIGNED(x, a)               (((x) & ((typeof(x))(a) - 1)) == 0)
 
 /* generic data direction definitions */