summaryrefslogtreecommitdiffstats
path: root/arch/powerpc/platforms/powernv/opal-rtc.c
diff options
context:
space:
mode:
authorMichael Neuling <mikey@neuling.org>2014-08-19 14:48:00 +1000
committerMichael Ellerman <mpe@ellerman.id.au>2014-09-25 23:14:35 +1000
commit035ed26fb090ff3277900259f19d57e54da2e116 (patch)
tree9af68eea506a739905892a3050a4c89a3b289f46 /arch/powerpc/platforms/powernv/opal-rtc.c
parentbffe6bda342578deea0b74f2d9cb97cc40585a1b (diff)
downloadop-kernel-dev-035ed26fb090ff3277900259f19d57e54da2e116.zip
op-kernel-dev-035ed26fb090ff3277900259f19d57e54da2e116.tar.gz
powerpc/powernv: Check OPAL RTC calls exists before using
Check that the OPAL_RTC_READ token exists before we use the OPAL RTC. Refactors the code a little to merge error paths. This avoids littering the OPAL console with: "OPAL: Called with bad token 3". Signed-off-by: Michael Neuling <mikey@neuling.org> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/platforms/powernv/opal-rtc.c')
-rw-r--r--arch/powerpc/platforms/powernv/opal-rtc.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/arch/powerpc/platforms/powernv/opal-rtc.c b/arch/powerpc/platforms/powernv/opal-rtc.c
index b1885db..499707d 100644
--- a/arch/powerpc/platforms/powernv/opal-rtc.c
+++ b/arch/powerpc/platforms/powernv/opal-rtc.c
@@ -42,6 +42,9 @@ unsigned long __init opal_get_boot_time(void)
__be64 __h_m_s_ms;
long rc = OPAL_BUSY;
+ if (!opal_check_token(OPAL_RTC_READ))
+ goto out;
+
while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
rc = opal_rtc_read(&__y_m_d, &__h_m_s_ms);
if (rc == OPAL_BUSY_EVENT)
@@ -49,16 +52,18 @@ unsigned long __init opal_get_boot_time(void)
else
mdelay(10);
}
- if (rc != OPAL_SUCCESS) {
- ppc_md.get_rtc_time = NULL;
- ppc_md.set_rtc_time = NULL;
- return 0;
- }
+ if (rc != OPAL_SUCCESS)
+ goto out;
+
y_m_d = be32_to_cpu(__y_m_d);
h_m_s_ms = be64_to_cpu(__h_m_s_ms);
opal_to_tm(y_m_d, h_m_s_ms, &tm);
return mktime(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
tm.tm_hour, tm.tm_min, tm.tm_sec);
+out:
+ ppc_md.get_rtc_time = NULL;
+ ppc_md.set_rtc_time = NULL;
+ return 0;
}
void opal_get_rtc_time(struct rtc_time *tm)
OpenPOWER on IntegriCloud