From mboxrd@z Thu Jan 1 00:00:00 1970 From: Heiko Schocher Date: Wed, 28 Oct 2015 12:23:40 +0100 Subject: [U-Boot] [PATCH v1 02/18] i2c: ihs_i2c: Use macro bestpractices In-Reply-To: <1446029199-11704-3-git-send-email-dirk.eibach@gdsys.cc> References: <1446029199-11704-1-git-send-email-dirk.eibach@gdsys.cc> <1446029199-11704-3-git-send-email-dirk.eibach@gdsys.cc> Message-ID: <5630B03C.3020700@denx.de> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de Hello Dirk, Am 28.10.2015 um 11:46 schrieb dirk.eibach at gdsys.cc: > From: Dirk Eibach > > Reinhard Pfau complained that macros in ihs_i2c do not follow best practices. > > Signed-off-by: Dirk Eibach > --- > > drivers/i2c/ihs_i2c.c | 24 ++++++++++++++---------- > 1 file changed, 14 insertions(+), 10 deletions(-) As the hole patchserie goes not through the i2c tree: Acked-by: Heiko Schocher bye, Heiko > > diff --git a/drivers/i2c/ihs_i2c.c b/drivers/i2c/ihs_i2c.c > index 737beaf..e001459 100644 > --- a/drivers/i2c/ihs_i2c.c > +++ b/drivers/i2c/ihs_i2c.c > @@ -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 { > -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany