i2c: ihs_i2c: Use macro bestpractices
authorDirk Eibach <dirk.eibach@gdsys.cc>
Wed, 28 Oct 2015 10:46:23 +0000 (11:46 +0100)
committerTom Rini <trini@konsulko.com>
Thu, 12 Nov 2015 20:59:01 +0000 (15:59 -0500)
Reinhard Pfau complained that macros in ihs_i2c do not follow best practices.

Signed-off-by: Dirk Eibach <dirk.eibach@gdsys.cc>
Acked-by: Heiko Schocher <hs@denx.de>
drivers/i2c/ihs_i2c.c

index 737beaf21830237935889073b138fd123abf996a..e0014590b5d4f875e69f61010bec0dbbdc8682e2 100644 (file)
@@ -13,24 +13,28 @@ DECLARE_GLOBAL_DATA_PTR;
 
 #ifdef CONFIG_SYS_I2C_IHS_DUAL
 #define I2C_SET_REG(fld, val) \
-       { if (I2C_ADAP_HWNR & 0x10) \
-               FPGA_SET_REG(I2C_ADAP_HWNR & 0xf, i2c1.fld, val); \
-       else \
-               FPGA_SET_REG(I2C_ADAP_HWNR, i2c0.fld, val); }
+       do { \
+               if (I2C_ADAP_HWNR & 0x10) \
+                       FPGA_SET_REG(I2C_ADAP_HWNR & 0xf, i2c1.fld, val); \
+               else \
+                       FPGA_SET_REG(I2C_ADAP_HWNR, i2c0.fld, val); \
+       } while (0)
 #else
 #define I2C_SET_REG(fld, val) \
-               FPGA_SET_REG(I2C_ADAP_HWNR, i2c0.fld, val);
+               FPGA_SET_REG(I2C_ADAP_HWNR, i2c0.fld, val)
 #endif
 
 #ifdef CONFIG_SYS_I2C_IHS_DUAL
 #define I2C_GET_REG(fld, val) \
-       { if (I2C_ADAP_HWNR & 0x10) \
-               FPGA_GET_REG(I2C_ADAP_HWNR & 0xf, i2c1.fld, val); \
-       else \
-               FPGA_GET_REG(I2C_ADAP_HWNR, i2c0.fld, val); }
+       do {                                    \
+               if (I2C_ADAP_HWNR & 0x10) \
+                       FPGA_GET_REG(I2C_ADAP_HWNR & 0xf, i2c1.fld, val); \
+               else \
+                       FPGA_GET_REG(I2C_ADAP_HWNR, i2c0.fld, val); \
+       } while (0)
 #else
 #define I2C_GET_REG(fld, val) \
-               FPGA_GET_REG(I2C_ADAP_HWNR, i2c0.fld, val);
+               FPGA_GET_REG(I2C_ADAP_HWNR, i2c0.fld, val)
 #endif
 
 enum {