Skip to content

Commit 509451a

Browse files
linkmauvealexandrebelloni
authored andcommitted
rtc: gamecube: Always reset HW_SRNPROT after read
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 <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 1e2585b commit 509451a

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/rtc/rtc-gamecube.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -265,18 +265,17 @@ static int gamecube_rtc_read_offset_from_sram(struct priv *d)
265265
* SRAM address as on previous consoles.
266266
*/
267267
ret = regmap_read(d->regmap, RTC_SRAM_BIAS, &d->rtc_bias);
268-
if (ret) {
269-
pr_err("failed to get the RTC bias\n");
270-
iounmap(hw_srnprot);
271-
return -1;
272-
}
273268

274269
/* Reset SRAM access to how it was before, our job here is done. */
275270
if (old != 0x7bf)
276271
iowrite32be(old, hw_srnprot);
272+
277273
iounmap(hw_srnprot);
278274

279-
return 0;
275+
if (ret)
276+
pr_err("failed to get the RTC bias\n");
277+
278+
return ret;
280279
}
281280

282281
static const struct regmap_range rtc_rd_ranges[] = {

0 commit comments

Comments
 (0)