anchao commented on code in PR #6488:
URL: https://github.com/apache/incubator-nuttx/pull/6488#discussion_r901612037


##########
drivers/wireless/ieee80211/bcm43xxx/bcmf_netdev.c:
##########
@@ -755,6 +768,74 @@ static int bcmf_ifdown(FAR struct net_driver_s *dev)
   return OK;
 }
 
+/****************************************************************************
+ * Name: bcmf_lowpower_work
+ *
+ * Description:
+ *   Process low power saving dueto work timer expiration
+ *
+ * Input Parameters:
+ *   arg - context of device to use
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_IEEE80211_BROADCOM_LOWPOWER
+static void bcmf_lowpower_work(FAR void *arg)
+{
+  FAR struct bcmf_dev_s *priv = (FAR struct bcmf_dev_s *)arg;
+  clock_t cticks = clock_systime_ticks();
+
+  if (!priv->bc_bifup)
+    {
+      return;
+    }
+
+  if (TICK2SEC(cticks - priv->lp_time) >=
+      CONFIG_IEEE80211_BROADCOM_LOWPOWER_TIMEOUT)
+    {
+      bcmf_wl_set_pm(priv, PM_MAX);
+      priv->lp_pending = false;
+    }
+  else
+    {
+      cticks = SEC2TICK(CONFIG_IEEE80211_BROADCOM_LOWPOWER_TIMEOUT) -
+               (cticks - priv->lp_time);
+      work_queue(LPWORK, &priv->lp_work, bcmf_lowpower_work, priv, cticks);
+    }
+}
+
+/****************************************************************************
+ * Name: bcmf_lowpower_poll
+ *
+ * Description:
+ *   Polling low power
+ *
+ * Input Parameters:
+ *   arg - context of device to use
+ *
+ ****************************************************************************/
+
+static void bcmf_lowpower_poll(FAR struct bcmf_dev_s *priv)
+{
+  if (priv->bc_bifup)
+    {
+      priv->lp_time = clock_systime_ticks();
+      if (priv->lp_mode != PM_FAST)
+        {
+          bcmf_wl_set_pm(priv, PM_FAST);
+        }
+
+      if (work_available(&priv->lp_work) && !priv->lp_pending)

Review Comment:
   lp_pending is needed, which avoid race conditions if work is requeued in the 
work handler



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