[PATCH 19/23] memory: omap-gpmc: Enclose macro statements in do-while

Krzysztof Kozlowski krzk at kernel.org
Thu Jul 23 03:37:40 EDT 2020


do-while is a preferred way for complex macros because of safety
reasons.  This fixes checkpatch error:

    ERROR: Macros starting with if should be enclosed by a do - while
        loop to avoid possible if/else logic defects

Signed-off-by: Krzysztof Kozlowski <krzk at kernel.org>
---
 drivers/memory/omap-gpmc.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/memory/omap-gpmc.c b/drivers/memory/omap-gpmc.c
index c158b6cae9a9..bb85aa56d247 100644
--- a/drivers/memory/omap-gpmc.c
+++ b/drivers/memory/omap-gpmc.c
@@ -635,10 +635,12 @@ static int set_gpmc_timing_reg(int cs, int reg, int st_bit, int end_bit, int max
 	return 0;
 }
 
-#define GPMC_SET_ONE_CD_MAX(reg, st, end, max, field, cd)  \
-	if (set_gpmc_timing_reg(cs, (reg), (st), (end), (max), \
-	    t->field, (cd), #field) < 0)                       \
-		return -1
+#define GPMC_SET_ONE_CD_MAX(reg, st, end, max, field, cd)		\
+	do {								\
+		if (set_gpmc_timing_reg(cs, (reg), (st), (end), (max),	\
+		    t->field, (cd), #field) < 0)			\
+			return -1;					\
+	} while (0)
 
 #define GPMC_SET_ONE(reg, st, end, field) \
 	GPMC_SET_ONE_CD_MAX(reg, st, end, 0, field, GPMC_CD_FCLK)
-- 
2.17.1




More information about the Linux-mediatek mailing list