From patchwork Tue May 19 22:01:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 246032 List-Id: U-Boot discussion From: rasmus.villemoes at prevas.dk (Rasmus Villemoes) Date: Wed, 20 May 2020 00:01:15 +0200 Subject: [PATCH v2 08/10] rtc: i2c_rtc_emul: catch any write to the "reset" register In-Reply-To: <20200519220117.24448-1-rasmus.villemoes@prevas.dk> References: <20200504212032.3759-1-rasmus.villemoes@prevas.dk> <20200519220117.24448-1-rasmus.villemoes@prevas.dk> Message-ID: <20200519220117.24448-9-rasmus.villemoes@prevas.dk> 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. Signed-off-by: Rasmus Villemoes Reviewed-by: Simon Glass --- drivers/rtc/i2c_rtc_emul.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/rtc/i2c_rtc_emul.c b/drivers/rtc/i2c_rtc_emul.c index d4b33e59d6..3a7f1fe53e 100644 --- a/drivers/rtc/i2c_rtc_emul.c +++ b/drivers/rtc/i2c_rtc_emul.c @@ -196,7 +196,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); } }