linux-fbdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Thompson <daniel.thompson@linaro.org>
To: Li Zhong <floridsleeves@gmail.com>
Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
	deller@gmx.de, jingoohan1@gmail.com, lee@kernel.org
Subject: Re: [PATCH v1] drivers:adp8870_bl: check the return value of adp8870_write
Date: Thu, 22 Sep 2022 10:34:19 +0100	[thread overview]
Message-ID: <YywsG6b/h+Mcs88y@maple.lan> (raw)
In-Reply-To: <20220921215049.1658796-1-floridsleeves@gmail.com>

On Wed, Sep 21, 2022 at 02:50:49PM -0700, Li Zhong wrote:
> Subject: [PATCH v1] drivers:adp8870_bl: check the return value of
> adp8870_write
                     ^^^^^^^^^^^^^^^^^^^^

Should be backlight: adp8870_bl.

> Check and propagate the return value of adp8870_write() when it fails,
> which is possible when SMBus writing byte fails.

This looks like a sensible change, however...

When writing patches like this please review the whole file for similar
concerns and fix all instances of the same issue. In this case there is another
unchecked call to adp8870_write() in
adp8870_bl_ambient_light_zone_store() (this function also contains
other unchecked calls).

Note that the unchecked use in adp8870_led_work() because there is no
way to propogate the error from this function (and adp8870_write()
already logged the error).

It would also be good to review and fix adp8860_bl.c at the same time
since these drivers are very similar (ideally the identical code in
these drivers should be factored out).


> Signed-off-by: Li Zhong <floridsleeves@gmail.com>
> ---
>  drivers/video/backlight/adp8870_bl.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c
> index 8b5213a39527..0eb4ae2ff592 100644
> --- a/drivers/video/backlight/adp8870_bl.c
> +++ b/drivers/video/backlight/adp8870_bl.c
> @@ -567,9 +567,13 @@ static ssize_t adp8870_store(struct device *dev, const char *buf,
>  		return ret;
>
>  	mutex_lock(&data->lock);
> -	adp8870_write(data->client, reg, val);
> +	ret = adp8870_write(data->client, reg, val);
>  	mutex_unlock(&data->lock);
>
> +	if (ret) {
> +		return ret;
> +	}

No need for braces here.

> +
>  	return count;
>  }
>

Thanks


Daniel.

      reply	other threads:[~2022-09-22  9:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-21 21:50 [PATCH v1] drivers:adp8870_bl: check the return value of adp8870_write Li Zhong
2022-09-22  9:34 ` Daniel Thompson [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=YywsG6b/h+Mcs88y@maple.lan \
    --to=daniel.thompson@linaro.org \
    --cc=deller@gmx.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=floridsleeves@gmail.com \
    --cc=jingoohan1@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-fbdev@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).