Browse Source

When we set or clear a pmic_bus bit, we do a read-modify-write
operation. We waste some time however, by writing back the exact same
value that was already set in the chip. Let us thus only configure the
chip if the data is different.

Merlijn Wajer 4 years ago
parent
commit
27cb72f314
1 changed files with 6 additions and 0 deletions
  1. 6 0
      arch/arm/mach-sunxi/pmic_bus.c

+ 6 - 0
arch/arm/mach-sunxi/pmic_bus.c

@@ -101,6 +101,9 @@ int pmic_bus_setbits(u8 reg, u8 bits)
101 101
 	if (ret)
102 102
 		return ret;
103 103
 
104
+	if (val & bits)
105
+		return 0;
106
+
104 107
 	val |= bits;
105 108
 	return pmic_bus_write(reg, val);
106 109
 }
@@ -114,6 +117,9 @@ int pmic_bus_clrbits(u8 reg, u8 bits)
114 117
 	if (ret)
115 118
 		return ret;
116 119
 
120
+	if (!(val & bits))
121
+		return 0;
122
+
117 123
 	val &= ~bits;
118 124
 	return pmic_bus_write(reg, val);
119 125
 }