mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] misc: hmc6352: fix wrong return value checking for i2c_master_recv
@ 2011-03-09  8:41 Axel Lin
  2011-03-09 23:58 ` Andrew Morton
  0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2011-03-09  8:41 UTC (permalink / raw)
  To: linux-kernel; +Cc: Kalhan Trisal, Alan Cox, Andrew Morton

i2c_master_recv() returns negative errno, or else the number of bytes read.
Thus i2c_master_recv(client, i2c_data, 2) returns 2 instead of 1 in success case.

Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
 drivers/misc/hmc6352.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/misc/hmc6352.c b/drivers/misc/hmc6352.c
index 234bfca..3afc11e 100644
--- a/drivers/misc/hmc6352.c
+++ b/drivers/misc/hmc6352.c
@@ -86,7 +86,7 @@ static ssize_t compass_heading_data_show(struct device *dev,
 	msleep(10); /* sending 'A' cmd we need to wait for 7-10 millisecs */
 	ret = i2c_master_recv(client, i2c_data, 2);
 	mutex_unlock(&compass_mutex);
-	if (ret != 1) {
+	if (ret < 0) {
 		dev_warn(dev, "i2c read data cmd failed\n");
 		return ret;
 	}
-- 
1.7.2




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

end of thread, other threads:[~2011-03-09 23:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-09  8:41 [PATCH] misc: hmc6352: fix wrong return value checking for i2c_master_recv Axel Lin
2011-03-09 23:58 ` Andrew Morton

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

all inboxes | Powered by JetHome®