public inbox for linux-acpi@vger.kernel.org
 help / color / mirror / Atom feed
* /proc/acpi/battery/BAT0/info stale when battery changed on Thinkpad X60t
@ 2008-05-14 15:05 Andy Neitzke
  2008-05-14 17:10 ` Alexey Starikovskiy
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Neitzke @ 2008-05-14 15:05 UTC (permalink / raw)
  To: linux-acpi

Hi,

I have two batteries for my Thinkpad X60 Tablet, one 6-cell and one 9-cell, 
with very different capacities.  If I boot up or resume from suspend with say 
battery A connected, then /proc/acpi/battery/BAT0/info correctly shows 
information about battery A.  If I then connect the system to AC power and 
remove battery A, /proc/acpi/battery/BAT0/info correctly shows that no 
battery is present.  If I then attach battery B, 
then /proc/acpi/battery/BAT0/info incorrectly shows the information about 
battery A again!  (And similarly e.g. kpowersave shows the wrong capacity.)  
On the other hand /proc/acpi/battery/BAT0/state always shows the correct 
information.  A suspend-resume cycle clears up the problem.

For example:

andy@chirality ~ $ cat /proc/acpi/battery/BAT0/state
present:                 yes
capacity state:          ok
charging state:          charged
present rate:            0 mW
remaining capacity:      61650 mWh
present voltage:         16587 mV

andy@chirality ~ $ cat /proc/acpi/battery/BAT0/info
present:                 yes
design capacity:         28800 mWh
last full capacity:      23550 mWh
battery technology:      rechargeable
design voltage:          14400 mV
design capacity warning: 1177 mWh
design capacity low:     200 mWh
capacity granularity 1:  1 mWh
capacity granularity 2:  1 mWh
model number:            93P5031
serial number:             482
battery type:            LION
OEM info:                SANYO

and then after suspend-resume, the correct information:

andy@chirality ~ $ cat /proc/acpi/battery/BAT0/info
present:                 yes
design capacity:         66240 mWh
last full capacity:      61650 mWh
battery technology:      rechargeable
design voltage:          14400 mV
design capacity warning: 3082 mWh
design capacity low:     200 mWh
capacity granularity 1:  1 mWh
capacity granularity 2:  1 mWh
model number:            42T4507
serial number:             833
battery type:            LION
OEM info:                SANYO

At the moment I am seeing this problem with kernel 2.6.25.3, but I believe I 
have had it for a while (I was reminded of it only just now because I started 
using kpowersave again).

Any ideas?  I'm happy to try to debug, but don't know where to start.

Thanks, and best wishes,

-Andy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: /proc/acpi/battery/BAT0/info stale when battery changed on Thinkpad X60t
  2008-05-14 15:05 /proc/acpi/battery/BAT0/info stale when battery changed on Thinkpad X60t Andy Neitzke
@ 2008-05-14 17:10 ` Alexey Starikovskiy
  2008-05-14 23:18   ` Andy Neitzke
  0 siblings, 1 reply; 4+ messages in thread
From: Alexey Starikovskiy @ 2008-05-14 17:10 UTC (permalink / raw)
  To: Andy Neitzke; +Cc: linux-acpi

Please check if following patch helps:

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index b1c723f..e5ca3a0 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -472,7 +472,7 @@ static void sysfs_remove_battery(struct acpi_battery 
*battery)
 
 static int acpi_battery_update(struct acpi_battery *battery)
 {
-    int result;
+    int result, old_present = acpi_battery_present(battery);
     result = acpi_battery_get_status(battery);
     if (result)
         return result;
@@ -483,7 +483,8 @@ static int acpi_battery_update(struct acpi_battery 
*battery)
         return 0;
     }
 #endif
-    if (!battery->update_time) {
+    if (!battery->update_time ||
+        old_present != acpi_battery_present(battery)) {
         result = acpi_battery_get_info(battery);
         if (result)
             return result;


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: /proc/acpi/battery/BAT0/info stale when battery changed on Thinkpad X60t
  2008-05-14 17:10 ` Alexey Starikovskiy
@ 2008-05-14 23:18   ` Andy Neitzke
  2008-05-15  9:26     ` [PATCH] ACPI: Battery: Update info for inserted battery Alexey Starikovskiy
  0 siblings, 1 reply; 4+ messages in thread
From: Andy Neitzke @ 2008-05-14 23:18 UTC (permalink / raw)
  To: Alexey Starikovskiy; +Cc: linux-acpi

On Wednesday 14 May 2008 1:10:41 pm Alexey Starikovskiy wrote:
> Please check if following patch helps:
>
> diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
> index b1c723f..e5ca3a0 100644

Yes, with that patch the problem seems to have gone away.

Thanks!

-Andy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] ACPI: Battery: Update info for inserted battery
  2008-05-14 23:18   ` Andy Neitzke
@ 2008-05-15  9:26     ` Alexey Starikovskiy
  0 siblings, 0 replies; 4+ messages in thread
From: Alexey Starikovskiy @ 2008-05-15  9:26 UTC (permalink / raw)
  To: LenBrown; +Cc: Linux-acpi

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Acked-by: Andy Neitzke <neitzke@ias.edu>

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
---

 drivers/acpi/battery.c |    5 +++--
 1 files changed, 3 insertions(+), 2 deletions(-)


diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index b1c723f..e5ca3a0 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -472,7 +472,7 @@ static void sysfs_remove_battery(struct acpi_battery *battery)
 
 static int acpi_battery_update(struct acpi_battery *battery)
 {
-	int result;
+	int result, old_present = acpi_battery_present(battery);
 	result = acpi_battery_get_status(battery);
 	if (result)
 		return result;
@@ -483,7 +483,8 @@ static int acpi_battery_update(struct acpi_battery *battery)
 		return 0;
 	}
 #endif
-	if (!battery->update_time) {
+	if (!battery->update_time ||
+	    old_present != acpi_battery_present(battery)) {
 		result = acpi_battery_get_info(battery);
 		if (result)
 			return result;


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-05-15  9:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-14 15:05 /proc/acpi/battery/BAT0/info stale when battery changed on Thinkpad X60t Andy Neitzke
2008-05-14 17:10 ` Alexey Starikovskiy
2008-05-14 23:18   ` Andy Neitzke
2008-05-15  9:26     ` [PATCH] ACPI: Battery: Update info for inserted battery Alexey Starikovskiy

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox