linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Zhang Rui <rui.zhang@intel.com>
To: Seblu <seblu@seblu.net>
Cc: "linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	Len Brown <lenb@kernel.org>
Subject: Re: Bad AC adaptateur value trought sysfst
Date: Mon, 01 Nov 2010 08:44:05 +0800	[thread overview]
Message-ID: <1288572245.2234.88.camel@rui> (raw)
In-Reply-To: <AANLkTino-WkpMHfqD6amL-gk5mabiQAVbn9Low8L6joF@mail.gmail.com>

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

Hi, Seblu,

On Mon, 2010-11-01 at 02:35 +0800, Seblu wrote:

> Got it, hal says adapter is offline...
> 
> cat /sys/devices/LNXSYSTM:00/device:00/ACPI0003:00/power_supply/AC/online
> 255
> watching dmesg show error about acpi ac adapter reading... (in pj)
> 
will you please attach the acpidump output of this laptop?

> The most strange for me, is, if i call acpitool or cat
> /proc/acpi/ac_adapter/AC/state, value in
> /sys/devices/LNXSYSTM:00/device:00/ACPI0003:00/power_supply/AC/online
> the answer goes right become 1. And so everything become ok. if i
> unplug and plug again the power cord, online state is reported
> correctly. This issue is only when the pc start with power cord
> plugged.
if you unplug the AC, is the status reported correctly?

> 
> I believe, issue come from a race condition, because if in my init
> script i access to /proc acpi file, and after hal start, status is
> reported correctly.
> 
> My current workaround is to load ac module in initrd, because, distro
> startup run udevadm trigger after and when it's done before, behaviour
> was like i said before.
> 
please try the patch attached to see if it helps.
BTW, the patch is based on today's git tree. and there may be some
conflict if you use 2.6.36 kernel.

thanks,
rui


[-- Attachment #2: patch-update-AC-status-when-querying-from-sysfs --]
[-- Type: text/x-vhdl, Size: 1939 bytes --]

---
 drivers/acpi/ac.c |   45 ++++++++++++++++++++++++++++-----------------
 1 file changed, 28 insertions(+), 17 deletions(-)

Index: linux-2.6/drivers/acpi/ac.c
===================================================================
--- linux-2.6.orig/drivers/acpi/ac.c
+++ linux-2.6/drivers/acpi/ac.c
@@ -100,24 +100,7 @@ static const struct file_operations acpi
 	.release = single_release,
 };
 #endif
-static int get_ac_property(struct power_supply *psy,
-			   enum power_supply_property psp,
-			   union power_supply_propval *val)
-{
-	struct acpi_ac *ac = to_acpi_ac(psy);
-	switch (psp) {
-	case POWER_SUPPLY_PROP_ONLINE:
-		val->intval = ac->state;
-		break;
-	default:
-		return -EINVAL;
-	}
-	return 0;
-}
 
-static enum power_supply_property ac_props[] = {
-	POWER_SUPPLY_PROP_ONLINE,
-};
 /* --------------------------------------------------------------------------
                                AC Adapter Management
    -------------------------------------------------------------------------- */
@@ -140,6 +123,34 @@ static int acpi_ac_get_state(struct acpi
 	return 0;
 }
 
+/* --------------------------------------------------------------------------
+                            sysfs I/F
+   -------------------------------------------------------------------------- */
+static int get_ac_property(struct power_supply *psy,
+			   enum power_supply_property psp,
+			   union power_supply_propval *val)
+{
+	struct acpi_ac *ac = to_acpi_ac(psy);
+
+	if (!ac)
+		return -EINVAL;
+
+	if (acpi_ac_get_state(ac))
+		return -ENODEV;
+
+	switch (psp) {
+	case POWER_SUPPLY_PROP_ONLINE:
+		val->intval = ac->state;
+		break;
+	default:
+		return -EINVAL;
+	}
+	return 0;
+}
+
+static enum power_supply_property ac_props[] = {
+	POWER_SUPPLY_PROP_ONLINE,
+};
 #ifdef CONFIG_ACPI_PROCFS_POWER
 /* --------------------------------------------------------------------------
                               FS Interface (/proc)

  reply	other threads:[~2010-11-01  0:44 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-31 18:35 Bad AC adaptateur value trought sysfst Seblu
2010-11-01  0:44 ` Zhang Rui [this message]
     [not found]   ` <AANLkTin517i-Ld_rNRxjmt65hiVpT3bC3wCrL43weiu7@mail.gmail.com>
2010-11-02  1:16     ` Zhang Rui
2010-11-02  1:50       ` Seblu

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=1288572245.2234.88.camel@rui \
    --to=rui.zhang@intel.com \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=seblu@seblu.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).