[U-Boot] [POWERPC] mgsuvd: fix compiler warning when using soft_i2c driver

Wolfgang Denk wd at denx.de
Thu Oct 16 23:41:26 CEST 2008


Dear Heiko Schocher,

In message <48F775CE.2020203 at denx.de> you wrote:
> following patch solves the compiler warning for the
> mgsuvd board, using the soft_i2c driver:
> 
> [hs at pollux u-boot]$ ./MAKEALL mgsuvd
> Configuring for mgsuvd board...
> soft_i2c.c: In function 'write_byte':
> soft_i2c.c:209: warning: implicit declaration of function 'i2c_soft_read_pin'
>    text    data     bss     dec     hex filename
>  174608    9712   28436  212756   33f14 ./u-boot
> [hs at pollux u-boot]$
> 
> Signed-off-by: Heiko Schocher <hs at denx.de>
> ---
>  drivers/i2c/soft_i2c.c   |    2 ++
>  include/configs/mgsuvd.h |    1 +
>  include/i2c.h            |    4 ++++
>  3 files changed, 7 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/i2c/soft_i2c.c b/drivers/i2c/soft_i2c.c
> index 0a9feb6..346125e 100644
> --- a/drivers/i2c/soft_i2c.c
> +++ b/drivers/i2c/soft_i2c.c
> @@ -41,6 +41,8 @@
>  #endif
>  #include <i2c.h>
> 
> +CONFIG_I2C_SOFT_EXTERN
> +
>  /* #define	DEBUG_I2C	*/
> 
>  #ifdef DEBUG_I2C
> diff --git a/include/configs/mgsuvd.h b/include/configs/mgsuvd.h
> index 4ecaeac..2171115 100644
> --- a/include/configs/mgsuvd.h
> +++ b/include/configs/mgsuvd.h
> @@ -356,6 +356,7 @@
> 
>  #define I2C_ACTIVE	do {} while (0)
>  #define I2C_TRISTATE	do {} while (0)
> +#define CONFIG_I2C_SOFT_EXTERN	extern int i2c_soft_read_pin (void);
>  #define I2C_READ	i2c_soft_read_pin ()
>  #define I2C_SDA(bit)	if(bit) { \
>  				*(unsigned short *)(I2C_BASE_DIR) &=  ~SDA_CONF; \
> diff --git a/include/i2c.h b/include/i2c.h
> index 9f771dd..24d535f 100644
> --- a/include/i2c.h
> +++ b/include/i2c.h
> @@ -76,6 +76,10 @@
>  #  define I2C_SOFT_DECLARATIONS
>  # endif
>  #endif
> +
> +#ifndef CONFIG_I2C_SOFT_EXTERN
> +#define CONFIG_I2C_SOFT_EXTERN
> +#endif
>  /*
>   * Initialization, must be called once on start up, may be called
>   * repeatedly to change the speed and slave addresses.

NAK. This is really ugly.

Please make i2c_soft_read_pin () an inline function so it's sufficient
to change the I2C_READ definition in include/configs/mgsuvd.h

Umm...  while  we  are  at  it  -  there  is  a  lot   of   code   in
"board/keymile/mgsuvd/mgsuvd.c" that needs to be cleaned up:


 24 #if 0
 25 #define DEBUG
 26 #endif

Please remove.

167         memory_data[0] = cpu_to_be32(bd->bi_memstart);
168         memory_data[1] = cpu_to_be32(bd->bi_memsize);
169
170                 nodeoffset = fdt_path_offset (blob, "/memory");
171                 if (nodeoffset >= 0) {
172                         ret = fdt_setprop(blob, nodeoffset, "reg", memory_data,
173                                                 sizeof(memory_data));

Indentation is wrong here.

177                 }
178                 else {

make this "} else {"

180                         printf("ft_blob_update(): cannot find /memory node "
181                         "err:%s\n", fdt_strerror(nodeoffset));

Indentation.

187         if (nodeoffset >= 0) {
188                 ret = fdt_setprop(blob, nodeoffset, "ranges", flash_data,
189                                         sizeof(flash_data));
190         if (ret < 0)
191                 printf("ft_blob_update(): cannot set /localbus/ranges "
192                         "property err:%s\n", fdt_strerror(ret));
193         }
194         else {

Bad indentation and "} else {" again.

202         if (nodeoffset >= 0) {
203                 ret = fdt_setprop(blob, nodeoffset, "brg-frequency", brg_data,
204                                         sizeof(brg_data));
205         if (ret < 0)
206                 printf("ft_blob_update(): cannot set /soc/cpm/brg-frequency "
207                         "property err:%s\n", fdt_strerror(ret));
208         }
209         else {

Bad indentation and "} else {" again.

Oops. This is the third time  you  repeat  the  same  code?  And  yet
another time follows below? Please turn this into a function.


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
I often quote myself; it adds spice to my conversation.  - G. B. Shaw


More information about the U-Boot mailing list