Skip to contentSkip to conversation

backlight: aat2870: fix setting max_current

PATCH In review Axel Lin 2 participants 2 messages Jul 6, 2011

Subsystems (3)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 backlight: aat2870: fix setting max_current

1. current implementation tests wrong value for setting aat2870_bl->max_current.
2. In current implementation, we cannot differentiate below 2 cases:

       a) if pdata->max_current is not set , or
       b) pdata->max_current is set to AAT2870_CURRENT_0_45 ( which is also 0 ).

fix it by setting AAT2870_CURRENT_0_45 to be 1 and adjust the equation in aat2870_brightness() accordingly.

---
hi Jin,
I make enum aat2870_current starting from 1 instead of adding a AAT2870_CURRENT_0_00, because adding a AAT2870_CURRENT_0_00 may let people feel it is a valid setting for max_current.

BTW, I don't have this device handy. can you help to test it? Thanks,
Axel

 drivers/video/backlight/aat2870_bl.c |    4 ++--
 include/linux/mfd/aat2870.h          |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
drivers/video/backlight/aat2870_bl.c +2 -2
index 4952a61..c0e2ce7 100644
@@ -44,7 +44,7 @@ static inline int aat2870_brightness(struct aat2870_bl_driver_data *aat2870_bl,
 	struct backlight_device *bd = aat2870_bl->bd;
 	int val;
 
-	val = brightness * aat2870_bl->max_current;
+	val = brightness * (aat2870_bl->max_current - 1);
 	val /= bd->props.max_brightness;
 
 	return val;
@@ -175,7 +175,7 @@ static int aat2870_bl_probe(struct platform_device *pdev)
 	else
 		aat2870_bl->channels = AAT2870_BL_CH_ALL;
 
-	if (pdata->max_brightness > 0)
+	if (pdata->max_current > 0)
 		aat2870_bl->max_current = pdata->max_current;
 	else
 		aat2870_bl->max_current = AAT2870_CURRENT_27_9;
include/linux/mfd/aat2870.h +1 -1
index 89212df..f7316c2 100644
@@ -89,7 +89,7 @@ enum aat2870_id {
 
 /* Backlight current magnitude (mA) */
 enum aat2870_current {
-	AAT2870_CURRENT_0_45,
+	AAT2870_CURRENT_0_45 = 1,
 	AAT2870_CURRENT_0_90,
 	AAT2870_CURRENT_1_80,
 	AAT2870_CURRENT_2_70,
Signature · 1 line
1.7.4.1
Tested-by on v1 1/1
#1 lore raw

Hi, Axel

Quoted 2 lines

I make enum aat2870_current starting from 1 instead of adding a AAT2870_CURRENT_0_00, because adding a AAT2870_CURRENT_0_00 may let people feel it is a valid setting for max_current.

I got it. There is no problem.

Quoted 1 line

BTW, I don't have this device handy. can you help to test it?

Just now I have tested your change on real device and working fine as expected.

Thanks,
Jin.

2011-07-06 오후 5:41, Axel Lin 쓴 글:

Quoted 56 lines

1. current implementation tests wrong value for setting aat2870_bl->max_current.
2. In current implementation, we cannot differentiate below 2 cases:
a) if pdata->max_current is not set , or
b) pdata->max_current is set to AAT2870_CURRENT_0_45 ( which is also 0 ).
fix it by setting AAT2870_CURRENT_0_45 to be 1 and adjust the equation in aat2870_brightness() accordingly.

---
hi Jin,
I make enum aat2870_current starting from 1 instead of adding a AAT2870_CURRENT_0_00, because adding a AAT2870_CURRENT_0_00 may let people feel it is a valid setting for max_current.

BTW, I don't have this device handy. can you help to test it? Thanks,
Axel

  drivers/video/backlight/aat2870_bl.c |    4 ++--
  include/linux/mfd/aat2870.h          |    2 +-
  2 files changed, 3 insertions(+), 3 deletions(-)
drivers/video/backlight/aat2870_bl.c +2 -2
index 4952a61..c0e2ce7 100644
@@ -44,7 +44,7 @@ static inline int aat2870_brightness(struct aat2870_bl_driver_data *aat2870_bl,
  	struct backlight_device *bd = aat2870_bl->bd;
  	int val;
 
-	val = brightness * aat2870_bl->max_current;
+	val = brightness * (aat2870_bl->max_current - 1);
  	val /= bd->props.max_brightness;
 
  	return val;
@@ -175,7 +175,7 @@ static int aat2870_bl_probe(struct platform_device *pdev)
  	else
  		aat2870_bl->channels = AAT2870_BL_CH_ALL;
 
-	if (pdata->max_brightness>  0)
+	if (pdata->max_current>  0)
  		aat2870_bl->max_current = pdata->max_current;
  	else
  		aat2870_bl->max_current = AAT2870_CURRENT_27_9;
include/linux/mfd/aat2870.h +1 -1
index 89212df..f7316c2 100644
@@ -89,7 +89,7 @@ enum aat2870_id {
 
  /* Backlight current magnitude (mA) */
  enum aat2870_current {
-	AAT2870_CURRENT_0_45,
+	AAT2870_CURRENT_0_45 = 1,
  	AAT2870_CURRENT_0_90,
  	AAT2870_CURRENT_1_80,
  	AAT2870_CURRENT_2_70,