diff mbox series

[U-Boot,v3,2/9] sunxi: pmic_bus: Decrease boot time by not writing duplicate data

Message ID da1ecb3c56e25b06532565fe0457c2934936bdcb.1542823428.git-series.plaes@plaes.org
State Accepted
Commit c970e8954f084b543d241fd96c0377988d8d4971
Delegated to: Jagannadha Sutradharudu Teki
Headers show
Series Stop AXP from crashing when enabling LDO3 | expand

Commit Message

Priit Laes Nov. 21, 2018, 6:05 p.m. UTC
From: Olliver Schinagl <oliver@schinagl.nl>

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

Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
Signed-off-by: Priit Laes <plaes@plaes.org>

--
Changes since v2:
- Fix code for pmic_bus_setbits
---
 arch/arm/mach-sunxi/pmic_bus.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Maxime Ripard Nov. 22, 2018, 8:21 a.m. UTC | #1
On Wed, Nov 21, 2018 at 08:05:26PM +0200, Priit Laes wrote:
> From: Olliver Schinagl <oliver@schinagl.nl>
> 
> When we clear a pmic_bus bit, we do a read-modify-write operation.
> We waste some time however, by writing back the exact samea value
> that was already set in the chip. Let us thus only do the write
> in case data was changed.
> 
> Signed-off-by: Olliver Schinagl <oliver@schinagl.nl>
> Signed-off-by: Priit Laes <plaes@plaes.org>

Acked-by: Maxime Ripard <maxime.ripard@bootlin.com>

Maxime
diff mbox series

Patch

diff --git a/arch/arm/mach-sunxi/pmic_bus.c b/arch/arm/mach-sunxi/pmic_bus.c
index 5d91d7e..dea42de 100644
--- a/arch/arm/mach-sunxi/pmic_bus.c
+++ b/arch/arm/mach-sunxi/pmic_bus.c
@@ -101,6 +101,9 @@  int pmic_bus_setbits(u8 reg, u8 bits)
 	if (ret)
 		return ret;
 
+	if ((val & bits) == bits)
+		return 0;
+
 	val |= bits;
 	return pmic_bus_write(reg, val);
 }
@@ -114,6 +117,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);
 }