packages: cpufreqd/cpufreqd.spec, cpufreqd/cpufreqd-battery.patch (NEW) - r...

baggins baggins at pld-linux.org
Sun Apr 24 10:16:50 CEST 2011


Author: baggins                      Date: Sun Apr 24 08:16:50 2011 GMT
Module: packages                      Tag: HEAD
---- Log message:
- rel 2 
- fix battery parameters detection problems
  http://bugs.gentoo.org/show_bug.cgi?id=346399

---- Files affected:
packages/cpufreqd:
   cpufreqd.spec (1.41 -> 1.42) , cpufreqd-battery.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/cpufreqd/cpufreqd.spec
diff -u packages/cpufreqd/cpufreqd.spec:1.41 packages/cpufreqd/cpufreqd.spec:1.42
--- packages/cpufreqd/cpufreqd.spec:1.41	Fri Apr 15 12:54:20 2011
+++ packages/cpufreqd/cpufreqd.spec	Sun Apr 24 10:16:45 2011
@@ -11,12 +11,13 @@
 Summary(pl.UTF-8):	Skalowanie częstotliwości procesora
 Name:		cpufreqd
 Version:	2.4.2
-Release:	1
+Release:	2
 License:	GPL v2
 Group:		Applications/System
 Source0:	http://dl.sourceforge.net/cpufreqd/%{name}-%{version}.tar.bz2
 # Source0-md5:	2ca80a77849c9a69b81e27c1843c97f5
 Source1:	%{name}.init
+Patch0:		%{name}-battery.patch
 URL:		http://www.linux.it/~malattia/wiki/index.php/Cpufreqd
 BuildRequires:	autoconf
 BuildRequires:	automake
@@ -49,6 +50,7 @@
 
 %prep
 %setup -q
+%patch0 -p1
 
 %build
 %{__libtoolize}
@@ -115,6 +117,11 @@
 All persons listed below can be reached at <cvs_login>@pld-linux.org
 
 $Log$
+Revision 1.42  2011/04/24 08:16:45  baggins
+- rel 2
+- fix battery parameters detection problems
+  http://bugs.gentoo.org/show_bug.cgi?id=346399
+
 Revision 1.41  2011/04/15 10:54:20  marti
 - up to 2.4.2
 

