]> git.ipfire.org Git - ipfire-3.x.git/blame - powertop/patches/powertop-1.98-power-supply-add-power-now-support.patch
openssl: Fix some unreliable lines in the makefile.
[ipfire-3.x.git] / powertop / patches / powertop-1.98-power-supply-add-power-now-support.patch
CommitLineData
d07674cb
MT
1From 0dce3803eff9c3919c025ba5534bacdfda471182 Mon Sep 17 00:00:00 2001
2From: =?UTF-8?q?Jaroslav=20=C5=A0karvada?= <jskarvad@redhat.com>
3Date: Fri, 24 Feb 2012 13:55:44 +0100
4Subject: [PATCH] power_supply: Add support for POWER_NOW readings
5
6---
7 measurement/power_supply.cpp | 30 ++++++++++++++++++++++--------
8 1 files changed, 22 insertions(+), 8 deletions(-)
9
10diff --git a/measurement/power_supply.cpp b/measurement/power_supply.cpp
11index b4fe3af..13d8d34 100755
12--- a/measurement/power_supply.cpp
13+++ b/measurement/power_supply.cpp
14@@ -76,7 +76,8 @@ void power_supply::measure(void)
15 char line[4096];
16 ifstream file;
17
18- double _rate = 0;
19+ double _power_rate = 0;
20+ double _current_rate = 0;
21 double _capacity = 0;
22 double _voltage = 0;
23
24@@ -114,11 +115,21 @@ void power_supply::measure(void)
25 c = strchr(line, '=');
26 c++;
27 if(*c == '-') c++; // ignoring the negative sign
28- _rate = strtoull(c, NULL, 10);
29+ _current_rate = strtoull(c, NULL, 10);
30 if (c) {
31- //printf ("CURRENT: %f. \n",_rate);
32+ //printf ("CURRENT: %f. \n",_current_rate);
33 } else {
34- _rate = 0;
35+ _current_rate = 0;
36+ }
37+ }
38+ if (strstr(line, "POWER_NOW")) {
39+ c = strchr(line, '=');
40+ c++;
41+ _power_rate = strtoull(c, NULL, 10);
42+ if (c) {
43+ //printf ("POWER: %f. \n",_power_rate);
44+ } else {
45+ _power_rate = 0;
46 }
47 }
48 if (strstr(line, "CAPACITY=")) {
49@@ -152,10 +163,13 @@ void power_supply::measure(void)
50 voltage = 0.0;
51 }
52
53- if(_rate) {
54- _rate = _rate / 1000.0;
55- _rate = _rate * _voltage;
56- rate = _rate;
57+ if(_power_rate)
58+ {
59+ rate = _power_rate / 1000000.0;
60+ }
61+ else if(_current_rate) {
62+ _current_rate = _current_rate / 1000.0;
63+ rate = _current_rate * _voltage;
64 } else {
65 rate = 0.0;
66 }
67--
681.7.7.6
69