From mboxrd@z Thu Jan 1 00:00:00 1970 From: Sitsofe Wheeler Subject: Re: [PATCH] ACPI / Battery: Return -ENODATA for unknown values in get_property() Date: Sat, 23 Oct 2010 16:36:37 +0100 Message-ID: <20101023153637.GA8994@sucs.org> References: <20101016141321.GA11054@sucs.org> <201010212157.47952.rjw@sisk.pl> <20101021204620.GB3318@sucs.org> <201010230019.14100.rjw@sisk.pl> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Received: from silver.sucs.swan.ac.uk ([137.44.10.1]:57507 "EHLO silver.sucs.swan.ac.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757692Ab0JWPhQ (ORCPT ); Sat, 23 Oct 2010 11:37:16 -0400 Content-Disposition: inline In-Reply-To: <201010230019.14100.rjw@sisk.pl> Sender: linux-acpi-owner@vger.kernel.org List-Id: linux-acpi@vger.kernel.org To: "Rafael J. Wysocki" Cc: Henrique de Moraes Holschuh , Matthew Garrett , Len Brown , Zhang Rui , David Zeuthen , Richard Hughes , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org On Sat, Oct 23, 2010 at 12:19:13AM +0200, Rafael J. Wysocki wrote: > > OK, so can you test the patch below, please? The latest patch seems to fix/workaround the problem. upower now reports 0 as the energy rate, there are no warnings in dmesg and battery hotplug works. Looks good and there's the option for a future upower to interpret the missing sysfs as meaning "unknown". Tested-by: Sitsofe Wheeler > The function acpi_battery_get_property() is called by the > power supply framework's function power_supply_show_property() > implementing the sysfs interface for power supply devices as the > ACPI battery driver's ->get_property() callback. Thus it is supposed > to return error code if the value of the given property is unknown. > Unfortunately, however, it returns 0 in those cases and puts a > wrong (negative) value into the intval field of the > union power_supply_propval object provided by > power_supply_show_property(). In consequence, wron negative wron -> wrong? > Fix this by making acpi_battery_get_property() return -ENODEV > for properties with unknown values (-ENODEV is returned, because > power_supply_uevent() returns with error for any other error code > returned by power_supply_show_property()). OK that's sneaky and clever - technically power_supply_uevent should be more robust but presumably things are already prepared to handle -ENODEV so overloading the meaning leads to the smallest change. -- Sitsofe | http://sucs.org/~sits/