Commit c7ce2500 authored by Michael Hennerich's avatar Michael Hennerich Committed by Linus Torvalds

drivers/video/backlight/adp8860_bl.c: fix ambient light zone overwrite handling

This affects the get/set of the current Ambient Light Zone.  Reading
should return an integer between 1..3 (1 = Daylight, 2 = office, 3 =
dark).  Writing a value between 1..3 forces the backlight controller to
enter the corresponding Ambient Light Zone.  Writing 0 returns to normal
operation.

Fix valid range checking so we don't write invalid values to the
controller, and make sure we subtract 1, since this is what the register
definition (CFGR:BLV) requires.  Otherwise the values written don't work
correctly.
Signed-off-by: default avatarMichael Hennerich <michael.hennerich@analog.com>
Signed-off-by: default avatarMike Frysinger <vapier@gentoo.org>
Acked-by: default avatarRichard Purdie <rpurdie@linux.intel.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent fef7764f
...@@ -614,7 +614,7 @@ static ssize_t adp8860_bl_ambient_light_zone_store(struct device *dev, ...@@ -614,7 +614,7 @@ static ssize_t adp8860_bl_ambient_light_zone_store(struct device *dev,
if (val == 0) { if (val == 0) {
/* Enable automatic ambient light sensing */ /* Enable automatic ambient light sensing */
adp8860_set_bits(data->client, ADP8860_MDCR, CMP_AUTOEN); adp8860_set_bits(data->client, ADP8860_MDCR, CMP_AUTOEN);
} else if ((val > 0) && (val < 6)) { } else if ((val > 0) && (val <= 3)) {
/* Disable automatic ambient light sensing */ /* Disable automatic ambient light sensing */
adp8860_clr_bits(data->client, ADP8860_MDCR, CMP_AUTOEN); adp8860_clr_bits(data->client, ADP8860_MDCR, CMP_AUTOEN);
...@@ -622,7 +622,7 @@ static ssize_t adp8860_bl_ambient_light_zone_store(struct device *dev, ...@@ -622,7 +622,7 @@ static ssize_t adp8860_bl_ambient_light_zone_store(struct device *dev,
mutex_lock(&data->lock); mutex_lock(&data->lock);
adp8860_read(data->client, ADP8860_CFGR, &reg_val); adp8860_read(data->client, ADP8860_CFGR, &reg_val);
reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT); reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT);
reg_val |= val << CFGR_BLV_SHIFT; reg_val |= (val - 1) << CFGR_BLV_SHIFT;
adp8860_write(data->client, ADP8860_CFGR, reg_val); adp8860_write(data->client, ADP8860_CFGR, reg_val);
mutex_unlock(&data->lock); mutex_unlock(&data->lock);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment