From: Sam Ravnborg <sam@ravnborg.org>
To: Kangjie Lu <kjlu@umn.edu>
Cc: Daniel Thompson <daniel.thompson@linaro.org>,
Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
Jingoo Han <jingoohan1@gmail.com>,
linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org, pakki001@umn.edu,
Lee Jones <lee.jones@linaro.org>
Subject: Re: [PATCH] backlight: (adp8870) fix a missing check for adp8870_write
Date: Thu, 27 Dec 2018 10:39:51 +0100 [thread overview]
Message-ID: <20181227093951.GA14579@ravnborg.org> (raw)
In-Reply-To: <20181225062109.66943-1-kjlu@umn.edu>
Hi Kangjie
> adp8870_write() may fail. This fix checks if adp8870_write fails, and if
> so, returns its error code.
>
> Signed-off-by: Kangjie Lu <kjlu@umn.edu>
> ---
> drivers/video/backlight/adp8870_bl.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c
> index 8d50e0299578..79901fb4fcd1 100644
> --- a/drivers/video/backlight/adp8870_bl.c
> +++ b/drivers/video/backlight/adp8870_bl.c
> @@ -811,9 +811,14 @@ static ssize_t adp8870_bl_ambient_light_zone_store(struct device *dev,
> if (!ret) {
> reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT);
> reg_val |= (val - 1) << CFGR_BLV_SHIFT;
> - adp8870_write(data->client, ADP8870_CFGR, reg_val);
> - }
> - mutex_unlock(&data->lock);
> + ret = adp8870_write(data->client,
> + ADP8870_CFGR, reg_val);
> + if (ret) {
> + mutex_unlock(&data->lock);
> + return ret;
> + }
> + } else
> + mutex_unlock(&data->lock);
> }
Something looks wrong with the indent.
If you have braces around first part of if () then use
barces also after else. Then it is easier to follow the code.
In this case please consider another approach where you
have only a single mutex_unlock() both in the good and
in the error case.
Sam
next prev parent reply other threads:[~2018-12-27 9:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-25 6:21 [PATCH] backlight: (adp8870) fix a missing check for adp8870_write Kangjie Lu
2018-12-27 9:39 ` Sam Ravnborg [this message]
2019-01-03 16:48 ` Daniel Thompson
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=20181227093951.GA14579@ravnborg.org \
--to=sam@ravnborg.org \
--cc=b.zolnierkie@samsung.com \
--cc=daniel.thompson@linaro.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=jingoohan1@gmail.com \
--cc=kjlu@umn.edu \
--cc=lee.jones@linaro.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pakki001@umn.edu \
/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