[U-Boot] [PATCH] i2c: merge all i2c_reg_read() and i2c_reg_write() into inline functions

Wolfgang Denk wd at denx.de
Sat Oct 4 01:21:36 CEST 2008


Dear Timur Tabi,

In message <1222959963-5697-1-git-send-email-timur at 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


More information about the U-Boot mailing list