rpmsg_rtc: to simply the SYNC cmd logic
Signed-off-by: ligd <liguiding1@xiaomi.com>
This commit is contained in:
parent
cb502a869c
commit
a9e3a5c233
@ -26,11 +26,11 @@
|
||||
|
||||
#include <nuttx/list.h>
|
||||
#include <nuttx/clock.h>
|
||||
#include <nuttx/wqueue.h>
|
||||
#include <nuttx/kmalloc.h>
|
||||
#include <nuttx/rptun/openamp.h>
|
||||
#include <nuttx/semaphore.h>
|
||||
#include <nuttx/timers/rpmsg_rtc.h>
|
||||
#include <nuttx/timers/arch_rtc.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user