Patchwork [U-Boot,06/24] mxc_i2c.c: code i2c_probe as a 0 length i2c_write

login
register
mail settings
Submitter Troy Kisky
Date June 22, 2012, 4:12 a.m.
Message ID <1340338339-11626-6-git-send-email-troy.kisky@boundarydevices.com>
Download mbox | patch
Permalink /patch/166481/
State Superseded
Delegated to: Heiko Schocher
Headers show

Comments

Troy Kisky - June 22, 2012, 4:12 a.m.
Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
---
 drivers/i2c/mxc_i2c.c |   29 ++++++++---------------------
 1 file changed, 8 insertions(+), 21 deletions(-)
Marek Vasut - June 22, 2012, 5 p.m.
Dear Troy Kisky,

> Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>

Acked-by: Marek Vasut <marex@denx.de>

> ---
>  drivers/i2c/mxc_i2c.c |   29 ++++++++---------------------
>  1 file changed, 8 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
> index 626960d..4f12b9e 100644
> --- a/drivers/i2c/mxc_i2c.c
> +++ b/drivers/i2c/mxc_i2c.c
> @@ -302,27 +302,6 @@ exit:
>  }
> 
>  /*
> - * Try if a chip add given address responds (probe the chip)
> - */
> -int i2c_probe(uchar chip)
> -{
> -	struct mxc_i2c_regs *i2c_regs = (struct mxc_i2c_regs *)I2C_BASE;
> -	int ret;
> -
> -	ret = i2c_imx_start();
> -	if (ret)
> -		return ret;
> -
> -	ret = tx_byte(i2c_regs, chip << 1);
> -	if (ret)
> -		return ret;
> -
> -	i2c_imx_stop();
> -
> -	return ret;
> -}
> -
> -/*
>   * Read data from I2C device
>   */
>  int i2c_read(uchar chip, uint addr, int alen, uchar *buf, int len)
> @@ -404,3 +383,11 @@ int i2c_write(uchar chip, uint addr, int alen, uchar
> *buf, int len)
> 
>  	return ret;
>  }
> +
> +/*
> + * Try if a chip add given address responds (probe the chip)
> + */
> +int i2c_probe(uchar chip)
> +{
> +	return i2c_write(chip, 0, 0, NULL, 0);
> +}

Best regards,
Marek Vasut
Stefano Babic - June 24, 2012, 8:03 a.m.
On 22/06/2012 06:12, Troy Kisky wrote:
> Signed-off-by: Troy Kisky <troy.kisky@boundarydevices.com>
> ---
>  drivers/i2c/mxc_i2c.c |   29 ++++++++---------------------
>  1 file changed, 8 insertions(+), 21 deletions(-)
> 
> diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
> index 626960d..4f12b9e 100644
> --- a/drivers/i2c/mxc_i2c.c
> +++ b/drivers/i2c/mxc_i2c.c
> @@ -302,27 +302,6 @@ exit:
>  }
>  
>  /*
> - * Try if a chip add given address responds (probe the chip)
> - */
> -int i2c_probe(uchar chip)
> -{
> -	struct mxc_i2c_regs *i2c_regs = (struct mxc_i2c_regs *)I2C_BASE;
> -	int ret;
> -
> -	ret = i2c_imx_start();
> -	if (ret)
> -		return ret;
> -
> -	ret = tx_byte(i2c_regs, chip << 1);
> -	if (ret)
> -		return ret;
> -
> -	i2c_imx_stop();
> -
> -	return ret;
> -}
> -
> -/*
>   * Read data from I2C device
>   */
>  int i2c_read(uchar chip, uint addr, int alen, uchar *buf, int len)
> @@ -404,3 +383,11 @@ int i2c_write(uchar chip, uint addr, int alen, uchar *buf, int len)
>  
>  	return ret;
>  }
> +
> +/*
> + * Try if a chip add given address responds (probe the chip)
> + */
> +int i2c_probe(uchar chip)
> +{
> +	return i2c_write(chip, 0, 0, NULL, 0);
> +}
> 

Acked-by: Stefano Babic <sbabic@denx.de>

Best regards,
Stefano Babic

Patch

diff --git a/drivers/i2c/mxc_i2c.c b/drivers/i2c/mxc_i2c.c
index 626960d..4f12b9e 100644
--- a/drivers/i2c/mxc_i2c.c
+++ b/drivers/i2c/mxc_i2c.c
@@ -302,27 +302,6 @@  exit:
 }
 
 /*
- * Try if a chip add given address responds (probe the chip)
- */
-int i2c_probe(uchar chip)
-{
-	struct mxc_i2c_regs *i2c_regs = (struct mxc_i2c_regs *)I2C_BASE;
-	int ret;
-
-	ret = i2c_imx_start();
-	if (ret)
-		return ret;
-
-	ret = tx_byte(i2c_regs, chip << 1);
-	if (ret)
-		return ret;
-
-	i2c_imx_stop();
-
-	return ret;
-}
-
-/*
  * Read data from I2C device
  */
 int i2c_read(uchar chip, uint addr, int alen, uchar *buf, int len)
@@ -404,3 +383,11 @@  int i2c_write(uchar chip, uint addr, int alen, uchar *buf, int len)
 
 	return ret;
 }
+
+/*
+ * Try if a chip add given address responds (probe the chip)
+ */
+int i2c_probe(uchar chip)
+{
+	return i2c_write(chip, 0, 0, NULL, 0);
+}