summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNishanth Menon <nm@ti.com>2016-03-15 10:25:51 -0500
committerTom Rini <trini@konsulko.com>2016-03-27 09:12:10 -0400
commitbc69b505f0303a23d831a03757d06b2acda26ebf (patch)
tree35804be9c7431b9aed02a23ca5ddc7be42408d76
parent69067a34b1ab1fb14f0183acb85358db60aac484 (diff)
downloadu-boot-imx-bc69b505f0303a23d831a03757d06b2acda26ebf.zip
u-boot-imx-bc69b505f0303a23d831a03757d06b2acda26ebf.tar.gz
u-boot-imx-bc69b505f0303a23d831a03757d06b2acda26ebf.tar.bz2
ARM: keystone2: Convert BOOTBITMASK to static inline function
BOOTBITMASK is almost impossible to decode, so convert it into a simpler static line functions of equivalent solution. Reported-by: Tom Rini <trini@konsulko.com> Signed-off-by: Nishanth Menon <nm@ti.com> Reviewed-by: Tom Rini <trini@konsulko.com>
-rw-r--r--arch/arm/mach-keystone/include/mach/psc_defs.h14
1 files changed, 9 insertions, 5 deletions
diff --git a/arch/arm/mach-keystone/include/mach/psc_defs.h b/arch/arm/mach-keystone/include/mach/psc_defs.h
index 6e6e7fd..9681175 100644
--- a/arch/arm/mach-keystone/include/mach/psc_defs.h
+++ b/arch/arm/mach-keystone/include/mach/psc_defs.h
@@ -27,12 +27,16 @@
#define PSC_REG_MDSTAT(x) (0x800 + (4 * (x)))
#define PSC_REG_MDCTL(x) (0xa00 + (4 * (x)))
-#define BOOTBITMASK(x, y) ((((((u32)1 << (((u32)x) - ((u32)y) + (u32)1)) - \
- (u32)1)) << ((u32)y)))
-#define BOOT_READ_BITFIELD(z, x, y) ((((u32)z) & BOOTBITMASK(x, y)) >> (y))
-#define BOOT_SET_BITFIELD(z, f, x, y) ((((u32)z) & ~BOOTBITMASK(x, y)) | \
- ((((u32)f) << (y)) & BOOTBITMASK(x, y)))
+static inline u32 _boot_bit_mask(u32 x, u32 y)
+{
+ u32 val = (1 << (x - y + 1)) - 1;
+ return val << y;
+}
+
+#define BOOT_READ_BITFIELD(z, x, y) ((((u32)z) & _boot_bit_mask(x, y)) >> (y))
+#define BOOT_SET_BITFIELD(z, f, x, y) ((((u32)z) & ~_boot_bit_mask(x, y)) | \
+ ((((u32)f) << (y)) & _boot_bit_mask(x, y)))
/* PDCTL */
#define PSC_REG_PDCTL_SET_NEXT(x, y) BOOT_SET_BITFIELD((x), (y), 0, 0)