From owner-freebsd-acpi@FreeBSD.ORG Wed May 26 22:04:29 2004 Return-Path: Delivered-To: freebsd-acpi@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id F3C6C16A4CE for ; Wed, 26 May 2004 22:04:28 -0700 (PDT) Received: from root.org (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with SMTP id B4E2343D1D for ; Wed, 26 May 2004 22:04:28 -0700 (PDT) (envelope-from nate@root.org) Received: (qmail 87946 invoked by uid 1000); 27 May 2004 05:03:44 -0000 Date: Wed, 26 May 2004 22:03:44 -0700 (PDT) From: Nate Lawson To: "Liam J. Foy" In-Reply-To: <20040520205712.57abc39b.liamfoy@sepulcrum.org> Message-ID: <20040526215940.F87914@root.org> References: <20040520205712.57abc39b.liamfoy@sepulcrum.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII cc: freebsd-acpi@freebsd.org Subject: Re: apm code X-BeenThere: freebsd-acpi@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: ACPI and power management development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 May 2004 05:04:29 -0000 On Thu, 20 May 2004, Liam J. Foy wrote: > Hey, > > Just writing to the list to make sure am correct here. The issue concerns /usr/src/usr.sbin/apm/apm.c. > > --- /usr/src/usr.sbin/apm/apm.c Thu May 20 20:30:57 2004 > +++ /hd2/apm.c Thu May 20 20:44:36 2004 > @@ -174,7 +174,7 @@ > printf("Remaining battery life: "); > if (aip->ai_batt_life == 255) > printf("unknown\n"); > - else if (aip->ai_batt_life <= 100) > + else if (aip->ai_batt_life >= 0 && aip->ai_batt_life <= 100) > printf("%d%%\n", aip->ai_batt_life); > else > printf("invalid value (0x%x)\n", aip->ai_batt_life); > > The above patch will make apm print invalid value when ai_batt_life does not equal 0-100. The reason for this was the the current code was printing -1 as a so called valid value(normally when acline is connected). I dont think printing -1 is correct, and really it should be printing invalid value since that is what it is. Do you guys agree with me or does -1 symbolise something? > > Something else I am curious over is this snippet of code: > > if (aip->ai_infoversion >= 1) { > printf("Number of batteries: "); > if (aip->ai_batteries == (u_int) -1) > printf("unknown\n"); > else { > > ai_batteries in machine/apm_bios.h is defined as u_int. Yet the above code is testing for -1. I _think_ this should be testing for 255(unknown). Anyone shead any light on this? I ask since I do not know apm very well. Would you guys agree my patch is correct also? Are you using ACPI or APM for your power management? Also, what values are reported as "invalid" besides "Remaining battery life"? The usermode code is correct in comparing against 255 but it may be that the kernel code is setting things to -1 (0xffffffff) which != 0xff. -Nate