* [PATCH] drivers/video/backlight/lp855x_bl.c: fix setting initial value for max_brightness and brightness
@ 2012-02-19 7:08 Axel Lin
2012-02-20 8:21 ` Kim, Milo
0 siblings, 1 reply; 2+ messages in thread
From: Axel Lin @ 2012-02-19 7:08 UTC (permalink / raw)
To: linux-kernel; +Cc: Richard Purdie, Milo(Woogyom) Kim, Andrew Morton
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* RE: [PATCH] drivers/video/backlight/lp855x_bl.c: fix setting initial value for max_brightness and brightness
2012-02-19 7:08 [PATCH] drivers/video/backlight/lp855x_bl.c: fix setting initial value for max_brightness and brightness Axel Lin
@ 2012-02-20 8:21 ` Kim, Milo
0 siblings, 0 replies; 2+ messages in thread
From: Kim, Milo @ 2012-02-20 8:21 UTC (permalink / raw)
To: Axel Lin; +Cc: Richard Purdie, Andrew Morton, linux-kernel
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=utf-8, Size: 2202 bytes --]
Thanks for this patch.
But it would be better if max_brightness of platform data is removed.
Actually, there is no need to use max_brightness in the platform data.
All LP855x devices have 8-bit brightness control register.
Simply, value of max_brightness can be set to 255.
I'll send the patch for this.
Thanks & BR
Milo -
> -----Original Message-----
> From: Axel Lin [mailto:axel.lin@gmail.com]
> Sent: Sunday, February 19, 2012 4:08 PM
> To: linux-kernel@vger.kernel.org
> Cc: Richard Purdie; Kim, Milo; Andrew Morton
> Subject: [PATCH] drivers/video/backlight/lp855x_bl.c: fix setting
> initial value for max_brightness and brightness
>
> 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
>
>
ÿôèº{.nÇ+·®+%Ëÿ±éݶ\x17¥wÿº{.nÇ+·¥{±þG«éÿ{ayº\x1dÊÚë,j\a¢f£¢·hïêÿêçz_è®\x03(éÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?¨èÚ&£ø§~á¶iOæ¬z·vØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?I¥
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2012-02-20 8:21 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-19 7:08 [PATCH] drivers/video/backlight/lp855x_bl.c: fix setting initial value for max_brightness and brightness Axel Lin
2012-02-20 8:21 ` Kim, Milo
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).