[U-Boot] [PATCH 2/8] sunxi: pmic_bus: Decrease boot time by not writing duplicate data

Olliver Schinagl oliver at schinagl.nl
Wed Mar 1 12:52:18 UTC 2017


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.

Signed-off-by: Olliver Schinagl <oliver at schinagl.nl>
---
 arch/arm/mach-sunxi/pmic_bus.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/arch/arm/mach-sunxi/pmic_bus.c b/arch/arm/mach-sunxi/pmic_bus.c
index 7c57f02792..dc3d328c1b 100644
--- a/arch/arm/mach-sunxi/pmic_bus.c
+++ b/arch/arm/mach-sunxi/pmic_bus.c
@@ -95,6 +95,9 @@ int pmic_bus_setbits(u8 reg, u8 bits)
 	if (ret)
 		return ret;
 
+	if (val & bits)
+		return 0;
+
 	val |= bits;
 	return pmic_bus_write(reg, val);
 }
@@ -108,6 +111,9 @@ int pmic_bus_clrbits(u8 reg, u8 bits)
 	if (ret)
 		return ret;
 
+	if (!(val & bits))
+		return 0;
+
 	val &= ~bits;
 	return pmic_bus_write(reg, val);
 }
-- 
2.11.0



More information about the U-Boot mailing list