mirror of
https://github.com/torvalds/linux.git
synced 2024-11-25 05:32:00 +00:00
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 <linkmauve@linkmauve.fr> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220823130702.1046-1-linkmauve@linkmauve.fr
This commit is contained in:
parent
1e2585b49d
commit
509451ac03
@ -265,18 +265,17 @@ static int gamecube_rtc_read_offset_from_sram(struct priv *d)
|
||||
* SRAM address as on previous consoles.
|
||||
*/
|
||||
ret = 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;
|
||||
}
|
||||
|
||||
/* Reset SRAM access to how it was before, our job here is done. */
|
||||
if (old != 0x7bf)
|
||||
iowrite32be(old, hw_srnprot);
|
||||
|
||||
iounmap(hw_srnprot);
|
||||
|
||||
return 0;
|
||||
if (ret)
|
||||
pr_err("failed to get the RTC bias\n");
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const struct regmap_range rtc_rd_ranges[] = {
|
||||
|
Loading…
Reference in New Issue
Block a user