Commit 36c3e759 authored by Axel Lin's avatar Axel Lin Committed by Linus Torvalds

drivers/video/backlight/adp88x0_bl.c: fix bit testing logic

We need to write new value if the bit mask fields of new value is not
equal to old value.  It does not make sense to write new value only when
all the bit_mask bits are zero.
Signed-off-by: default avatarAxel Lin <axel.lin@gmail.com>
Cc: Michael Hennerich <michael.hennerich@analog.com>
Cc: Richard Purdie <rpurdie@rpsys.net>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent d496aab5
...@@ -146,7 +146,7 @@ static int adp8860_set_bits(struct i2c_client *client, int reg, uint8_t bit_mask ...@@ -146,7 +146,7 @@ static int adp8860_set_bits(struct i2c_client *client, int reg, uint8_t bit_mask
ret = adp8860_read(client, reg, &reg_val); ret = adp8860_read(client, reg, &reg_val);
if (!ret && ((reg_val & bit_mask) == 0)) { if (!ret && ((reg_val & bit_mask) != bit_mask)) {
reg_val |= bit_mask; reg_val |= bit_mask;
ret = adp8860_write(client, reg, reg_val); ret = adp8860_write(client, reg, reg_val);
} }
......
...@@ -160,7 +160,7 @@ static int adp8870_set_bits(struct i2c_client *client, int reg, uint8_t bit_mask ...@@ -160,7 +160,7 @@ static int adp8870_set_bits(struct i2c_client *client, int reg, uint8_t bit_mask
ret = adp8870_read(client, reg, &reg_val); ret = adp8870_read(client, reg, &reg_val);
if (!ret && ((reg_val & bit_mask) == 0)) { if (!ret && ((reg_val & bit_mask) != bit_mask)) {
reg_val |= bit_mask; reg_val |= bit_mask;
ret = adp8870_write(client, reg, reg_val); ret = adp8870_write(client, reg, reg_val);
} }
......
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