You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/07/30 06:07:23 UTC

[GitHub] [incubator-nuttx] pkarashchenko commented on a diff in pull request #6743: drivers/battery: Handle the early changed event correctly

pkarashchenko commented on code in PR #6743:
URL: https://github.com/apache/incubator-nuttx/pull/6743#discussion_r933758869


##########
include/nuttx/list.h:
##########
@@ -390,6 +390,11 @@ static inline bool list_is_empty(FAR struct list_node *list)
   return (list->next == list) ? true : false;
 }
 
+static inline bool list_is_clear(FAR struct list_node *list)
+{
+  return (list->next == NULL) ? true : false;

Review Comment:
   ```suggestion
     return (list->next == NULL);
   ```



##########
drivers/power/battery_charger.c:
##########
@@ -467,6 +467,16 @@ int battery_charger_changed(FAR struct battery_charger_dev_s *dev,
   FAR struct battery_charger_priv_s *priv;
   int ret;
 
+  /* Event happen too early? */
+
+  if (list_is_clear(&dev->flist))
+    {
+      /* Yes, record it and return directly */
+
+      dev->mask |= mask;
+      return 0;
+    }

Review Comment:
   How correct is to call this before taking `dev->batsem`?



-- 
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-unsubscribe@nuttx.apache.org

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