All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexey Starikovskiy <astarikovskiy@suse.de>
To: "Rafael J. Wysocki" <rjw@sisk.pl>
Cc: Johannes Weiner <hannes-kernel@saeurebad.de>,
	"Michael (rabenkind) Brandstetter" <listen@selfservix.org>,
	linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org
Subject: Re: 2.6.24-rc1: OOPS at  acpi_battery_update
Date: Thu, 08 Nov 2007 19:35:23 +0300	[thread overview]
Message-ID: <47333ACB.6070408@suse.de> (raw)
In-Reply-To: <200711081717.00421.rjw@sisk.pl>

[-- Attachment #1: Type: text/plain, Size: 343 bytes --]

Rafael J. Wysocki wrote:
> On Thursday, 8 of November 2007, Johannes Weiner wrote:
>> Hi,
>>
>> is there any reason, why acpi_battery_get_property() should call
>> acpi_battery_update() at all?
> 
> Alex?
Do you mean "why should it call _whole_ battery update?" ?
get_state should be sufficient in order to not get stale data.

Regards,
Alex.

[-- Attachment #2: remove_cycle_at_battery_removal.patch --]
[-- Type: text/x-patch, Size: 1733 bytes --]

ACPI: Battery: remove cycle from battery removal.

From: Alexey Starikovskiy <astarikovskiy@suse.de>

get_property() should not call battery_update() on absent battery to
avoid cycle and oops.

Signed-off-by: Alexey Starikovskiy <astarikovskiy@suse.de>
Tested-by: Rolf Eike Beer <eike-kernel@sf-tec.de>
---

 drivers/acpi/battery.c |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index c2ce0ad..192c244 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -132,7 +132,7 @@ static int acpi_battery_technology(struct acpi_battery *battery)
 	return POWER_SUPPLY_TECHNOLOGY_UNKNOWN;
 }
 
-static int acpi_battery_update(struct acpi_battery *battery);
+static int acpi_battery_get_state(struct acpi_battery *battery);
 
 static int acpi_battery_get_property(struct power_supply *psy,
 				     enum power_supply_property psp,
@@ -140,10 +140,11 @@ static int acpi_battery_get_property(struct power_supply *psy,
 {
 	struct acpi_battery *battery = to_acpi_battery(psy);
 
-	if ((!acpi_battery_present(battery)) &&
-	     psp != POWER_SUPPLY_PROP_PRESENT)
+	if (acpi_battery_present(battery)) {
+		/* run battery update only if it is present */
+		acpi_battery_get_state(battery);
+	} else if (psp != POWER_SUPPLY_PROP_PRESENT)
 		return -ENODEV;
-	acpi_battery_update(battery);
 	switch (psp) {
 	case POWER_SUPPLY_PROP_STATUS:
 		if (battery->state & 0x01)
@@ -457,6 +458,7 @@ static void sysfs_remove_battery(struct acpi_battery *battery)
 		return;
 	device_remove_file(battery->bat.dev, &alarm_attr);
 	power_supply_unregister(&battery->bat);
+	battery->bat.dev = NULL;
 }
 
 static int acpi_battery_update(struct acpi_battery *battery)

  parent reply	other threads:[~2007-11-08 16:35 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-29 10:11 2.6.24-rc1: OOPS at acpi_battery_update Romano Giannetti
2007-10-29 10:11 ` Romano Giannetti
2007-11-01 23:14 ` Andrew Morton
2007-11-02 16:08   ` Rafael J. Wysocki
2007-11-04  9:34     ` *SPAM* " Romano Giannetti
2007-11-04  9:34       ` Romano Giannetti
2007-11-04 13:17       ` Rafael J. Wysocki
2007-11-04 23:29         ` Michael (rabenkind) Brandstetter
2007-11-05  0:18           ` Rafael J. Wysocki
2007-11-08 15:53             ` Johannes Weiner
2007-11-08 16:16               ` Rafael J. Wysocki
2007-11-08 16:11                 ` Alexey Starikovskiy
2007-11-08 16:46                   ` Johannes Weiner
2007-11-08 16:35                 ` Alexey Starikovskiy [this message]
2007-11-08 16:58                   ` Johannes Weiner
2007-11-09  4:34                   ` Andrew Morton
2007-11-09  9:36                     ` Alexey Starikovskiy
2007-11-09  9:49                       ` Andrew Morton
2007-11-13  8:35                         ` Alexey Starikovskiy
2007-11-13  8:59                           ` Andrew Morton
2007-11-13  9:23                           ` [PATCH] ACPI: Battery: remove cycle from battery removal Alexey Starikovskiy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=47333ACB.6070408@suse.de \
    --to=astarikovskiy@suse.de \
    --cc=hannes-kernel@saeurebad.de \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=listen@selfservix.org \
    --cc=rjw@sisk.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.