GUIDINGLI commented on a change in pull request #5847:
URL: https://github.com/apache/incubator-nuttx/pull/5847#discussion_r837630346



##########
File path: drivers/rptun/rptun.c
##########
@@ -238,56 +259,145 @@ static void rptun_unlock(void)
     }
 }
 
+#ifdef CONFIG_RPTUN_PM
+static inline void rptun_pm_action(FAR struct rptun_priv_s *priv,
+                                   bool stay)
+{
+  irqstate_t flags;
+
+  flags = enter_critical_section();
+
+  if (stay && !priv->stay)
+    {
+      pm_stay(0, PM_IDLE);
+      priv->stay = true;
+    }
+
+  if (!stay && priv->stay && !rptun_buffer_nused(&priv->rvdev, false))
+    {
+      pm_relax(0, PM_IDLE);
+      priv->stay = false;
+    }
+
+  leave_critical_section(flags);
+}
+
+#else
+#  define rptun_pm_action(priv, stay)
+#endif
+
+static void rptun_worker(FAR void *arg)
+{
+  FAR struct rptun_priv_s *priv = arg;
+
+  switch (priv->cmd)
+    {
+      case RPTUNIOC_START:
+        if (priv->rproc.state == RPROC_OFFLINE)
+          {
+            rptun_dev_start(&priv->rproc);
+          }
+        break;
+
+      case RPTUNIOC_STOP:
+        if (priv->rproc.state != RPROC_OFFLINE)
+          {
+            rptun_dev_stop(&priv->rproc);
+          }
+        break;
+    }
+
+  priv->cmd = RPTUNIOC_NONE;
+  remoteproc_get_notification(&priv->rproc, RPTUN_NOTIFY_ALL);
+
+  rptun_pm_action(priv, false);
+}
+
+static void rptun_post(FAR struct rptun_priv_s *priv)
+{
+  int semcount;
+
+  nxsem_get_value(&priv->sem, &semcount);
+  while (semcount++ < 1)
+    {
+      nxsem_post(&priv->sem);
+    }

Review comment:
       NO, we can't do that, imagine we have more then one HPWORK




-- 
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