rtc: pcf8563: fix write of invalid bits to ST2 reg
[firefly-linux-kernel-4.4.55.git] / drivers / rtc / rtc-pcf8563.c
index 1a865c9f11277eca91d6992262259f8495346928..8c23606ce2ccfaa89a1cfde85a3f5c7a7241fa53 100644 (file)
@@ -28,6 +28,7 @@
 #define PCF8563_REG_ST2                0x01
 #define PCF8563_BIT_AIE                (1 << 1)
 #define PCF8563_BIT_AF         (1 << 3)
+#define PCF8563_BITS_ST2_N     (7 << 5)
 
 #define PCF8563_REG_SC         0x02 /* datetime */
 #define PCF8563_REG_MN         0x03
@@ -130,7 +131,7 @@ static int pcf8563_set_alarm_mode(struct i2c_client *client, bool on)
        else
                buf &= ~PCF8563_BIT_AIE;
 
-       buf &= ~PCF8563_BIT_AF;
+       buf &= ~(PCF8563_BIT_AF | PCF8563_BITS_ST2_N);
 
        err = pcf8563_write_block_data(client, PCF8563_REG_ST2, 1, &buf);
        if (err < 0) {