jlaitine commented on code in PR #15929:
URL: https://github.com/apache/nuttx/pull/15929#discussion_r1990105098


##########
arch/risc-v/src/common/riscv_mtimer.c:
##########
@@ -290,6 +377,59 @@ static int riscv_mtimer_cancel(struct oneshot_lowerhalf_s 
*lower,
   return 0;
 }
 
+/****************************************************************************
+ * Name: riscv_mtimer_tick_cancel
+ *
+ * Description:
+ *   Cancel the oneshot timer and return the time remaining on the timer.
+ *
+ *   NOTE: This function may execute at a high rate with no timer running (as
+ *   when pre-emption is enabled and disabled).
+ *
+ * Input Parameters:
+ *   lower   Caller allocated instance of the oneshot state structure.  This
+ *           structure must have been previously initialized via a call to
+ *           oneshot_initialize();
+ *   ticks   The location in which to return the time remaining on the
+ *           oneshot timer.  A time of zero is returned if the timer is
+ *           not running.
+ *
+ * Returned Value:
+ *   Zero (OK) is returned on success.  A call to up_timer_cancel() when
+ *   the timer is not active should also return success; a negated errno
+ *   value is returned on any failure.
+ *
+ ****************************************************************************/
+
+static int riscv_mtimer_tick_cancel(struct oneshot_lowerhalf_s *lower,
+                                    clock_t *ticks)
+{
+  struct riscv_mtimer_lowerhalf_s *priv =
+    (struct riscv_mtimer_lowerhalf_s *)lower;
+  uint64_t mtime;
+  uint64_t alarm;
+  irqstate_t flags;
+
+  flags = up_irq_save();
+
+  alarm = priv->alarm;
+
+  mtime = riscv_mtimer_get_mtime(priv);
+
+  riscv_mtimer_set_mtimecmp(priv, mtime + UINT64_MAX);

Review Comment:
   That's right! The original implementation was broken for cancel, and I just 
copied that also to the _tick_cancel. Thanks for pointing that out, now fixed 
both the existing function and the new one - in case someone would call the 
cancel some day :)
   
   
   



-- 
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: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to