- rel 2 auto/th/cpufreqd-2_4_2-2
authorJan Rękorajski <baggins@pld-linux.org>
Sun, 24 Apr 2011 08:16:45 +0000 (08:16 +0000)
committercvs2git <feedback@pld-linux.org>
Sun, 24 Jun 2012 12:13:13 +0000 (12:13 +0000)
- fix battery parameters detection problems
  http://bugs.gentoo.org/show_bug.cgi?id=346399

Changed files:
    cpufreqd-battery.patch -> 1.1
    cpufreqd.spec -> 1.42

cpufreqd-battery.patch [new file with mode: 0644]
cpufreqd.spec

diff --git a/cpufreqd-battery.patch b/cpufreqd-battery.patch
new file mode 100644 (file)
index 0000000..a2fa0f0
--- /dev/null
@@ -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;
index c6abc0e..de4cf03 100644 (file)
@@ -10,12 +10,13 @@ Summary:    Fully configurable daemon for dynamic frequency and voltage scaling
 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
@@ -48,6 +49,7 @@ jednocześnie dobrej szybkości procesora.
 
 %prep
 %setup -q
+%patch0 -p1
 
 %build
 %{__libtoolize}
This page took 0.249837 seconds and 4 git commands to generate.