From nobody Wed Apr 8 04:28:49 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B963C32796 for ; Tue, 23 Aug 2022 16:56:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244760AbiHWQ4W (ORCPT ); Tue, 23 Aug 2022 12:56:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343503AbiHWQz2 (ORCPT ); Tue, 23 Aug 2022 12:55:28 -0400 X-Greylist: delayed 602 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Tue, 23 Aug 2022 06:25:47 PDT Received: from luna.linkmauve.fr (82-65-109-163.subs.proxad.net [82.65.109.163]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3E7CD883CA; Tue, 23 Aug 2022 06:25:46 -0700 (PDT) Received: by luna.linkmauve.fr (Postfix, from userid 1000) id DBE46F41DDA; Tue, 23 Aug 2022 15:07:05 +0200 (CEST) From: Emmanuel Gil Peyrot To: Alexandre Belloni , Alessandro Zummo , linux-rtc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Emmanuel Gil Peyrot , Ash Logan , rw-r-r-0644 , =?UTF-8?q?Jonathan=20Neusch=C3=A4fer?= Subject: [PATCH] rtc: gamecube: Always reset HW_SRNPROT after read Date: Tue, 23 Aug 2022 15:07:02 +0200 Message-Id: <20220823130702.1046-1-linkmauve@linkmauve.fr> X-Mailer: git-send-email 2.37.2 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" This register would fail to be reset if reading the RTC bias failed for whichever reason. This commit reorganises the code around to unconditionally write it back to its previous value, unmap it, and return the result of regmap_read(), which makes it both simpler and more correct in the error case. Signed-off-by: Emmanuel Gil Peyrot --- drivers/rtc/rtc-gamecube.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/rtc/rtc-gamecube.c b/drivers/rtc/rtc-gamecube.c index c2717bb52b2b..c828bc8e05b9 100644 --- a/drivers/rtc/rtc-gamecube.c +++ b/drivers/rtc/rtc-gamecube.c @@ -265,18 +265,17 @@ static int gamecube_rtc_read_offset_from_sram(struct = priv *d) * SRAM address as on previous consoles. */ ret =3D regmap_read(d->regmap, RTC_SRAM_BIAS, &d->rtc_bias); - if (ret) { - pr_err("failed to get the RTC bias\n"); - iounmap(hw_srnprot); - return -1; - } =20 /* Reset SRAM access to how it was before, our job here is done. */ if (old !=3D 0x7bf) iowrite32be(old, hw_srnprot); + iounmap(hw_srnprot); =20 - return 0; + if (ret) + pr_err("failed to get the RTC bias\n"); + + return ret; } =20 static const struct regmap_range rtc_rd_ranges[] =3D { --=20 2.37.2