|
@@ -58,6 +58,7 @@ static void tm_to_opal(struct rtc_time *tm, u32 *y_m_d, u64 *h_m_s_ms)
|
|
|
static int opal_get_rtc_time(struct device *dev, struct rtc_time *tm)
|
|
|
{
|
|
|
long rc = OPAL_BUSY;
|
|
|
+ int retries = 10;
|
|
|
u32 y_m_d;
|
|
|
u64 h_m_s_ms;
|
|
|
__be32 __y_m_d;
|
|
@@ -67,8 +68,11 @@ static int opal_get_rtc_time(struct device *dev, struct rtc_time *tm)
|
|
|
rc = opal_rtc_read(&__y_m_d, &__h_m_s_ms);
|
|
|
if (rc == OPAL_BUSY_EVENT)
|
|
|
opal_poll_events(NULL);
|
|
|
- else
|
|
|
+ else if (retries-- && (rc == OPAL_HARDWARE
|
|
|
+ || rc == OPAL_INTERNAL_ERROR))
|
|
|
msleep(10);
|
|
|
+ else if (rc != OPAL_BUSY && rc != OPAL_BUSY_EVENT)
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
if (rc != OPAL_SUCCESS)
|
|
@@ -84,6 +88,7 @@ static int opal_get_rtc_time(struct device *dev, struct rtc_time *tm)
|
|
|
static int opal_set_rtc_time(struct device *dev, struct rtc_time *tm)
|
|
|
{
|
|
|
long rc = OPAL_BUSY;
|
|
|
+ int retries = 10;
|
|
|
u32 y_m_d = 0;
|
|
|
u64 h_m_s_ms = 0;
|
|
|
|
|
@@ -92,8 +97,11 @@ static int opal_set_rtc_time(struct device *dev, struct rtc_time *tm)
|
|
|
rc = opal_rtc_write(y_m_d, h_m_s_ms);
|
|
|
if (rc == OPAL_BUSY_EVENT)
|
|
|
opal_poll_events(NULL);
|
|
|
- else
|
|
|
+ else if (retries-- && (rc == OPAL_HARDWARE
|
|
|
+ || rc == OPAL_INTERNAL_ERROR))
|
|
|
msleep(10);
|
|
|
+ else if (rc != OPAL_BUSY && rc != OPAL_BUSY_EVENT)
|
|
|
+ break;
|
|
|
}
|
|
|
|
|
|
return rc == OPAL_SUCCESS ? 0 : -EIO;
|