You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by pk...@apache.org on 2022/08/02 15:50:52 UTC
[incubator-nuttx] branch master updated (013a562478 -> 306431d16f)
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
from 013a562478 Net thread-safe ntoa functions
new 992747cef3 drivers/battery: Handle the early changed event correctly
new 306431d16f list: Remove the unnecessary ? : operator
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
drivers/power/battery_charger.c | 10 ++++++++++
drivers/power/battery_gauge.c | 10 ++++++++++
drivers/power/battery_monitor.c | 10 ++++++++++
include/nuttx/list.h | 7 ++++++-
4 files changed, 36 insertions(+), 1 deletion(-)
[incubator-nuttx] 02/02: list: Remove the unnecessary ? : operator
Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 306431d16f489f9956826f3d0599d9354e28b51a
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri Jul 29 10:55:37 2022 +0800
list: Remove the unnecessary ? : operator
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
include/nuttx/list.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/include/nuttx/list.h b/include/nuttx/list.h
index bbeb16e541..8081da31db 100644
--- a/include/nuttx/list.h
+++ b/include/nuttx/list.h
@@ -387,12 +387,12 @@ list_next_wrap(FAR struct list_node *list, FAR struct list_node *item)
static inline bool list_is_empty(FAR struct list_node *list)
{
- return (list->next == list) ? true : false;
+ return list->next == list;
}
static inline bool list_is_clear(FAR struct list_node *list)
{
- return (list->next == NULL) ? true : false;
+ return list->next == NULL;
}
static inline size_t list_length(FAR struct list_node *list)
[incubator-nuttx] 01/02: drivers/battery: Handle the early changed event correctly
Posted by pk...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pkarashchenko pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 992747cef386e829a5addff8e1e3074a6dddf934
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Fri Jul 29 02:03:50 2022 +0800
drivers/battery: Handle the early changed event correctly
since it may happen before battery_xxx_register sometime
Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
---
drivers/power/battery_charger.c | 10 ++++++++++
drivers/power/battery_gauge.c | 10 ++++++++++
drivers/power/battery_monitor.c | 10 ++++++++++
include/nuttx/list.h | 5 +++++
4 files changed, 35 insertions(+)
diff --git a/drivers/power/battery_charger.c b/drivers/power/battery_charger.c
index f72b79513b..5fce337571 100644
--- a/drivers/power/battery_charger.c
+++ b/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;
+ }
+
ret = nxsem_wait_uninterruptible(&dev->batsem);
if (ret < 0)
{
diff --git a/drivers/power/battery_gauge.c b/drivers/power/battery_gauge.c
index 2a8c38955a..0e36aab74f 100644
--- a/drivers/power/battery_gauge.c
+++ b/drivers/power/battery_gauge.c
@@ -435,6 +435,16 @@ int battery_gauge_changed(FAR struct battery_gauge_dev_s *dev,
FAR struct battery_gauge_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;
+ }
+
ret = nxsem_wait_uninterruptible(&dev->batsem);
if (ret < 0)
{
diff --git a/drivers/power/battery_monitor.c b/drivers/power/battery_monitor.c
index 49ea4a34a2..8090fc9a83 100644
--- a/drivers/power/battery_monitor.c
+++ b/drivers/power/battery_monitor.c
@@ -510,6 +510,16 @@ int battery_monitor_changed(FAR struct battery_monitor_dev_s *dev,
FAR struct battery_monitor_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;
+ }
+
ret = nxsem_wait_uninterruptible(&dev->batsem);
if (ret < 0)
{
diff --git a/include/nuttx/list.h b/include/nuttx/list.h
index 4361e7ee16..bbeb16e541 100644
--- a/include/nuttx/list.h
+++ b/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;
+}
+
static inline size_t list_length(FAR struct list_node *list)
{
FAR struct list_node *node = list;