================================================================
Index: packages/cpufreqd/cpufreqd-battery.patch
diff -u /dev/null packages/cpufreqd/cpufreqd-battery.patch:1.1
--- /dev/null	Sun Apr 24 10:16:50 2011
+++ packages/cpufreqd/cpufreqd-battery.patch	Sun Apr 24 10:16:45 2011
@@ -0,0 +1,176 @@
+--- cpufreqd-2.4.2/src/cpufreqd_acpi_battery.c	2010-03-28 04:34:54.000000000 -0700
++++ cpufreqd-2.4.2/src/cpufreqd_acpi_battery.c	2010-11-21 18:51:32.000000000 -0800
+@@ -29,12 +29,15 @@ 
+ 
+ #define POWER_SUPPLY	"power_supply"
+ #define BATTERY_TYPE	"Battery"
++#define PRESENT		"present"
++#define STATUS		"status"
++//energy batter properties
+ #define ENERGY_FULL	"energy_full"
+ #define ENERGY_NOW	"energy_now"
++#define POWER_NOW	"power_now"
++//charge battery properties
+ #define CHARGE_FULL	"charge_full"
+ #define CHARGE_NOW	"charge_now"
+-#define PRESENT		"present"
+-#define STATUS		"status"
+ #define CURRENT_NOW	"current_now"
+ 
+ struct battery_info {
+@@ -45,11 +48,11 @@ 
+ 	int is_present;
+ 
+ 	struct sysfs_class_device *cdev;
+-	struct sysfs_attribute *energy_full; /* last full capacity */
+-	struct sysfs_attribute *energy_now; /* remaining capacity */
++	struct sysfs_attribute *full_capacity; /* last full capacity */
++	struct sysfs_attribute *remaining_capacity; /* remaining capacity */
+ 	struct sysfs_attribute *present;
+ 	struct sysfs_attribute *status;
+-	struct sysfs_attribute *current_now; /* present rate */
++	struct sysfs_attribute *draw_rate; /* present rate */
+ 
+ 	int open;
+ };
+@@ -87,16 +90,16 @@ 
+ 
+ 	if (!binfo->open) return;
+ 
+-	if (binfo->energy_full)
+-		put_attribute(binfo->energy_full);
+-	if (binfo->energy_now)
+-		put_attribute(binfo->energy_now);
++	if (binfo->full_capacity)
++		put_attribute(binfo->full_capacity);
++	if (binfo->remaining_capacity)
++		put_attribute(binfo->remaining_capacity);
+ 	if (binfo->present)
+ 		put_attribute(binfo->present);
+ 	if (binfo->status)
+ 		put_attribute(binfo->status);
+-	if (binfo->current_now)
+-		put_attribute(binfo->current_now);
++	if (binfo->draw_rate)
++		put_attribute(binfo->draw_rate);
+ 
+ 	binfo->open = 0;
+ }
+@@ -104,11 +107,11 @@ 
+ static int read_battery(struct battery_info *binfo) {
+ 	clog(LOG_DEBUG, "%s - reading battery levels\n", binfo->cdev->name);
+ 
+-	if (read_int(binfo->current_now, &binfo->present_rate) != 0) {
++	if (read_int(binfo->draw_rate, &binfo->present_rate) != 0) {
+ 		clog(LOG_ERR, "Skipping %s\n", binfo->cdev->name);
+ 		return -1;
+ 	}
+-	if (read_int(binfo->energy_now, &binfo->remaining) != 0) {
++	if (read_int(binfo->remaining_capacity, &binfo->remaining) != 0) {
+ 		clog(LOG_ERR, "Skipping %s\n", binfo->cdev->name);
+ 		return -1;
+ 	}
+@@ -120,38 +123,88 @@ 
+ 			binfo->cdev->name, binfo->remaining);
+ 	return 0;
+ }
++
++/* open energy battery specific attributes */
++static int read_energy_battery_attributes(struct battery_info *binfo)
++{
++	binfo->full_capacity = get_class_device_attribute(binfo->cdev, ENERGY_FULL);
++	if(!binfo->full_capacity)
++	{
++		return -1;
++	}
++
++	binfo->remaining_capacity = get_class_device_attribute(binfo->cdev, ENERGY_NOW);
++	if(!binfo->remaining_capacity)
++	{
++		return -1;
++	}
++
++	binfo->draw_rate = get_class_device_attribute(binfo->cdev, POWER_NOW);
++	if(!binfo->draw_rate)
++	{
++		return -1;
++	}
++
++	return 0;
++}
++
++/* open charge battery specific attributes */
++static int read_charge_battery_attributes(struct battery_info *binfo)
++{
++	binfo->full_capacity = get_class_device_attribute(binfo->cdev, CHARGE_FULL);
++	if(!binfo->full_capacity)
++	{
++		return -1;
++	}
++
++	binfo->remaining_capacity = get_class_device_attribute(binfo->cdev, CHARGE_NOW);
++	if(!binfo->remaining_capacity)
++	{
++		return -1;
++	}
++
++	binfo->draw_rate = get_class_device_attribute(binfo->cdev, CURRENT_NOW);
++	if(!binfo->draw_rate)
++	{
++		return -1;
++	}
++
++	return 0;
++}
++
+ /* open all the required attributes and set the open status */
+ static int open_battery(struct battery_info *binfo) {
+ 	binfo->open = 1;
+ 
+-	binfo->energy_full = get_class_device_attribute(binfo->cdev, ENERGY_FULL);
+-	if (!binfo->energy_full) {
+-		/* try the "charge_full" name */
+-		binfo->energy_full = get_class_device_attribute(binfo->cdev,
+-				CHARGE_FULL);
+-		if (!binfo->energy_full)
++	//attempt to open energy attribute
++	struct sysfs_attribute *tmp_attribute = get_class_device_attribute(binfo->cdev, ENERGY_FULL);
++
++	if(!tmp_attribute)
++	{
++		if(read_charge_battery_attributes(binfo) != 0)
++		{
+ 			return -1;
++		}
+ 	}
+-	binfo->energy_now = get_class_device_attribute(binfo->cdev, ENERGY_NOW);
+-	if (!binfo->energy_now) {
+-		/* try the "charge_now" name */
+-		binfo->energy_now = get_class_device_attribute(binfo->cdev, CHARGE_NOW);
+-		if (!binfo->energy_now)
++	else
++	{
++		put_attribute(tmp_attribute);
++		if(read_energy_battery_attributes(binfo) != 0)
++		{
+ 			return -1;
++		}
+ 	}
++
+ 	binfo->present = get_class_device_attribute(binfo->cdev, PRESENT);
+ 	if (!binfo->present)
+ 		return -1;
+ 	binfo->status = get_class_device_attribute(binfo->cdev, STATUS);
+ 	if (!binfo->status)
+ 		return -1;
+-	binfo->current_now = get_class_device_attribute(binfo->cdev, CURRENT_NOW);
+-	if (!binfo->current_now)
+-		return -1;
+ 
+ 	/* read the last full capacity, this is not going to change
+ 	 * very often, so no need to poke it later */
+-	if (read_int(binfo->energy_full, &binfo->capacity) != 0) {
++	if (read_int(binfo->full_capacity, &binfo->capacity) != 0) {
+ 		clog(LOG_WARNING, "Couldn't read %s capacity (%s)\n",
+ 				binfo->cdev->name, strerror(errno));
+ 		return -1;
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/cpufreqd/cpufreqd.spec?r1=1.41&r2=1.42&f=u



More information about the pld-cvs-commit mailing list