public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mfd: twl4030: clarify the return value for read and write
@ 2009-12-02 13:31 Amit Kucheria
  2009-12-02 13:41 ` Felipe Balbi
  2009-12-02 14:00 ` [PATCHv2] " Amit Kucheria
  0 siblings, 2 replies; 9+ messages in thread
From: Amit Kucheria @ 2009-12-02 13:31 UTC (permalink / raw)
  To: List Linux Kernel; +Cc: Samuel Ortiz, List Linux Omap

We should be checking if all the messages were tranferred or not. Currently we
return success even if none of messages were transferred successfully.

Signed-off-by: Amit Kucheria <amit.kucheria@verdurent.com>
---
 drivers/mfd/twl4030-core.c |   21 +++++++++++++--------
 1 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c
index cf462b9..6ace378 100644
--- a/drivers/mfd/twl4030-core.c
+++ b/drivers/mfd/twl4030-core.c
@@ -298,10 +298,12 @@ int twl4030_i2c_write(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
 	ret = i2c_transfer(twl->client->adapter, twl->xfer_msg, 1);
 	mutex_unlock(&twl->xfer_lock);
 
-	/* i2cTransfer returns num messages.translate it pls.. */
-	if (ret >= 0)
-		ret = 0;
-	return ret;
+	/* i2c_transfer returns number of messages transferred */
+	if (ret != 1) {
+		pr_err("%s: twl4030_i2c_write failed to transfer all messages\n", DRIVER_NAME);
+		return ret;
+	} else
+		return 0;
 }
 EXPORT_SYMBOL(twl4030_i2c_write);
 
@@ -350,10 +352,13 @@ int twl4030_i2c_read(u8 mod_no, u8 *value, u8 reg, unsigned num_bytes)
 	ret = i2c_transfer(twl->client->adapter, twl->xfer_msg, 2);
 	mutex_unlock(&twl->xfer_lock);
 
-	/* i2cTransfer returns num messages.translate it pls.. */
-	if (ret >= 0)
-		ret = 0;
-	return ret;
+	/* i2c_transfer returns number of messages transferred */
+	if (ret != 2) {
+		pr_err("%s: twl4030_i2c_read failed to transfer all messages\n", DRIVER_NAME);
+		return ret;
+	}
+	else
+		return 0;
 }
 EXPORT_SYMBOL(twl4030_i2c_read);
 
-- 
1.6.3.3


^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-12-11 12:09 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-02 13:31 [PATCH] mfd: twl4030: clarify the return value for read and write Amit Kucheria
2009-12-02 13:41 ` Felipe Balbi
2009-12-02 14:00 ` [PATCHv2] " Amit Kucheria
2009-12-02 15:05   ` Gadiyar, Anand
2009-12-07 12:17     ` [PATCH 1/1] " Amit Kucheria
2009-12-07 13:53       ` Eduardo Valentin
2009-12-11 10:36         ` Samuel Ortiz
2009-12-11 10:53           ` Eduardo Valentin
2009-12-11 12:11             ` Samuel Ortiz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox