From patchwork Mon Dec 7 12:17:29 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amit Kucheria X-Patchwork-Id: 65502 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id nB7CIdls011927 for ; Mon, 7 Dec 2009 12:18:39 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934676AbZLGMRf (ORCPT ); Mon, 7 Dec 2009 07:17:35 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S934653AbZLGMRf (ORCPT ); Mon, 7 Dec 2009 07:17:35 -0500 Received: from smtp.nokia.com ([192.100.105.134]:28579 "EHLO mgw-mx09.nokia.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934474AbZLGMRe (ORCPT ); Mon, 7 Dec 2009 07:17:34 -0500 Received: from esebh106.NOE.Nokia.com (esebh106.ntc.nokia.com [172.21.138.213]) by mgw-mx09.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nB7CHRV7013198; Mon, 7 Dec 2009 06:17:35 -0600 Received: from vaebh104.NOE.Nokia.com ([10.160.244.30]) by esebh106.NOE.Nokia.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 7 Dec 2009 14:17:31 +0200 Received: from mgw-sa01.ext.nokia.com ([147.243.1.47]) by vaebh104.NOE.Nokia.com over TLS secured channel with Microsoft SMTPSVC(6.0.3790.3959); Mon, 7 Dec 2009 14:17:31 +0200 Received: from localhost.localdomain (esdhcp036155.research.nokia.com [172.21.36.155]) by mgw-sa01.ext.nokia.com (Switch-3.3.3/Switch-3.3.3) with ESMTP id nB7CHTLa000600; Mon, 7 Dec 2009 14:17:30 +0200 From: Amit Kucheria To: Samuel Ortiz Cc: gadiyar@ti.com, List Linux Kernel , List Linux Omap Subject: [PATCH 1/1] mfd: twl4030: clarify the return value for read and write Date: Mon, 7 Dec 2009 14:17:29 +0200 Message-Id: <449d505b874c236e4d0df0c1f765918386a4d58b.1260187781.git.amit.kucheria@verdurent.com> X-Mailer: git-send-email 1.6.3.3 In-Reply-To: <5A47E75E594F054BAF48C5E4FC4B92AB0309DAC23C@dbde02.ent.ti.com> References: <5A47E75E594F054BAF48C5E4FC4B92AB0309DAC23C@dbde02.ent.ti.com> X-OriginalArrivalTime: 07 Dec 2009 12:17:31.0250 (UTC) FILETIME=[3FE72520:01CA7737] X-Nokia-AV: Clean Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c index 56f1de5..3d2c413 100644 --- a/drivers/mfd/twl4030-core.c +++ b/drivers/mfd/twl4030-core.c @@ -292,10 +292,14 @@ 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: i2c_write failed to transfer all messages\n", + DRIVER_NAME); + return -EIO; + } else { + return 0; + } } EXPORT_SYMBOL(twl4030_i2c_write); @@ -344,10 +348,14 @@ 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: i2c_read failed to transfer all messages\n", + DRIVER_NAME); + return -EIO; + } else { + return 0; + } } EXPORT_SYMBOL(twl4030_i2c_read);