[U-Boot] [PATCH] designware_i2c: Enhance DesignWare I2C driver address support

Alexey Brodkin Alexey.Brodkin at synopsys.com
Wed Jan 15 16:30:24 CET 2014


On Wed, 2014-01-15 at 08:58 -0600, Chin Liang See wrote:
> Enhance the DesignWare I2C driver to support address length more
> than 1 byte. This enhancement is required as some I2C slave
> device such as EEPROM chip might have 16 bit address byte.
> diff --git a/drivers/i2c/designware_i2c.c b/drivers/i2c/designware_i2c.c
> index cb2ac04..c0ac5f7 100644
> --- a/drivers/i2c/designware_i2c.c
> +++ b/drivers/i2c/designware_i2c.c
> @@ -205,27 +205,21 @@ static int check_params(uint addr, int alen, uchar *buffer, int len)
>  		return 1;
>  	}
>  
> -	if (alen > 1) {
> -		printf("addr len %d not supported\n", alen);
> -		return 1;
> -	}
> -
> -	if (addr + len > 256) {
> -		printf("address out of range\n");
> -		return 1;
> -	}
> -
>  	return 0;
>  }

Hi Chin,

if you strip down functionality of "check_params()" to one single check
I would recommend you to remove "check_params()" at all and do in-place
check for "buffer" existence.

Moreover you may just use "assert" for this check because this buffer is
passed by u-boot (no need to check every parameter passed to any
function in run-time) so in production/release build it won't exist at
all.

Regards,
Alexey



More information about the U-Boot mailing list