All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] backlight: Fix the logic to set bits in adp8860_bl and adp8870_bl drivers
@ 2012-01-13  8:15 Axel Lin
  2012-01-13 22:10 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Axel Lin @ 2012-01-13  8:15 UTC (permalink / raw)
  To: linux-kernel
  Cc: Michael Hennerich, Richard Purdie, device-drivers-devel, Andrew Morton

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: Axel Lin <axel.lin@gmail.com>
---
 drivers/video/backlight/adp8860_bl.c |    2 +-
 drivers/video/backlight/adp8870_bl.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c
index 66bc74d..378276c 100644
--- a/drivers/video/backlight/adp8860_bl.c
+++ b/drivers/video/backlight/adp8860_bl.c
@@ -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);
 
-	if (!ret && ((reg_val & bit_mask) == 0)) {
+	if (!ret && ((reg_val & bit_mask) != bit_mask)) {
 		reg_val |= bit_mask;
 		ret = adp8860_write(client, reg, reg_val);
 	}
diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c
index 6c68a68..6735059 100644
--- a/drivers/video/backlight/adp8870_bl.c
+++ b/drivers/video/backlight/adp8870_bl.c
@@ -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);
 
-	if (!ret && ((reg_val & bit_mask) == 0)) {
+	if (!ret && ((reg_val & bit_mask) != bit_mask)) {
 		reg_val |= bit_mask;
 		ret = adp8870_write(client, reg, reg_val);
 	}
-- 
1.7.5.4




^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2012-01-16  8:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-13  8:15 [PATCH] backlight: Fix the logic to set bits in adp8860_bl and adp8870_bl drivers Axel Lin
2012-01-13 22:10 ` Andrew Morton
2012-01-14  9:22   ` Axel Lin
2012-01-16  8:33     ` Hennerich, Michael

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.