diff mbox

[U-Boot,3/3] ARM: keystone2: Convert BOOT_SET_BITFIELD into static inline function

Message ID 1458055553-10818-4-git-send-email-nm@ti.com
State Accepted
Commit 705c506e4faa7c22b492a1c560f7de86fcbcc913
Delegated to: Tom Rini
Headers show

Commit Message

Nishanth Menon March 15, 2016, 3:25 p.m. UTC
Fix up BOOT_SET_BITFIELD to be a static inline function to be readable
with the same functionality.

Reported-by: Tom Rini <trini@konsulko.com>
Signed-off-by: Nishanth Menon <nm@ti.com>
---
 arch/arm/mach-keystone/include/mach/psc_defs.h | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

Comments

Tom Rini March 17, 2016, 2:11 a.m. UTC | #1
On Tue, Mar 15, 2016 at 10:25:53AM -0500, Nishanth Menon wrote:

> Fix up BOOT_SET_BITFIELD to be a static inline function to be readable
> with the same functionality.
> 
> Reported-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>

Reviewed-by: Tom Rini <trini@konsulko.com>
Tom Rini March 27, 2016, 10:23 p.m. UTC | #2
On Tue, Mar 15, 2016 at 10:25:53AM -0500, Nishanth Menon wrote:

> Fix up BOOT_SET_BITFIELD to be a static inline function to be readable
> with the same functionality.
> 
> Reported-by: Tom Rini <trini@konsulko.com>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> Reviewed-by: Tom Rini <trini@konsulko.com>

Applied to u-boot/master, thanks!
diff mbox

Patch

diff --git a/arch/arm/mach-keystone/include/mach/psc_defs.h b/arch/arm/mach-keystone/include/mach/psc_defs.h
index 671b1d64d69f..18499386a321 100644
--- a/arch/arm/mach-keystone/include/mach/psc_defs.h
+++ b/arch/arm/mach-keystone/include/mach/psc_defs.h
@@ -40,12 +40,16 @@  static inline u32 boot_read_bitfield(u32 z, u32 x, u32 y)
 	return val >> y;
 }
 
-#define BOOT_SET_BITFIELD(z, f, x, y)  ((((u32)z) & ~_boot_bit_mask(x, y)) | \
-					((((u32)f) << (y)) & _boot_bit_mask(x, y)))
+static inline u32 boot_set_bitfield(u32 z, u32 f, u32 x, u32 y)
+{
+	u32 mask = _boot_bit_mask(x, y);
+
+	return (z & ~mask) | ((f << y) & mask);
+}
 
 /* PDCTL */
-#define PSC_REG_PDCTL_SET_NEXT(x, y)        BOOT_SET_BITFIELD((x), (y), 0, 0)
-#define PSC_REG_PDCTL_SET_PDMODE(x, y)      BOOT_SET_BITFIELD((x), (y), 15, 12)
+#define PSC_REG_PDCTL_SET_NEXT(x, y)        boot_set_bitfield((x), (y), 0, 0)
+#define PSC_REG_PDCTL_SET_PDMODE(x, y)      boot_set_bitfield((x), (y), 15, 12)
 
 /* PDSTAT */
 #define PSC_REG_PDSTAT_GET_STATE(x)         boot_read_bitfield((x), 4, 0)
@@ -55,10 +59,10 @@  static inline u32 boot_read_bitfield(u32 z, u32 x, u32 y)
 #define PSC_REG_MDCFG_GET_RESET_ISO(x)      boot_read_bitfield((x), 14, 14)
 
 /* MDCTL */
-#define PSC_REG_MDCTL_SET_NEXT(x, y)        BOOT_SET_BITFIELD((x), (y), 4, 0)
-#define PSC_REG_MDCTL_SET_LRSTZ(x, y)       BOOT_SET_BITFIELD((x), (y), 8, 8)
+#define PSC_REG_MDCTL_SET_NEXT(x, y)        boot_set_bitfield((x), (y), 4, 0)
+#define PSC_REG_MDCTL_SET_LRSTZ(x, y)       boot_set_bitfield((x), (y), 8, 8)
 #define PSC_REG_MDCTL_GET_LRSTZ(x)          boot_read_bitfield((x), 8, 8)
-#define PSC_REG_MDCTL_SET_RESET_ISO(x, y)   BOOT_SET_BITFIELD((x), (y), \
+#define PSC_REG_MDCTL_SET_RESET_ISO(x, y)   boot_set_bitfield((x), (y), \
 								  12, 12)
 
 /* MDSTAT */