diff --git a/drivers/timers/rpmsg_rtc.c b/drivers/timers/rpmsg_rtc.c index c0164f81d2..b27c3b664b 100644 --- a/drivers/timers/rpmsg_rtc.c +++ b/drivers/timers/rpmsg_rtc.c @@ -26,11 +26,11 @@ #include #include -#include #include #include #include #include +#include #include #include @@ -108,7 +108,6 @@ struct rpmsg_rtc_lowerhalf_s */ struct rpmsg_endpoint ept; - struct work_s syncwork; #ifdef CONFIG_RTC_ALARM struct lower_setalarm_s alarminfo[CONFIG_RTC_NALARMS]; @@ -284,18 +283,6 @@ static void rpmsg_rtc_alarm_fire_handler(FAR struct rpmsg_endpoint *ept, #endif } -static void rpmsg_rtc_syncworker(FAR void *arg) -{ - clock_synchronize(); -} - -static void rpmsg_rtc_sync_handler(FAR void *priv) -{ - FAR struct rpmsg_rtc_lowerhalf_s *lower = priv; - - work_queue(HPWORK, &lower->syncwork, rpmsg_rtc_syncworker, NULL, 0); -} - static int rpmsg_rtc_ept_cb(FAR struct rpmsg_endpoint *ept, FAR void *data, size_t len, uint32_t src, FAR void *priv) { @@ -310,7 +297,15 @@ static int rpmsg_rtc_ept_cb(FAR struct rpmsg_endpoint *ept, FAR void *data, break; case RPMSG_RTC_SYNC: - rpmsg_rtc_sync_handler(priv); + { + struct rpmsg_rtc_set_s *msg = data; + struct timespec tp; + + tp.tv_sec = msg->sec; + tp.tv_nsec = msg->nsec; + + clock_synchronize(&tp); + } break; default: @@ -472,18 +467,20 @@ static int rpmsg_rtc_server_settime(FAR struct rtc_lowerhalf_s *lower, (FAR struct rpmsg_rtc_server_s *)lower; FAR struct rpmsg_rtc_client_s *client; FAR struct list_node *node; - struct rpmsg_rtc_header_s header; + struct rpmsg_rtc_set_s msg; int ret; ret = server->lower->ops->settime(server->lower, rtctime); if (ret >= 0) { nxsem_wait_uninterruptible(&server->exclsem); - header.command = RPMSG_RTC_SYNC; + msg.sec = timegm((FAR struct tm *)rtctime); + msg.nsec = rtctime->tm_nsec; + msg.header.command = RPMSG_RTC_SYNC; list_for_every(&server->list, node) { client = (FAR struct rpmsg_rtc_client_s *)node; - rpmsg_send(&client->ept, &header, sizeof(header)); + rpmsg_send(&client->ept, &msg, sizeof(msg)); } nxsem_post(&server->exclsem);