From: Eduardo Valentin <eduardo.valentin@nokia.com>
To: ext Amit Kucheria <amit.kucheria@verdurent.com>
Cc: Samuel Ortiz <sameo@linux.intel.com>,
"gadiyar@ti.com" <gadiyar@ti.com>,
List Linux Kernel <linux-kernel@vger.kernel.org>,
List Linux Omap <linux-omap@vger.kernel.org>
Subject: Re: [PATCH 1/1] mfd: twl4030: clarify the return value for read and write
Date: Mon, 7 Dec 2009 15:53:09 +0200 [thread overview]
Message-ID: <20091207135309.GA23829@esdhcp037198.research.nokia.com> (raw)
In-Reply-To: <449d505b874c236e4d0df0c1f765918386a4d58b.1260187781.git.amit.kucheria@verdurent.com>
On Mon, Dec 07, 2009 at 01:17:29PM +0100, ext Amit Kucheria wrote:
> Infact, we can just return -EIO 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 <amit.kucheria@verdurent.com>
> ---
> drivers/mfd/twl4030-core.c | 24 ++++++++++++++++--------
> 1 files changed, 16 insertions(+), 8 deletions(-)
>
> 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;
How about reporting the actual error that has occurred and reported by i2c_transfer?
Instead of just masking it as EIO? If i2c_transfer returns something > 0 then EIO should be right.
But if returns and error code, then that error code must be reported to upper layers.
> + } 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;
dito.
> + } else {
> + return 0;
> + }
> }
> EXPORT_SYMBOL(twl4030_i2c_read);
>
> --
> 1.6.3.3
>
> --
> 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/
--
Eduardo Valentin
next prev parent reply other threads:[~2009-12-07 13:53 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-02 13:31 [PATCH] " 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 [this message]
2009-12-11 10:36 ` Samuel Ortiz
2009-12-11 10:53 ` Eduardo Valentin
2009-12-11 12:11 ` Samuel Ortiz
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20091207135309.GA23829@esdhcp037198.research.nokia.com \
--to=eduardo.valentin@nokia.com \
--cc=amit.kucheria@verdurent.com \
--cc=gadiyar@ti.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=sameo@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®