xiaoxiang781216 commented on code in PR #22492:
URL: https://github.com/apache/nuttx/pull/22492#discussion_r4719925579


##########
sched/sched/sched_processtick.c:
##########
@@ -186,11 +189,7 @@ void nxsched_process_timer(void)
 
   /* Process watchdogs */
 
-#ifdef CONFIG_HRTIMER
-  hrtimer_process(clock_systime_nsec());
-#else
-  wd_timer(clock_systime_ticks());
-#endif
+  hrtimer_process(TICK2NSEC((uint64_t)now));

Review Comment:
   remove the cast



##########
sched/wdog/wdog.h:
##########
@@ -101,36 +94,25 @@ extern clock_t  g_wdexpired;
  *
  ****************************************************************************/
 
-#ifndef CONFIG_HRTIMER
-void wd_timer(clock_t ticks);
-#else
 uint64_t wd_timer(const hrtimer_t *timer, uint64_t expired);
-#endif
 
 /****************************************************************************
  * Inline functions
  ****************************************************************************/
 
-#if defined(CONFIG_SCHED_TICKLESS) || defined(CONFIG_HRTIMER)
-#  define wd_in_callback()          (g_wdtimernested)
-#  define wd_set_nested(f)          (g_wdtimernested = (f))
-#  define wd_update_expire(expired) (g_wdexpired = (expired))
-#else
-#  define wd_in_callback() (false)
-#  define wd_set_nested(f)
-#  define wd_update_expire(expired)
-#endif
+#define wd_in_callback()          (g_wdtimernested)
+#define wd_set_nested(f)          (g_wdtimernested = (f))
+#define wd_update_expire(expired) (g_wdexpired = (expired))
 
-#ifdef CONFIG_HRTIMER
 static inline_function void wd_timer_start(clock_t tick, bool in_expiration)
 {
   if (!in_expiration)
     {
-      clock_t interval = clock_compare(g_wdexpired, tick) ?
-                         tick - g_wdexpired : 0;
-      uint64_t nsec    = interval <= HRTIMER_MAX_DELAY / NSEC_PER_TICK ?
-                         TICK2NSEC(g_wdexpired + interval) :
-                         TICK2NSEC(g_wdexpired) + HRTIMER_MAX_DELAY;
+      uint64_t delay = clock_compare(g_wdexpired, tick) ?

Review Comment:
   keep clock_t



##########
sched/wdog/wd_start.c:
##########
@@ -380,23 +366,14 @@ int wd_start_abstick(FAR struct wdog_s *wdog, clock_t 
ticks,
  *
  ****************************************************************************/
 
-#ifndef CONFIG_HRTIMER
-void wd_timer(clock_t ticks)
-{
-  /* Check if there are any active watchdogs to process */
-
-  wd_expiration(ticks);
-}
-#else
 uint64_t wd_timer(const hrtimer_t *timer, uint64_t expired)
 {
   /* Check if there are any active watchdogs to process */
 
-  clock_t  tick = div_const(expired, NSEC_PER_TICK);
-  clock_t delay = wd_expiration(tick) - tick;
-  uint64_t nsec = delay <= HRTIMER_MAX_DELAY / NSEC_PER_TICK ?
-                  TICK2NSEC(delay) : HRTIMER_MAX_DELAY;
+  clock_t  tick  = div_const(expired, NSEC_PER_TICK);
+  uint64_t delay = wd_expiration(tick) - tick;

Review Comment:
   keep clock_t



##########
include/nuttx/wdog.h:
##########
@@ -181,16 +191,11 @@ static inline_function
 int wd_start(FAR struct wdog_s *wdog, clock_t delay,
              wdentry_t wdentry, wdparm_t arg)
 {
-  int ret = -EINVAL;
-
   /* Ensure delay is within the range the wdog can handle. */
 
-  if (delay >= 0 && delay <= WDOG_MAX_DELAY)
-    {
-      ret = wd_start_abstick(wdog, clock_delay2abstick(delay), wdentry, arg);
-    }
-
-  return ret;
+  return (uint64_t)delay <= WDOG_MAX_DELAY ?

Review Comment:
   remove the cast



##########
sched/wqueue/kwork_queue.c:
##########
@@ -133,8 +133,9 @@ static int work_qqueue(FAR struct kwork_wqueue_s *wqueue,
           /* Start the timer if the work is the earliest expired work. */
 
           retimer = false;
-          wd_start_abstick(&wqueue->timer, work->qtime,
-                           work_timer_expired, (wdparm_t)wqueue);
+          hrtimer_start(&wqueue->timer, work_timer_expired,
+                        TICK2NSEC((uint64_t)work->qtime),

Review Comment:
   remove the cast



##########
sched/wqueue/kwork_thread.c:
##########
@@ -160,8 +161,9 @@ static inline_function bool work_dispatch(FAR struct 
kwork_wqueue_s *wqueue,
 
           if (!clock_compare(work->qtime, ticks))
             {
-              wd_start_abstick(&wqueue->timer, work->qtime,
-                               work_timer_expired, (wdparm_t)wqueue);
+              hrtimer_start(&wqueue->timer, work_timer_expired,
+                            TICK2NSEC((uint64_t)work->qtime),

Review Comment:
   remove too



##########
sched/wdog/wd_start.c:
##########
@@ -286,59 +281,46 @@ bool wd_insert(FAR struct wdog_s *wdog, clock_t expired,
  *   indicate the nature of any failure.
  *
  * Assumptions:
+ *   The wdog and wdentry is not NULL.
  *   The watchdog routine runs in the context of the timer interrupt handler
  *   and is subject to all ISR restrictions.
  *
  ****************************************************************************/
 
-int wd_start_abstick(FAR struct wdog_s *wdog, clock_t ticks,
-                     wdentry_t wdentry, wdparm_t arg)
+int wd_start_abstick_internal(FAR struct wdog_s *wdog,
+                                           clock_t ticks, wdentry_t wdentry,

Review Comment:
   align



##########
sched/wqueue/wqueue.h:
##########
@@ -306,13 +307,12 @@ void work_timer_reset(FAR struct kwork_wqueue_s *wqueue)
       FAR struct work_s *work;
 
       work = list_first_entry(&wqueue->pending, struct work_s, node);
-
-      wd_start_abstick(&wqueue->timer, work->qtime,
-                       work_timer_expired, (wdparm_t)wqueue);
+      hrtimer_start(&wqueue->timer, work_timer_expired,
+                    TICK2NSEC((uint64_t)work->qtime), HRTIMER_MODE_ABS);

Review Comment:
   remove the cast too



##########
sched/wqueue/kwork_queue.c:
##########
@@ -77,7 +77,7 @@ static int work_qqueue(FAR struct kwork_wqueue_s *wqueue,
   bool retimer;
 
   if (wqueue == NULL || work == NULL || worker == NULL ||
-      delay < 0 || delay > WDOG_MAX_DELAY)
+      (uint64_t)delay > WQUEUE_MAX_DELAY)

Review Comment:
   remove the cast



##########
include/nuttx/wdog.h:
##########
@@ -328,12 +333,9 @@ int wd_start_next(FAR struct wdog_s *wdog, clock_t delay,
 {
   /* Ensure delay is within the range the wdog can handle. */
 
-  if (delay <= 0 || delay > WDOG_MAX_DELAY)
-    {
-      return -EINVAL;
-    }
-
-  return wd_start_abstick(wdog, wdog->expired + delay, wdentry, arg);
+  return (uint64_t)delay > 0 && (uint64_t)delay <= WDOG_MAX_DELAY ?

Review Comment:
   remove the cast too



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to