Skip to content

Commit

Permalink
powerpc/powernv: Check OPAL RTC calls exists before using
Browse files Browse the repository at this point in the history
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 <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
  • Loading branch information
mikey authored and mpe committed Sep 25, 2014
1 parent bffe6bd commit 035ed26
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions arch/powerpc/platforms/powernv/opal-rtc.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,23 +42,28 @@ 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)
opal_poll_events(NULL);
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)
Expand Down

0 comments on commit 035ed26

Please sign in to comment.