summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAl 'netstar' Poole <netstar@gmail.com>2017-01-27 18:28:19 -0600
committerStephen 'Okra' Houston <smhouston88@gmail.com>2017-01-27 18:28:19 -0600
commit82af16c32b47e4d2d7f59443d0610257af7b923d (patch)
tree1c9b83907002211cb643dbfda66783fd91120529
parentd55164d0e06d2e8a1ad57a78940cb6504c818b05 (diff)
Enlightenment - BSD - Cleanup sysctl code for batteries.
-rw-r--r--src/modules/battery/e_mod_sysctl.c23
-rw-r--r--src/modules/sysinfo/batman/batman_sysctl.c10
2 files changed, 19 insertions, 14 deletions
diff --git a/src/modules/battery/e_mod_sysctl.c b/src/modules/battery/e_mod_sysctl.c
index b149207c8..96b921666 100644
--- a/src/modules/battery/e_mod_sysctl.c
+++ b/src/modules/battery/e_mod_sysctl.c
@@ -11,7 +11,7 @@
11#include "e.h" 11#include "e.h"
12#include "e_mod_main.h" 12#include "e_mod_main.h"
13 13
14static Eina_Bool _battery_sysctl_battery_update_poll(void *data); 14static Eina_Bool _battery_sysctl_battery_update_poll(void *data EINA_UNUSED);
15static int _battery_sysctl_battery_update(); 15static int _battery_sysctl_battery_update();
16 16
17extern Eina_List *device_batteries; 17extern Eina_List *device_batteries;
@@ -160,7 +160,7 @@ _battery_sysctl_stop(void)
160} 160}
161 161
162static Eina_Bool 162static Eina_Bool
163_battery_sysctl_battery_update_poll(void *data) 163_battery_sysctl_battery_update_poll(void *data EINA_UNUSED)
164{ 164{
165 _battery_sysctl_battery_update(); 165 _battery_sysctl_battery_update();
166 return EINA_TRUE; 166 return EINA_TRUE;
@@ -201,7 +201,7 @@ _battery_sysctl_battery_update()
201 } 201 }
202 202
203 /* This is a workaround because there's an ACPI bug */ 203 /* This is a workaround because there's an ACPI bug */
204 if (charge == 0 || bat->last_full_charge == 0) 204 if ((EINA_FLT_EQ(charge ==, 0.0)) || (EINA_FLT_EQ(bat->last_full_charge ==, 0.0)))
205 { 205 {
206 /* last full capacity */ 206 /* last full capacity */
207 bat->mib[3] = 8; 207 bat->mib[3] = 8;
@@ -219,9 +219,11 @@ _battery_sysctl_battery_update()
219 charge = (double)s.value; 219 charge = (double)s.value;
220 } 220 }
221 } 221 }
222
223 bat->got_prop = 1;
222 224
223 _time = ecore_time_get(); 225 _time = ecore_time_get();
224 if ((bat->got_prop) && (charge != bat->current_charge)) 226 if ((bat->got_prop) && (!EINA_FLT_EQ(charge, bat->current_charge)))
225 bat->charge_rate = ((charge - bat->current_charge) / (_time - bat->last_update)); 227 bat->charge_rate = ((charge - bat->current_charge) / (_time - bat->last_update));
226 bat->last_update = _time; 228 bat->last_update = _time;
227 bat->current_charge = charge; 229 bat->current_charge = charge;
@@ -328,12 +330,13 @@ _battery_sysctl_battery_update()
328#endif 330#endif
329 } 331 }
330 332
331 if (bat) 333 if (bat)
332 { 334 {
333 if (bat->got_prop) 335 if (bat->got_prop)
334 _battery_device_update(); 336 _battery_device_update();
335 bat->got_prop = 1; 337 bat->got_prop = 1;
336 } 338 }
339 return 1;
337} 340}
338 341
339 342
diff --git a/src/modules/sysinfo/batman/batman_sysctl.c b/src/modules/sysinfo/batman/batman_sysctl.c
index 7dd568894..f8e522738 100644
--- a/src/modules/sysinfo/batman/batman_sysctl.c
+++ b/src/modules/sysinfo/batman/batman_sysctl.c
@@ -10,7 +10,7 @@
10#include "batman.h" 10#include "batman.h"
11 11
12#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) 12#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
13static Eina_Bool _batman_sysctl_battery_update_poll(void *data); 13static Eina_Bool _batman_sysctl_battery_update_poll(void *data EINA_UNUSED);
14#endif 14#endif
15static int _batman_sysctl_battery_update(Instance *inst); 15static int _batman_sysctl_battery_update(Instance *inst);
16 16
@@ -163,7 +163,7 @@ _batman_sysctl_stop(void)
163 163
164#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__) 164#if defined(__OpenBSD__) || defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
165static Eina_Bool 165static Eina_Bool
166_batman_sysctl_battery_update_poll(void *data) 166_batman_sysctl_battery_update_poll(void *data EINA_UNUSED)
167{ 167{
168 Instance *inst = data; 168 Instance *inst = data;
169 _batman_sysctl_battery_update(inst); 169 _batman_sysctl_battery_update(inst);
@@ -207,7 +207,7 @@ _batman_sysctl_battery_update(Instance *inst)
207 } 207 }
208 208
209 /* This is a workaround because there's an ACPI bug */ 209 /* This is a workaround because there's an ACPI bug */
210 if (charge == 0 || bat->last_full_charge == 0) 210 if ((EINA_FLT_EQ(charge, 0.0)) || (EINA_FLT_EQ(bat->last_full_charge, 0.0)))
211 { 211 {
212 /* last full capacity */ 212 /* last full capacity */
213 bat->mib[3] = 8; 213 bat->mib[3] = 8;
@@ -225,6 +225,8 @@ _batman_sysctl_battery_update(Instance *inst)
225 charge = (double)s.value; 225 charge = (double)s.value;
226 } 226 }
227 } 227 }
228
229 bat->got_prop = 1;
228 230
229 _time = ecore_time_get(); 231 _time = ecore_time_get();
230 if ((bat->got_prop) && (charge != bat->current_charge)) 232 if ((bat->got_prop) && (charge != bat->current_charge))
@@ -340,7 +342,7 @@ _batman_sysctl_battery_update(Instance *inst)
340 _batman_device_update(bat->inst); 342 _batman_device_update(bat->inst);
341 bat->got_prop = 1; 343 bat->got_prop = 1;
342 } 344 }
343 return 0; 345 return 1;
344} 346}
345 347
346 348