Re: [U-Boot] [PATCH v3 5/6] i2c: rcar_i2c: Set the slave address from rcar_i2c_xfer

2019-03-06 Thread Heiko Schocher

Hello Ismael,

Am 06.03.2019 um 11:46 schrieb Ismael Luceno Cortes:

It needs to be done for both reads and writes, so do it at rcar_i2c_xfer
to avoid duplication.

Signed-off-by: Ismael Luceno 
---
  drivers/i2c/rcar_i2c.c | 14 +-
  1 file changed, 5 insertions(+), 9 deletions(-)


Reviewed-by: Heiko Schocher 

bye,
Heiko
--
DENX Software Engineering GmbH,  Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: +49-8142-66989-52   Fax: +49-8142-66989-80   Email: h...@denx.de
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


Re: [U-Boot] [PATCH v3 5/6] i2c: rcar_i2c: Set the slave address from rcar_i2c_xfer

2019-03-06 Thread Marek Vasut
On 3/6/19 11:46 AM, Ismael Luceno Cortes wrote:
> It needs to be done for both reads and writes, so do it at rcar_i2c_xfer
> to avoid duplication.
> 
> Signed-off-by: Ismael Luceno 


Reviewed-by: Marek Vasut 

-- 
Best regards,
Marek Vasut
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot


[U-Boot] [PATCH v3 5/6] i2c: rcar_i2c: Set the slave address from rcar_i2c_xfer

2019-03-06 Thread Ismael Luceno Cortes
It needs to be done for both reads and writes, so do it at rcar_i2c_xfer
to avoid duplication.

Signed-off-by: Ismael Luceno 
---
 drivers/i2c/rcar_i2c.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/rcar_i2c.c b/drivers/i2c/rcar_i2c.c
index 9223eaecbf..78ef8acacc 100644
--- a/drivers/i2c/rcar_i2c.c
+++ b/drivers/i2c/rcar_i2c.c
@@ -158,10 +158,6 @@ static int rcar_i2c_read_common(struct udevice *dev, 
struct i2c_msg *msg)
u32 icmcr = RCAR_I2C_ICMCR_MDBS | RCAR_I2C_ICMCR_MIE;
int i, ret = -EREMOTEIO;
 
-   ret = rcar_i2c_set_addr(dev, msg->addr, 1);
-   if (ret)
-   return ret;
-
for (i = 0; i < msg->len; i++) {
if (msg->len - 1 == i)
icmcr |= RCAR_I2C_ICMCR_FSB;
@@ -188,10 +184,6 @@ static int rcar_i2c_write_common(struct udevice *dev, 
struct i2c_msg *msg)
u32 icmcr = RCAR_I2C_ICMCR_MDBS | RCAR_I2C_ICMCR_MIE;
int i, ret = -EREMOTEIO;
 
-   ret = rcar_i2c_set_addr(dev, msg->addr, 0);
-   if (ret)
-   return ret;
-
for (i = 0; i < msg->len; i++) {
writel(msg->buf[i], priv->base + RCAR_I2C_ICRXD_ICTXD);
writel(icmcr, priv->base + RCAR_I2C_ICMCR);
@@ -215,6 +207,10 @@ static int rcar_i2c_xfer(struct udevice *dev, struct 
i2c_msg *msg, int nmsgs)
int ret;
 
for (; nmsgs > 0; nmsgs--, msg++) {
+   ret = rcar_i2c_set_addr(dev, msg->addr, 1);
+   if (ret)
+   return ret;
+
if (msg->flags & I2C_M_RD)
ret = rcar_i2c_read_common(dev, msg);
else
@@ -224,7 +220,7 @@ static int rcar_i2c_xfer(struct udevice *dev, struct 
i2c_msg *msg, int nmsgs)
return ret;
}
 
-   return ret;
+   return 0;
 }
 
 static int rcar_i2c_probe_chip(struct udevice *dev, uint addr, uint flags)
-- 
2.19.1
___
U-Boot mailing list
U-Boot@lists.denx.de
https://lists.denx.de/listinfo/u-boot