From: Axel Lin <axel.lin@gmail.com>
To: linux-kernel@vger.kernel.org
Cc: Richard Purdie <rpurdie@rpsys.net>,
"Milo(Woogyom) Kim" <milo.kim@ti.com>,
Andrew Morton <akpm@linux-foundation.org>
Subject: [PATCH] drivers/video/backlight/lp855x_bl.c: fix setting initial value for max_brightness and brightness
Date: Sun, 19 Feb 2012 15:08:22 +0800 [thread overview]
Message-ID: <1329635302.4818.1.camel@phoenix> (raw)
Current code does not always ensure
pdata->initial_brightness <= pdata->max_brightness <= MAX_BRIGHTNESS.
Fix it.
Signed-off-by: Axel Lin <axel.lin@gmail.com>
---
drivers/video/backlight/lp855x_bl.c | 11 ++++++++---
1 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c
index d32c097..29a3af2 100644
--- a/drivers/video/backlight/lp855x_bl.c
+++ b/drivers/video/backlight/lp855x_bl.c
@@ -24,6 +24,7 @@
#define BUF_SIZE (20)
#define DEFAULT_BL_NAME "lcd-backlight"
+#define MAX_BRIGHTNESS 255
struct lp855x {
const char *chipid;
@@ -171,10 +172,14 @@ static int lp855x_backlight_register(struct lp855x *lp)
char *name = pdata->name ? : DEFAULT_BL_NAME;
props.type = BACKLIGHT_PLATFORM;
+
+ if (pdata->max_brightness > MAX_BRIGHTNESS)
+ pdata->max_brightness = MAX_BRIGHTNESS;
+ props.max_brightness = pdata->max_brightness;
+
+ if (pdata->initial_brightness > pdata->max_brightness)
+ pdata->initial_brightness = pdata->max_brightness;
props.brightness = pdata->initial_brightness;
- props.max_brightness =
- (pdata->max_brightness < pdata->initial_brightness) ?
- 255 : pdata->max_brightness;
bl = backlight_device_register(name, lp->dev, lp,
&lp855x_bl_ops, &props);
--
1.7.5.4
next reply other threads:[~2012-02-19 7:08 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-19 7:08 Axel Lin [this message]
2012-02-20 8:21 ` [PATCH] drivers/video/backlight/lp855x_bl.c: fix setting initial value for max_brightness and brightness Kim, Milo
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=1329635302.4818.1.camel@phoenix \
--to=axel.lin@gmail.com \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=milo.kim@ti.com \
--cc=rpurdie@rpsys.net \
/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