| From 32cac77a5363a46de87b4fe680bfc7f554305253 Mon Sep 17 00:00:00 2001 |
| From: Wolfram Sang <wsa+renesas@sang-engineering.com> |
| Date: Wed, 28 May 2014 09:44:40 +0200 |
| Subject: i2c: rcar: check bus free before first message |
| |
| We should always check if the bus is free, independently if it is a read |
| or write. It should be done before the first message, though. After |
| that, we ourselves keep the bus busy. Remove a 'ret' assignment which |
| only silenced a build warning. |
| |
| Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com> |
| Acked-by: Kuninori Morimoto <kuninori.morimoto.gx@renesas.com> |
| Acked-by: Geert Uytterhoeven <geert@linux-m68k.org> |
| Signed-off-by: Wolfram Sang <wsa@the-dreams.de> |
| (cherry picked from commit 3f7de22eb28244fc79bc744d9f51d018da343962) |
| Signed-off-by: Simon Horman <horms+renesas@verge.net.au> |
| --- |
| drivers/i2c/busses/i2c-rcar.c | 16 +++++----------- |
| 1 file changed, 5 insertions(+), 11 deletions(-) |
| |
| diff --git a/drivers/i2c/busses/i2c-rcar.c b/drivers/i2c/busses/i2c-rcar.c |
| index f2cbb8a7d0ba..828b519146fc 100644 |
| --- a/drivers/i2c/busses/i2c-rcar.c |
| +++ b/drivers/i2c/busses/i2c-rcar.c |
| @@ -294,15 +294,6 @@ static int rcar_i2c_recv(struct rcar_i2c_priv *priv) |
| |
| static int rcar_i2c_send(struct rcar_i2c_priv *priv) |
| { |
| - int ret; |
| - |
| - /* |
| - * It should check bus status when send case |
| - */ |
| - ret = rcar_i2c_bus_barrier(priv); |
| - if (ret < 0) |
| - return ret; |
| - |
| rcar_i2c_set_addr(priv, 0); |
| rcar_i2c_status_clear(priv); |
| rcar_i2c_write(priv, ICMCR, RCAR_BUS_PHASE_START); |
| @@ -508,7 +499,10 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap, |
| spin_unlock_irqrestore(&priv->lock, flags); |
| /*-------------- spin unlock -----------------*/ |
| |
| - ret = -EINVAL; |
| + ret = rcar_i2c_bus_barrier(priv); |
| + if (ret < 0) |
| + goto out; |
| + |
| for (i = 0; i < num; i++) { |
| /* This HW can't send STOP after address phase */ |
| if (msgs[i].len == 0) { |
| @@ -569,7 +563,7 @@ static int rcar_i2c_master_xfer(struct i2c_adapter *adap, |
| |
| ret = i + 1; /* The number of transfer */ |
| } |
| - |
| +out: |
| pm_runtime_put(dev); |
| |
| if (ret < 0 && ret != -ENXIO) |
| -- |
| 2.1.2 |
| |