Merge branch '2019-05-28-master-imports'
[oweals/u-boot.git] / arch / arm / mach-sunxi / pmic_bus.c
index f917c3e070a515e75551ab20372459a8f9d8806b..dea42de833f12bc48c2c48739c3fba8ac7d1224e 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * (C) Copyright 2015 Hans de Goede <hdegoede@redhat.com>
  *
@@ -5,8 +6,6 @@
  *
  * The axp152 & axp209 use an i2c bus, the axp221 uses the p2wi bus and the
  * axp223 uses the rsb bus, these functions abstract this.
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -102,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);
 }
@@ -115,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);
 }