Re: Bad AC adaptateur value trought sysfst

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

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

[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux