[patch] Move negative checks to util.c, from acpi.c (resend)
Danny Kukawka
danny.kukawka at web.de
Sun Aug 21 11:03:20 PDT 2005
On Sunday 21 August 2005 19:06, Richard Hughes wrote:
> On Wed, 2005-08-17 at 22:56 +0100, Richard Hughes wrote:
>
> Further to Danny's fixes, how about these?
>
> Richard.
More comments in the code are always good :-)
But I'm not sure if it is a good Idea to return 0 if chargeLevel >
chargeLastFull. You can't calculate the time so don't add the key with 0.
This case is the same case as in my patch. But in the percentage case you can
say it's 100% but you can say absolutely nothing about the remaining time. If
we return -1 you don't add the related key to HAL. If the chargeLevel fails
under the chargeLastFull you get a correct time. Maybe better to wait for
this.
+ if (chargeRate = 0) {
+ /* Some ACPI BIOS's don't report rate */
+ if (isDischarging || isCharging) {
+ HAL_WARNING (("chargeRate is 0, but discharging or
charging. ACPI bug?."));
+ return -1;
+ } else {
+ HAL_INFO (("chargeRate is 0"));
+ return 0;
+ }
+ }
The else path is IMO alway true if the machine is full charged and on AC. In
this case we don't need the remaining time. Also not as 0, I think. This
maybe can also happen in other case (I don't know a machine with this problem
currently.) But in this case you have more than only a broke ACPI
Implementation. And in this case you don't need the 0. ;-)
Cheers
Danny
More information about the hal
mailing list