From: Michael Hennerich <michael.hennerich@analog.com>
To: Axel Lin <axel.lin@ingics.com>, Mark Brown <broonie@kernel.org>
Cc: Liam Girdwood <lgirdwood@gmail.com>,
Sonic Zhang <sonic.zhang@analog.com>,
<linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] regulator: ad5398: Fix return value of ad5398_write_reg
Date: Fri, 12 Feb 2016 12:42:51 +0100 [thread overview]
Message-ID: <56BDC53B.9030506@analog.com> (raw)
In-Reply-To: <1455185823.6323.1.camel@ingics.com>
On 02/11/2016 11:17 AM, Axel Lin wrote:
> i2c_master_send() returns the number of bytes written on success.
> So current code returns 2 if ad5398_write_reg() success.
> This return value is propagated to .set_current_limit, .enable and .disable
> callbacks of regulator_ops. This can be a problem, for example, if the
> users test if the return value of regulator_set_current_limit() is 0.
> Fix it by making ad5398_write_reg() return 0 on success.
>
> Signed-off-by: Axel Lin <axel.lin@ingics.com>
Acked-by: Michael Hennerich <michael.hennerich@analog.com>
> ---
> drivers/regulator/ad5398.c | 6 ++++--
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/regulator/ad5398.c b/drivers/regulator/ad5398.c
> index ea50a88..8b0f788 100644
> --- a/drivers/regulator/ad5398.c
> +++ b/drivers/regulator/ad5398.c
> @@ -58,10 +58,12 @@ static int ad5398_write_reg(struct i2c_client *client, const unsigned short data
>
> val = cpu_to_be16(data);
> ret = i2c_master_send(client, (char *)&val, 2);
> - if (ret < 0)
> + if (ret != 2) {
> dev_err(&client->dev, "I2C write error\n");
> + return ret < 0 ? ret : -EIO;
> + }
>
> - return ret;
> + return 0;
> }
>
> static int ad5398_get_current_limit(struct regulator_dev *rdev)
>
--
Greetings,
Michael
--
Analog Devices GmbH Wilhelm-Wagenfeld-Str. 6 80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin,
Margaret Seif
prev parent reply other threads:[~2016-02-12 12:22 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-11 10:17 [PATCH] regulator: ad5398: Fix return value of ad5398_write_reg Axel Lin
2016-02-12 11:42 ` Michael Hennerich [this message]
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=56BDC53B.9030506@analog.com \
--to=michael.hennerich@analog.com \
--cc=axel.lin@ingics.com \
--cc=broonie@kernel.org \
--cc=lgirdwood@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=sonic.zhang@analog.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 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.