/sys/.../BAT0/current_now : no such file
Brought to you by:
mattia-san
hi,
on my laptop (T60 / IBM thinkpad) and a gentoo-sources kernel 2.6.37, it seems that the file current_now is replaced by power_now.
i made a test :
--- #define CURRENT_NOW "current_now"
+++ #define CURRENT_NOW "power_now"
and now works good.
i'm not competent to bring you an enhanced patch, sorry.
if you want more information, let me now.
by
the cpufreqd version is 2.4.2
thanks for submitting the issue, The fix should at least be backward compatible with earlier versions not having power_now.
Anyway this will be fixed in the next version of cpufreqd.
hi,
it seems current_now was removed since 2.6.36, so what do you think about this :
#include <linux/version.h>
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
#define CURRENT_NOW "power_now"
#else
#define CURRENT_NOW "current_now"
#endif
it keeps the CURRENT_NOW name but, in the other hand, it does not change many things...
in patch form :
--- cpufreqd_acpi_battery.c 2011-02-08 15:29:24.000000000 +0100
+++ cpufreqd_acpi_battery.c 2011-02-08 15:30:34.000000000 +0100
@@ -22,6 +22,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <linux/version.h>
#include "cpufreqd_plugin.h"
#include "cpufreqd_acpi.h"
#include "cpufreqd_acpi_event.h"
@@ -35,7 +36,11 @@
#define CHARGE_NOW "charge_now"
#define PRESENT "present"
#define STATUS "status"
-#define CURRENT_NOW "current_now"
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,36)
+#define CURRENT_NOW "power_now"
+#else
+#define CURRENT_NOW "current_now"
+#endif
struct battery_info {
int capacity;
No sorry. cpufreqd needs to be able to detect the file at runtime, not compile time. See how it was done for for current_now/energy_now here around line 135:
http://git.kamineko.org/cgi-bin/gitweb.cgi?p=cpufreqd.git;a=blob;f=src/cpufreqd_acpi_battery.c;h=e2da1722e6c1a50d8176d38d153bfab0764c9d54;hb=HEAD
you right, i only thought about my gentoo, sorry.
patch hopping current_now is the best way :
--- cpufreqd_acpi_battery.c.orig 2011-02-09 13:17:32.000000000 +0100
+++ cpufreqd_acpi_battery.c 2011-02-09 13:28:32.000000000 +0100
@@ -36,6 +36,7 @@
#define PRESENT "present"
#define STATUS "status"
#define CURRENT_NOW "current_now"
+#define POWER_NOW "power_now"
struct battery_info {
int capacity;
@@ -146,8 +147,12 @@
if (!binfo->status)
return -1;
binfo->current_now = get_class_device_attribute(binfo->cdev, CURRENT_NOW);
- if (!binfo->current_now)
- return -1;
+ if (!binfo->current_now) {
+ /* try the "power_now" name */
+ binfo->current_now = get_class_device_attribute(binfo->cdev, POWER_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 */
or patch knowing that power_now will be the future :
--- cpufreqd_acpi_battery.c.orig 2011-02-09 13:17:32.000000000 +0100
+++ cpufreqd_acpi_battery.c 2011-02-09 13:33:47.000000000 +0100
@@ -36,6 +36,7 @@
#define PRESENT "present"
#define STATUS "status"
#define CURRENT_NOW "current_now"
+#define POWER_NOW "power_now"
struct battery_info {
int capacity;
@@ -145,9 +146,13 @@
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;
+ binfo->current_now = get_class_device_attribute(binfo->cdev, POWER_NOW);
+ if (!binfo->current_now) {
+ /* try the "current_now" name */
+ 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 */
it was allready done with name changing : http://bugs.gentoo.org/show_bug.cgi?id=346399