This is an automated email from the ASF dual-hosted git repository.

ccollins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git


The following commit(s) were added to refs/heads/master by this push:
     new 6ffb137  adding battery polling rate 0 to stop polling (#1545)
6ffb137 is described below

commit 6ffb137e5d87e616ccab65f7d6b03859bd101f15
Author: JustineKH <35044800+justin...@users.noreply.github.com>
AuthorDate: Mon Dec 3 13:20:02 2018 -0800

    adding battery polling rate 0 to stop polling (#1545)
    
    * adding polling rate 0 to stop polling
    
    * remove extra parentheses
    
    * set b_poll_rate to 0 if polling stopped
---
 hw/battery/src/battery.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/hw/battery/src/battery.c b/hw/battery/src/battery.c
index c8d4fc0..e3f2ac3 100644
--- a/hw/battery/src/battery.c
+++ b/hw/battery/src/battery.c
@@ -487,10 +487,16 @@ battery_set_poll_rate_ms(struct os_dev *battery, uint32_t 
poll_rate)
 {
     struct battery *bat = (struct battery *)battery;
 
-    if ((poll_rate == 0) || (bat == NULL)) {
+    if (bat == NULL) {
         return -1;
     }
 
+    if (poll_rate == 0) {
+        bat->b_poll_rate = 0;
+        os_callout_stop(&battery_manager.bm_poll_callout);
+        return 0;
+    }
+
     bat->b_poll_rate = poll_rate;
     bat->b_next_run = os_time_get();
     os_callout_reset(&battery_manager.bm_poll_callout, 0);

Reply via email to