Re: Why is /sys/class/power_supply/CMB1/energy_now not exported?

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Michal Hocko
Date: Thursday, September 4, 2008 - 12:40 pm

On Mon, Jul 21, 2008 at 09:04:13PM -0600, Michal Hocko wrote:
[...]

I had some time to get back to this issue and the problem why I have
seen different behavior on distribution and vanilla kernel was in
configuration. 
While distribution kernel doesn't use CONFIG_ACPI_PROCFS_POWER=y while
my vanilla kernel configuration does! This means that the patched code
wasn't triggered in my vanilla kernel testing.

So that I have checked the print_batter_sysfs again and it seems that
the problem is on another place:
powertop.c:648
	sprintf(filename, "/sys/class/power_supply/%s/current_now", dirent->d_name);
	file = fopen(filename, "r");
	if (!file)
		continue;
	memset(line, 0, 1024);
	if (fgets(line, 1024, file) != NULL) {
		watts_drawn = strtoull(line, NULL, 10) / 1000000.0;
	}
	fclose(file);

	if (!dontcount) {
		rate += watts_drawn + voltage * amperes_drawn;
	}

current rate (later used for the remaining time calculation:
display.c:201
	sprintf(buffer, _("Power usage (ACPI estimate): %3.1fW (%3.1f hours)"), rate, cap/rate);
)

is calculated as watts_drawn + voltage which is not correct, because
current_* values are in A and not in W (according to
linux-src/Documentation/power/power_supply_class.txt).

Updated patch is attached. This one is already working for me.

-- 
Michal Hocko
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: Why is /sys/class/power_supply/CMB1/energy_now not exp ..., Alexey Starikovskiy, (Mon Jul 21, 10:49 pm)
Re: Why is /sys/class/power_supply/CMB1/energy_now not exp ..., Michal Hocko, (Thu Sep 4, 12:40 pm)