From: iw3gtf@arcor.de
To: barebox@lists.infradead.org
Subject: [PATCH 3/4] video/backlight-pwm: code readability improvement.
Date: Thu, 14 Jul 2016 16:17:17 +0200 [thread overview]
Message-ID: <20160714141718.20121-4-iw3gtf@arcor.de> (raw)
In-Reply-To: <20160714141718.20121-1-iw3gtf@arcor.de>
In-Reply-To: <20160713051805.GZ20657@pengutronix.de>
We use the local variable 'length' instead of the lengthy
'pwm_backlight->backlight.brightness_max' within pwm_backlight_parse_dt().
---
drivers/video/backlight-pwm.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/video/backlight-pwm.c b/drivers/video/backlight-pwm.c
index 53cf4e9..5ff40a9 100644
--- a/drivers/video/backlight-pwm.c
+++ b/drivers/video/backlight-pwm.c
@@ -133,12 +133,11 @@ static int pwm_backlight_parse_dt(struct device_d *dev,
if (!prop)
return -EINVAL;
- pwm_backlight->backlight.brightness_max = length / sizeof(u32);
+ length /= sizeof(u32);
/* read brightness levels from DT property */
- if (pwm_backlight->backlight.brightness_max > 0) {
- size_t size = sizeof(*pwm_backlight->levels) *
- pwm_backlight->backlight.brightness_max;
+ if (length > 0) {
+ size_t size = sizeof(*pwm_backlight->levels) * length;
pwm_backlight->levels = xzalloc(size);
if (!pwm_backlight->levels)
@@ -146,11 +145,11 @@ static int pwm_backlight_parse_dt(struct device_d *dev,
ret = of_property_read_u32_array(node, "brightness-levels",
pwm_backlight->levels,
- pwm_backlight->backlight.brightness_max);
+ length);
if (ret < 0)
return ret;
- for (i = 0; i < pwm_backlight->backlight.brightness_max; i++)
+ for (i = 0; i < length; i++)
if (pwm_backlight->levels[i] > pwm_backlight->scale)
pwm_backlight->scale = pwm_backlight->levels[i];
--
2.9.1
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
next prev parent reply other threads:[~2016-07-14 14:17 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-11 11:51 problem configuring backlight brightness levels in device tree giorgio.nicole
2016-07-13 5:18 ` Sascha Hauer
2016-07-14 14:17 ` [PATCH 0/4] fixes some problems found in the backligth-pwm implementation iw3gtf
2016-07-14 14:17 ` [PATCH 1/4] video/backlight-pwm: fixed a loop index going out of range iw3gtf
2016-07-14 14:17 ` [PATCH 2/4] video/backlight-pwm: fix the value of 'brightness_max' iw3gtf
2016-07-14 14:17 ` iw3gtf [this message]
2016-07-14 14:17 ` [PATCH 4/4] video/backlight-pwm: properly handle the case of an empty 'brightness-levels' in the device tree iw3gtf
2016-07-15 6:07 ` [PATCH 0/4] fixes some problems found in the backligth-pwm implementation Sascha Hauer
2016-07-25 8:37 ` Sascha Hauer
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=20160714141718.20121-4-iw3gtf@arcor.de \
--to=iw3gtf@arcor.de \
--cc=barebox@lists.infradead.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