From: Samuel Ortiz <sameo@openedhand.com>
To: Mark Brown <broonie@opensource.wolfsonmicro.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2.6.28] mfd: Correct WM8350 I2C return code usage
Date: Wed, 12 Nov 2008 19:49:57 +0100 [thread overview]
Message-ID: <20081112184956.GA17382@sortiz.org> (raw)
In-Reply-To: <1226324477-21022-1-git-send-email-broonie@opensource.wolfsonmicro.com>
Hi Mark,
On Mon, Nov 10, 2008 at 01:41:17PM +0000, Mark Brown wrote:
> The vendor BSP used for the WM8350 development provided an I2C driver
> which incorrectly returned zero on succesful sends rather than the
> number of transmitted bytes, an error which was then propagated into the
> WM8350 I2C accessors.
Shouldnt we fix the accessors behaviour instead ?
Currently, that would mean fixing some of the wm8350-core static functions.
Slightly bigger patch, but that would keep the i2c interface consistent.
What do you think ?
Cheers,
Samuel.
> Signed-off-by: Mark Brown <broonie@opensource.wolfsonmicro.com>
> ---
> drivers/mfd/wm8350-i2c.c | 15 +++++++++++++--
> 1 files changed, 13 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/mfd/wm8350-i2c.c b/drivers/mfd/wm8350-i2c.c
> index 8dfe21b..3e0ce0e 100644
> --- a/drivers/mfd/wm8350-i2c.c
> +++ b/drivers/mfd/wm8350-i2c.c
> @@ -30,7 +30,12 @@ static int wm8350_i2c_read_device(struct wm8350 *wm8350, char reg,
> ret = i2c_master_send(wm8350->i2c_client, ®, 1);
> if (ret < 0)
> return ret;
> - return i2c_master_recv(wm8350->i2c_client, dest, bytes);
> + ret = i2c_master_recv(wm8350->i2c_client, dest, bytes);
> + if (ret < 0)
> + return ret;
> + if (ret != bytes)
> + return -EIO;
> + return 0;
> }
>
> static int wm8350_i2c_write_device(struct wm8350 *wm8350, char reg,
> @@ -38,13 +43,19 @@ static int wm8350_i2c_write_device(struct wm8350 *wm8350, char reg,
> {
> /* we add 1 byte for device register */
> u8 msg[(WM8350_MAX_REGISTER << 1) + 1];
> + int ret;
>
> if (bytes > ((WM8350_MAX_REGISTER << 1) + 1))
> return -EINVAL;
>
> msg[0] = reg;
> memcpy(&msg[1], src, bytes);
> - return i2c_master_send(wm8350->i2c_client, msg, bytes + 1);
> + ret = i2c_master_send(wm8350->i2c_client, msg, bytes + 1);
> + if (ret < 0)
> + return ret;
> + if (ret != bytes + 1)
> + return -EIO;
> + return 0;
> }
>
> static int wm8350_i2c_probe(struct i2c_client *i2c,
> --
> 1.5.6.5
>
--
Intel Open Source Technology Centre
http://oss.intel.com/
next prev parent reply other threads:[~2008-11-12 18:47 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-11-10 13:41 [PATCH 2.6.28] mfd: Correct WM8350 I2C return code usage Mark Brown
2008-11-12 18:49 ` Samuel Ortiz [this message]
2008-11-12 20:00 ` Mark Brown
2008-11-12 23:06 ` Samuel Ortiz
2008-11-12 23:43 ` Mark Brown
2008-11-16 22:30 ` Samuel Ortiz
-- strict thread matches above, loose matches on Subject: below --
2008-11-06 13:24 Mark Brown
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=20081112184956.GA17382@sortiz.org \
--to=sameo@openedhand.com \
--cc=broonie@opensource.wolfsonmicro.com \
--cc=linux-kernel@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.