]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
rtc: i2c_rtc_emul: catch any write to the "reset" register
authorRasmus Villemoes <rasmus.villemoes@prevas.dk>
Mon, 6 Jul 2020 20:01:17 +0000 (22:01 +0200)
committerHeiko Schocher <hs@denx.de>
Thu, 9 Jul 2020 04:02:45 +0000 (06:02 +0200)
It's more natural that any write that happens to touch the reset
register should cause a reset, rather than just a write that starts at
that offset.

Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Heiko Schocher <hs@denx.de>
Signed-off-by: Rasmus Villemoes <rasmus.villemoes@prevas.dk>
drivers/rtc/i2c_rtc_emul.c

index a010af411bbd5f1023aede023cd52d78495d7425..7f78ff83cb07760fa6ceb773f75a9e02729a8159 100644 (file)
@@ -197,7 +197,8 @@ static int sandbox_i2c_rtc_xfer(struct udevice *emul, struct i2c_msg *msg,
 
                        /* Write the register */
                        memcpy(plat->reg + offset, ptr, len);
-                       if (offset == REG_RESET)
+                       /* If the reset register was written to, do reset. */
+                       if (offset <= REG_RESET && REG_RESET < offset + len)
                                reset_time(emul);
                }
        }