The patch is better than nothing, though I don't trust the values it reports when on battery. This is what I see when discharging:
Power usage (ACPI estimate): 2.4W (23.0 hours)
Obviously, I'm not really that lucky.
[EMAIL PROTECTED]:~/tmp/powertop-1.10>acpi
Battery 0: Discharging, 87%, 00:04:51 remaining
That's closer to right.
[EMAIL PROTECTED]:/home/joey/tmp/powertop-1.10>cat
/sys/class/power_supply/CMB1/charge_now
6790000
[EMAIL PROTECTED]:/home/joey/tmp/powertop-1.10>cat
/sys/class/power_supply/CMB1/voltage_now
8038000
[EMAIL PROTECTED]:/home/joey/tmp/powertop-1.10>cat
/sys/class/power_supply/CMB1/current_now
1249000
[EMAIL PROTECTED]:/home/joey/tmp/powertop-1.10>cat
/sys/class/power_supply/CMB1/charge_full
7800000
--
see shy jo
diff -u powertop-1.10/debian/changelog powertop-1.10/debian/changelog
--- powertop-1.10/debian/changelog
+++ powertop-1.10/debian/changelog
@@ -1,3 +1,12 @@
+powertop (1.10-1.1) unstable; urgency=low
+
+ * NMU
+ * Support batteries that do not report energy_now, by reading change_now.
+ Closes: #486873, #495638, #495348
+ (Patch by Michal Hocko.)
+
+ -- Joey Hess <[EMAIL PROTECTED]> Mon, 01 Sep 2008 14:01:46 -0400
+
powertop (1.10-1) unstable; urgency=low
* New upstream version (Closes: #486510)
only in patch2:
unchanged:
--- powertop-1.10.orig/powertop.c
+++ powertop-1.10/powertop.c
@@ -627,11 +627,19 @@
sprintf(filename, "/sys/class/power_supply/%s/energy_now", dirent->d_name);
file = fopen(filename, "r");
- if (!file)
- continue;
+ watts_left = 1;
+ if (!file) {
+ sprintf(filename, "/sys/class/power_supply/%s/charge_now", dirent->d_name);
+ file = fopen(filename, "r");
+ if (!file)
+ continue;
+
+ /* W = A * V */
+ watts_left = voltage;
+ }
memset(line, 0, 1024);
if (fgets(line, 1024, file) != NULL) {
- watts_left = strtoull(line, NULL, 10) / 1000000.0;
+ watts_left *= strtoull(line, NULL, 10) / 1000000.0;
}
fclose(file);
signature.asc
Description: Digital signature

