diff mbox

i2c: exynos5: simplify transfer function

Message ID 20180511093307.10362-1-a.hajda@samsung.com (mailing list archive)
State Not Applicable
Headers show

Commit Message

Andrzej Hajda May 11, 2018, 9:33 a.m. UTC
exynos5_i2c_xfer contains lots of dead code, let's remove it and simplify
the rest. The patch should not introduce functional changes.

Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
Suggested-by: Peter Rosin <peda@axentia.se>
---
 drivers/i2c/busses/i2c-exynos5.c | 29 +++++++----------------------
 1 file changed, 7 insertions(+), 22 deletions(-)

Comments

Andi Shyti May 11, 2018, 9:55 a.m. UTC | #1
Hi Andrzej,

On Fri, May 11, 2018 at 11:33:07AM +0200, Andrzej Hajda wrote:
> exynos5_i2c_xfer contains lots of dead code, let's remove it and simplify
> the rest. The patch should not introduce functional changes.
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> Suggested-by: Peter Rosin <peda@axentia.se>

looks prettier :)

Reviewed-by: Andi Shyti <andi@etezian.org>

Thsnk you,
Andi
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Peter Rosin May 13, 2018, 9:10 p.m. UTC | #2
On 2018-05-11 11:33, Andrzej Hajda wrote:
> exynos5_i2c_xfer contains lots of dead code, let's remove it and simplify
> the rest. The patch should not introduce functional changes.
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> Suggested-by: Peter Rosin <peda@axentia.se>

Reviewed-by: Peter Rosin <peda@axentia.se>

Thanks for taking this the extra mile.

Cheers,
Peter
--
To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Wolfram Sang May 14, 2018, 10:11 p.m. UTC | #3
On Fri, May 11, 2018 at 11:33:07AM +0200, Andrzej Hajda wrote:
> exynos5_i2c_xfer contains lots of dead code, let's remove it and simplify
> the rest. The patch should not introduce functional changes.
> 
> Signed-off-by: Andrzej Hajda <a.hajda@samsung.com>
> Suggested-by: Peter Rosin <peda@axentia.se>

Applied to for-next, thanks!
diff mbox

Patch

diff --git a/drivers/i2c/busses/i2c-exynos5.c b/drivers/i2c/busses/i2c-exynos5.c
index 12ec8484e653..de82ad8ff534 100644
--- a/drivers/i2c/busses/i2c-exynos5.c
+++ b/drivers/i2c/busses/i2c-exynos5.c
@@ -707,7 +707,7 @@  static int exynos5_i2c_xfer(struct i2c_adapter *adap,
 			struct i2c_msg *msgs, int num)
 {
 	struct exynos5_i2c *i2c = adap->algo_data;
-	int i = 0, ret = 0, stop = 0;
+	int i, ret;
 
 	if (i2c->suspended) {
 		dev_err(i2c->dev, "HS-I2C is not initialized.\n");
@@ -718,30 +718,15 @@  static int exynos5_i2c_xfer(struct i2c_adapter *adap,
 	if (ret)
 		return ret;
 
-	for (i = 0; i < num; i++, msgs++) {
-		stop = (i == num - 1);
-
-		ret = exynos5_i2c_xfer_msg(i2c, msgs, stop);
-
-		if (ret < 0)
-			goto out;
-	}
-
-	if (i == num) {
-		ret = num;
-	} else {
-		/* Only one message, cannot access the device */
-		if (i == 1)
-			ret = -EREMOTEIO;
-		else
-			ret = i;
-
-		dev_warn(i2c->dev, "xfer message failed\n");
+	for (i = 0; i < num; ++i) {
+		ret = exynos5_i2c_xfer_msg(i2c, msgs + i, i + 1 == num);
+		if (ret)
+			break;
 	}
 
- out:
 	clk_disable(i2c->clk);
-	return ret;
+
+	return ret ?: num;
 }
 
 static u32 exynos5_i2c_func(struct i2c_adapter *adap)