Here is a minor patch to make the setting of intensity a little more understandable (to me) :)

Sean

diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c
index 950d100..49a0e9b 100644
--- a/drivers/i2c/chips/pcf50633.c
+++ b/drivers/i2c/chips/pcf50633.c
@@ -1880,6 +1880,11 @@ static int pcf50633bl_get_intensity(struct backlight_device *bd)
 	struct pcf50633_data *pcf = bl_get_data(bd);
 	int intensity = reg_read(pcf, PCF50633_REG_LEDOUT) << 2;
 
+    /* If the LED unit is turned off, then the intensity is 0
+     */
+	if (!(reg_read(pcf, PCF50633_REG_LEDENA) & 1))
+		intensity = 0;
+
 	return intensity & 0xff;
 }
 
@@ -1887,35 +1892,28 @@ static int pcf50633bl_set_intensity(struct backlight_device *bd)
 {
 	struct pcf50633_data *pcf = bl_get_data(bd);
 	int intensity = bd->props.brightness >> 2;
-	int old_intensity = reg_read(pcf, PCF50633_REG_LEDOUT);
-	u_int8_t ledena = 2;
+	u_int8_t old_ledena = reg_read(pcf, PCF50633_REG_LEDENA);
+	u_int8_t ledena = old_ledena;
 	int ret;
 
-	if (!(reg_read(pcf, PCF50633_REG_LEDENA) & 1))
-		old_intensity = 0;
-
+	/* illegal to set LEDOUT to 0 */
 	if ((bd->props.power != FB_BLANK_UNBLANK) ||
-	    (bd->props.fb_blank != FB_BLANK_UNBLANK))
-		intensity = 0;
+	    (bd->props.fb_blank != FB_BLANK_UNBLANK) ||
+	    (!intensity)) {
 
-	/* The PCF50633 cannot handle LEDOUT = 0 (datasheet p60)
-	 * if seen, you have to re-enable the LED unit
-	 */
+		ledena &= ~1;
 
-	if (intensity != 0 && old_intensity == 0) {
-		ledena = reg_read(pcf, PCF50633_REG_LEDENA);
-		reg_write(pcf, PCF50633_REG_LEDENA, 0x00);
-	}
+	} else {
 
-	if (!intensity) /* illegal to set LEDOUT to 0 */
-		ret = reg_set_bit_mask(pcf, PCF50633_REG_LEDOUT, 0x3f, 2);
-	else
-		ret = reg_set_bit_mask(pcf, PCF50633_REG_LEDOUT, 0x3f,
-			       intensity);
+		ledena |= 1;
+	}
 
-	if (intensity != 0 && old_intensity == 0)
+	if (ledena != old_ledena)
 		reg_write(pcf, PCF50633_REG_LEDENA, ledena);
 
+	ret = reg_set_bit_mask(pcf, PCF50633_REG_LEDOUT, 0x3f,
+				intensity ? intensity : 2);
+
 	return ret;
 }
 

Reply via email to