drivers/video/backlight/lp855x_bl.c: fix setting initial value for max_brightness and brightness
Subsystems (2)
PATCH 1/1 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.
--- drivers/video/backlight/lp855x_bl.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-)
drivers/video/backlight/lp855x_bl.c +8 -3
@@ -24,6 +24,7 @@#define BUF_SIZE (20)#define DEFAULT_BL_NAME "lcd-backlight" +#define MAX_BRIGHTNESS 255struct 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);
Signature · 1 line
1.7.5.4
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 -
Quoted 48 lines
-----Original Message-----
From: Axel Lin [mailto:[email protected]]
Sent: Sunday, February 19, 2012 4:08 PM
To: [email protected]
Cc: Richard Purdie; Kim, Milo; Andrew Morton
Subject: [PATCH]drivers/video/backlight/lp855x_bl.c: fix setting initial value formax_brightnessand brightnessCurrent code does not always ensure
pdata->initial_brightness<=pdata->max_brightness<=MAX_BRIGHTNESS. Fix it.Signed-off-by Axel Lin <[email protected]>--- drivers/video/backlight/lp855x_bl.c | 11 ++++++++--- 1 files changed, 8 insertions(+), 3 deletions(-)drivers/video/backlight/lp855x_bl.c +8
-3@@ -24,6 +24,7 @@#define BUF_SIZE (20)#define DEFAULT_BL_NAME "lcd-backlight" +#define MAX_BRIGHTNESS 255struct 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,
Quoted 5 lines
&lp855x_bl_ops, &props);
--
1.7.5.4
���{.n�+�������+%�����ݶ��w��{.n�+����{��G�����{ay�ʇڙ�,j��f���h��������z_�(�階�ݢj"���m������G������?����&���~��iO��z��v�^�m����������?�I