Menu

#32 /sys/.../BAT0/current_now : no such file

open
acpi plugin (7)
5
2011-02-06
2011-02-04
niko2gare
No

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

Discussion

  • niko2gare

    niko2gare - 2011-02-04

    the cpufreqd version is 2.4.2

     
  • Mattia Dongili

    Mattia Dongili - 2011-02-06

    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.

     
  • Mattia Dongili

    Mattia Dongili - 2011-02-06
    • labels: --> acpi plugin
    • assigned_to: nobody --> mattia-san
     
  • niko2gare

    niko2gare - 2011-02-08

    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...

     
  • niko2gare

    niko2gare - 2011-02-08

    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;

     
  • niko2gare

    niko2gare - 2011-02-09

    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 */

     
  • niko2gare

    niko2gare - 2011-03-06

    it was allready done with name changing : http://bugs.gentoo.org/show_bug.cgi?id=346399

     

Log in to post a comment.

MongoDB Logo MongoDB