From patchwork Fri Dec 11 10:36:10 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Samuel Ortiz X-Patchwork-Id: 66582 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 nBBAYe8T006297 for ; Fri, 11 Dec 2009 10:34:40 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760691AbZLKKeb (ORCPT ); Fri, 11 Dec 2009 05:34:31 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757502AbZLKKea (ORCPT ); Fri, 11 Dec 2009 05:34:30 -0500 Received: from mga12.intel.com ([143.182.124.36]:14777 "EHLO azsmga102.ch.intel.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1754728AbZLKKe3 (ORCPT ); Fri, 11 Dec 2009 05:34:29 -0500 Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga102.ch.intel.com with ESMTP; 11 Dec 2009 02:34:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.47,316,1257148800"; d="scan'208";a="221519010" Received: from unknown (HELO sortiz-mobl) ([10.255.17.3]) by azsmga001.ch.intel.com with ESMTP; 11 Dec 2009 02:34:33 -0800 Date: Fri, 11 Dec 2009 11:36:10 +0100 From: Samuel Ortiz To: Eduardo Valentin , Amit Kucheria Cc: "gadiyar@ti.com" , List Linux Kernel , List Linux Omap Subject: Re: [PATCH 1/1] mfd: twl4030: clarify the return value for read and write Message-ID: <20091211103609.GB5863@sortiz.org> References: <5A47E75E594F054BAF48C5E4FC4B92AB0309DAC23C@dbde02.ent.ti.com> <449d505b874c236e4d0df0c1f765918386a4d58b.1260187781.git.amit.kucheria@verdurent.com> <20091207135309.GA23829@esdhcp037198.research.nokia.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20091207135309.GA23829@esdhcp037198.research.nokia.com> User-Agent: Mutt/1.5.20 (2009-06-14) 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 e4a5d48..8add16c 100644 --- a/drivers/mfd/twl4030-core.c +++ b/drivers/mfd/twl4030-core.c @@ -306,10 +306,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 ret; + } else { + return 0; + } } EXPORT_SYMBOL(twl4030_i2c_write); @@ -358,10 +362,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 ret; + } else { + return 0; + } } EXPORT_SYMBOL(twl4030_i2c_read);