From: Artur Weber <aweber.kernel@gmail.com>
To: Lee Jones <lee@kernel.org>
Cc: "Daniel Thompson" <daniel.thompson@linaro.org>,
"Jingoo Han" <jingoohan1@gmail.com>,
"Helge Deller" <deller@gmx.de>,
"Thierry Reding" <thierry.reding@gmail.com>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
"Artur Weber" <aweber.kernel@gmail.com>,
dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org,
~postmarketos/upstreaming@lists.sr.ht
Subject: [PATCH 2/2] backlight: lp855x: Catch errors when changing brightness
Date: Fri, 14 Jul 2023 14:14:40 +0200 [thread overview]
Message-ID: <20230714121440.7717-3-aweber.kernel@gmail.com> (raw)
In-Reply-To: <20230714121440.7717-1-aweber.kernel@gmail.com>
The lp855x_bl_update_status function's return type is int, but
it always returns 0, without checking for the results of the
write_byte/pwm_ctrl functions called within.
Make this function return the return values of the functions it
calls, and modify the lp855x_pwm_ctrl function to return errors.
Signed-off-by: Artur Weber <aweber.kernel@gmail.com>
---
drivers/video/backlight/lp855x_bl.c | 13 ++++++++-----
1 file changed, 8 insertions(+), 5 deletions(-)
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index 349ec324bc1e..61a7f45bfad8 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -217,7 +217,7 @@ static int lp855x_configure(struct lp855x *lp)
return ret;
}
-static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
+static int lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
{
struct pwm_state state;
@@ -234,23 +234,26 @@ static void lp855x_pwm_ctrl(struct lp855x *lp, int br, int max_br)
state.duty_cycle = div_u64(br * state.period, max_br);
state.enabled = state.duty_cycle;
- pwm_apply_state(lp->pwm, &state);
+ return pwm_apply_state(lp->pwm, &state);
}
static int lp855x_bl_update_status(struct backlight_device *bl)
{
struct lp855x *lp = bl_get_data(bl);
int brightness = bl->props.brightness;
+ int ret;
if (bl->props.state & (BL_CORE_SUSPENDED | BL_CORE_FBBLANK))
brightness = 0;
if (lp->mode == PWM_BASED)
- lp855x_pwm_ctrl(lp, brightness, bl->props.max_brightness);
+ ret = lp855x_pwm_ctrl(lp, brightness,
+ bl->props.max_brightness);
else if (lp->mode == REGISTER_BASED)
- lp855x_write_byte(lp, lp->cfg->reg_brightness, (u8)brightness);
+ ret = lp855x_write_byte(lp, lp->cfg->reg_brightness,
+ (u8)brightness);
- return 0;
+ return ret;
}
static const struct backlight_ops lp855x_bl_ops = {
--
2.41.0
next prev parent reply other threads:[~2023-07-14 12:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-14 12:14 [PATCH 0/2] backlight: lp855x: Fixes after c1ff7da03e16 Artur Weber
2023-07-14 12:14 ` [PATCH 1/2] backlight: lp855x: Initialize PWM state on first brightness change Artur Weber
2023-07-17 8:38 ` Daniel Thompson
2023-07-14 12:14 ` Artur Weber [this message]
2023-07-17 8:39 ` [PATCH 2/2] backlight: lp855x: Catch errors when changing brightness Daniel Thompson
2023-07-28 9:22 ` [PATCH 0/2] backlight: lp855x: Fixes after c1ff7da03e16 Lee Jones
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=20230714121440.7717-3-aweber.kernel@gmail.com \
--to=aweber.kernel@gmail.com \
--cc=daniel.thompson@linaro.org \
--cc=deller@gmx.de \
--cc=dri-devel@lists.freedesktop.org \
--cc=jingoohan1@gmail.com \
--cc=lee@kernel.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pwm@vger.kernel.org \
--cc=thierry.reding@gmail.com \
--cc=u.kleine-koenig@pengutronix.de \
--cc=~postmarketos/upstreaming@lists.sr.ht \
/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).