From: Olliver Schinagl Date: Wed, 21 Nov 2018 18:05:26 +0000 (+0200) Subject: sunxi: pmic_bus: Decrease boot time by not writing duplicate data X-Git-Tag: v2019.01-rc2~23^2~8 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c970e8954f084b543d241fd96c0377988d8d4971;p=oweals%2Fu-boot.git sunxi: pmic_bus: Decrease boot time by not writing duplicate data 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 Signed-off-by: Priit Laes Acked-by: Maxime Ripard --- diff --git a/arch/arm/mach-sunxi/pmic_bus.c b/arch/arm/mach-sunxi/pmic_bus.c index 5d91d7e2c1..dea42de833 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); }