Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754846AbZLBPGK (ORCPT ); Wed, 2 Dec 2009 10:06:10 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754802AbZLBPGI (ORCPT ); Wed, 2 Dec 2009 10:06:08 -0500 Received: from arroyo.ext.ti.com ([192.94.94.40]:39280 "EHLO arroyo.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753699AbZLBPGD convert rfc822-to-8bit (ORCPT ); Wed, 2 Dec 2009 10:06:03 -0500 From: "Gadiyar, Anand" To: Amit Kucheria , List Linux Kernel CC: Samuel Ortiz , List Linux Omap Date: Wed, 2 Dec 2009 20:35:57 +0530 Subject: RE: [PATCHv2] mfd: twl4030: clarify the return value for read and write Thread-Topic: [PATCHv2] mfd: twl4030: clarify the return value for read and write Thread-Index: AcpzV/kTKkdlGCHTT1u5oeblSSLwugACJnsQ Message-ID: <5A47E75E594F054BAF48C5E4FC4B92AB0309DAC23C@dbde02.ent.ti.com> References: <1259760678-18707-1-git-send-email-amit.kucheria@verdurent.com> <1259762450-7385-1-git-send-email-amit.kucheria@verdurent.com> In-Reply-To: <1259762450-7385-1-git-send-email-amit.kucheria@verdurent.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: acceptlanguage: en-US Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7BIT MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2198 Lines: 65 Amit Kucheria wrote: > Infact, we can just return -1 so that caller knows for sure that all messages > were not tranferred. Please consider fixed patch instead. > > We should be checking if all the messages were tranferred or not. And return > -1 for failure. Currently we return success (0) even if none of messages were > transferred successfully. > > Signed-off-by: Amit Kucheria > --- > drivers/mfd/twl4030-core.c | 25 +++++++++++++++++-------- > 1 files changed, 17 insertions(+), 8 deletions(-) > > diff --git a/drivers/mfd/twl4030-core.c b/drivers/mfd/twl4030-core.c > index 56f1de5..8f9ba79 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 -1; > + } else { > + return 0; > + } > } > EXPORT_SYMBOL(twl4030_i2c_write); > > @@ -344,10 +348,15 @@ 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 -1; > + } > + else { > + return 0; > + } The else clause should be on the same line as the brace closing the if clause. like you did above So says Documentation/CodingStyle. - Anand -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/