From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wolfgang Denk Date: Sat, 04 Oct 2008 01:21:36 +0200 Subject: [U-Boot] [PATCH] i2c: merge all i2c_reg_read() and i2c_reg_write() into inline functions In-Reply-To: <1222959963-5697-1-git-send-email-timur@freescale.com> References: <1222959963-5697-1-git-send-email-timur@freescale.com> Message-ID: <20081003232136.76FA22480D@gemini.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 Dear Timur Tabi, In message <1222959963-5697-1-git-send-email-timur@freescale.com> you wrote: > All implementations of the functions i2c_reg_read() and i2c_reg_write() are > identical. We can save space and simplify the code by converting these > functions into inlines and putting them in i2c.h. Actually they are not identical: > +++ b/cpu/arm926ejs/davinci/i2c.c > @@ -331,21 +331,4 @@ int i2c_write(u_int8_t chip, u_int32_t addr, int alen, u_int8_t *buf, int len) ... > -u_int8_t i2c_reg_read(u_int8_t chip, u_int8_t reg) > -{ > - u_int8_t tmp; > - > - i2c_read(chip, reg, 1, &tmp, 1); > - return(tmp); > -} ... > -void i2c_reg_write(u_int8_t chip, u_int8_t reg, u_int8_t val) > -{ > - u_int8_t tmp; > - > - i2c_write(chip, reg, 1, &tmp, 1); > -} > - > #endif /* CONFIG_DRIVER_DAVINCI_I2C */ > diff --git a/cpu/blackfin/i2c.c b/cpu/blackfin/i2c.c > index 60f03d4..2a3e223 100644 > --- a/cpu/blackfin/i2c.c > +++ b/cpu/blackfin/i2c.c > @@ -425,20 +425,4 @@ int i2c_write(uchar chip, uint addr, int alen, uchar * buffer, int len) ... > -uchar i2c_reg_read(uchar chip, uchar reg) > -{ > - uchar buf; > - > - PRINTD("i2c_reg_read: chip=0x%02x, reg=0x%02x\n", chip, reg); > - i2c_read(chip, reg, 0, &buf, 1); > - return (buf); > -} > - > -void i2c_reg_write(uchar chip, uchar reg, uchar val) > -{ > - PRINTD("i2c_reg_write: chip=0x%02x, reg=0x%02x, val=0x%02x\n", chip, > - reg, val); > - i2c_write(chip, reg, 0, &val, 1); > -} > - This does not exactly look identical to me. And when you claim "We can save space" - which sort of space are you talking about? Dos this reduce the memory footprint of the code? Best regards, Wolfgang Denk -- DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de The main thing is the play itself. I swear that greed for money has nothing to do with it, although heaven knows I am sorely in need of money. - Feodor Dostoyevsky