summaryrefslogtreecommitdiff
path: root/drivers/video/backlight/adp8860_bl.c
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2015-11-23 16:44:13 +0300
committerLee Jones <lee.jones@linaro.org>2016-01-11 08:56:12 +0300
commit86c68e2fb3eeb87ef716a0d61c5a346e9aee2ecb (patch)
treec356db3958377c49ef83c175c8eb697d49105da5 /drivers/video/backlight/adp8860_bl.c
parent1ec218373b8ebda821aec00bb156a9c94fad9cd4 (diff)
downloadlinux-86c68e2fb3eeb87ef716a0d61c5a346e9aee2ecb.tar.xz
backlight: adp88x0: Fix uninitialized variable use
gcc correctly warns about both the adp8860 and adp8870 backlight drivers using an uninitialized variable in their error handling path: drivers/video/backlight/adp8870_bl.c: In function 'adp8870_bl_ambient_light_zone_store': drivers/video/backlight/adp8870_bl.c:811:11: warning: 'reg_val' may be used uninitialized in this function This changes the code to only write back the data if it was correctly read to start with. As a side-note, the drivers are mostly identical, so I think they should really be merged into one file to avoid having to fix every bug twice. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Michael Hennerich <michael.hennerich@analog.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
Diffstat (limited to 'drivers/video/backlight/adp8860_bl.c')
-rw-r--r--drivers/video/backlight/adp8860_bl.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
index 98ffe71e8af2..f0d4c0324580 100644
--- a/drivers/video/backlight/adp8860_bl.c
+++ b/drivers/video/backlight/adp8860_bl.c
@@ -621,10 +621,12 @@ static ssize_t adp8860_bl_ambient_light_zone_store(struct device *dev,
/* Set user supplied ambient light zone */
mutex_lock(&data->lock);
- adp8860_read(data->client, ADP8860_CFGR, &reg_val);
- reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT);
- reg_val |= (val - 1) << CFGR_BLV_SHIFT;
- adp8860_write(data->client, ADP8860_CFGR, reg_val);
+ ret = adp8860_read(data->client, ADP8860_CFGR, &reg_val);
+ if (!ret) {
+ reg_val &= ~(CFGR_BLV_MASK << CFGR_BLV_SHIFT);
+ reg_val |= (val - 1) << CFGR_BLV_SHIFT;
+ adp8860_write(data->client, ADP8860_CFGR, reg_val);
+ }
mutex_unlock(&data->lock);
}