sunxi: pmic_bus: Decrease boot time by not writing duplicate data
authorOlliver Schinagl <oliver@schinagl.nl>
Wed, 21 Nov 2018 18:05:26 +0000 (20:05 +0200)
committerJagan Teki <jagan@amarulasolutions.com>
Fri, 7 Dec 2018 16:54:33 +0000 (22:24 +0530)
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>
arch/arm/mach-sunxi/pmic_bus.c

index 5d91d7e2c126c661394848035f472f4ee279985b..dea42de833f12bc48c2c48739c3fba8ac7d1224e 100644 (file)
@@ -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);
 }