Skip to contentSkip to conversation

mfd: adp5520: Ensure setting bits if new value is different from the old value

PATCH Applied Axel Lin 3 participants 3 messages Oct 31, 2011 – Nov 13, 2011

Subsystems (2)
lore
Share & tools
lore

Axel Lin

author
#0 lore raw

PATCH 1/1 mfd: adp5520: Ensure setting bits if new value is different from the old value

Current code checks if all the bit_mask bits are all zero is wrong. We need to write new value if the bit mask fields of new value is not equal to old value.

---
 drivers/mfd/adp5520.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mfd/adp5520.c +1 -1
index f1d8848..8d816cc 100644
@@ -109,7 +109,7 @@ int adp5520_set_bits(struct device *dev, int reg, uint8_t bit_mask)
 
 	ret = __adp5520_read(chip->client, reg, &reg_val);
 
-	if (!ret && ((reg_val & bit_mask) == 0)) {
+	if (!ret && ((reg_val & bit_mask) != bit_mask)) {
 		reg_val |= bit_mask;
 		ret = __adp5520_write(chip->client, reg, reg_val);
 	}
Signature · 1 line
1.7.5.4
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 5 lines · Axel Lin

Current code checks if all the bit_mask bits are all zero is wrong. We need to write new value if the bit mask fields of new value is not equal to old value.

Right - the da903x suffers the same problem.

Quoted 17 lines
---
  drivers/mfd/adp5520.c |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)
drivers/mfd/adp5520.c +1 -1
index f1d8848..8d816cc 100644
@@ -109,7 +109,7 @@ int adp5520_set_bits(struct device *dev, int reg, uint8_t bit_mask)
 
  	ret = __adp5520_read(chip->client, reg,&reg_val);
 
-	if (!ret&&  ((reg_val&  bit_mask) == 0)) {
+	if (!ret&&  ((reg_val&  bit_mask) != bit_mask)) {
  		reg_val |= bit_mask;
  		ret = __adp5520_write(chip->client, reg, reg_val);
  	}
Signature · 8 lines
Greetings,
Michael

--
Analog Devices GmbH      Wilhelm-Wagenfeld-Str. 6      80807 Muenchen
Sitz der Gesellschaft: Muenchen; Registergericht: Muenchen HRB 40368;
Geschaeftsfuehrer:Dr.Carsten Suckrow, Thomas Wessel, William A. Martin,
Margaret Seif
Applied
#2 lore raw
In reply to Axel Lin

Hi Axel,

Quoted 3 lines · Axel Lin

Current code checks if all the bit_mask bits are all zero is wrong. We need to write new value if the bit mask fields of new value is not equal to old value.

I applied all 3 patches, thanks.

Cheers,
Samuel.

Signature · 2 lines
Intel Open Source Technology Centre
http://oss.intel.com/