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.
lime2-spi
Merlijn Wajer 7 years ago
parent 3ae192c2a4
commit 27cb72f314
  1. 6
      arch/arm/mach-sunxi/pmic_bus.c

@ -101,6 +101,9 @@ int pmic_bus_setbits(u8 reg, u8 bits)
if (ret) if (ret)
return ret; return ret;
if (val & bits)
return 0;
val |= bits; val |= bits;
return pmic_bus_write(reg, val); return pmic_bus_write(reg, val);
} }
@ -114,6 +117,9 @@ int pmic_bus_clrbits(u8 reg, u8 bits)
if (ret) if (ret)
return ret; return ret;
if (!(val & bits))
return 0;
val &= ~bits; val &= ~bits;
return pmic_bus_write(reg, val); return pmic_bus_write(reg, val);
} }

Loading…
Cancel
Save