Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/i386 Make it possible to query each battery individ...



details:   https://anonhg.NetBSD.org/src/rev/b8adce8e2aea
branches:  trunk
changeset: 514747:b8adce8e2aea
user:      perry <perry%NetBSD.org@localhost>
date:      Mon Sep 10 05:23:30 2001 +0000

description:
Make it possible to query each battery individually by making the
APM_IOC_GETPOWER ioctl read/write. Setting the batteryid in the passed
structure returns the data for just that battery. The old ioctl
remains for binary compatibility but has been renamed.

Itojun already did the hard work -- I just added a couple of lines.

reviewed by: thorpej

diffstat:

 sys/arch/i386/i386/apm.c       |  8 ++++++--
 sys/arch/i386/include/apmvar.h |  6 ++++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diffs (47 lines):

diff -r 04c4b788f953 -r b8adce8e2aea sys/arch/i386/i386/apm.c
--- a/sys/arch/i386/i386/apm.c  Mon Sep 10 04:43:35 2001 +0000
+++ b/sys/arch/i386/i386/apm.c  Mon Sep 10 05:23:30 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apm.c,v 1.63 2001/08/06 07:59:39 thorpej Exp $ */
+/*     $NetBSD: apm.c,v 1.64 2001/09/10 05:23:30 perry Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -1679,9 +1679,13 @@
                }
                break;
 
+       case OAPM_IOC_GETPOWER:
        case APM_IOC_GETPOWER:
                powerp = (struct apm_power_info *)data;
-               batteryid = 0;  /* need a way to pass it from the userland */
+               if (cmd == OAPM_IOC_GETPOWER)
+                       batteryid = 0;
+               else
+                       batteryid = powerp->batteryid;
                if (apm_minver >= 2) {
                        apm_get_capabilities(&regs);
                        if (batteryid > APM_NBATTERIES(&regs)) {
diff -r 04c4b788f953 -r b8adce8e2aea sys/arch/i386/include/apmvar.h
--- a/sys/arch/i386/include/apmvar.h    Mon Sep 10 04:43:35 2001 +0000
+++ b/sys/arch/i386/include/apmvar.h    Mon Sep 10 05:23:30 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: apmvar.h,v 1.13 2001/07/22 16:05:18 itojun Exp $       */
+/*     $NetBSD: apmvar.h,v 1.14 2001/09/10 05:23:32 perry Exp $        */
 /*-
  * Copyright (c) 1995 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -295,10 +295,12 @@
 #define        APM_IOC_REJECT  _IOW('A', 0, struct apm_event_info) /* reject request # */
 #define        APM_IOC_STANDBY _IO('A', 1)     /* put system into standby */
 #define        APM_IOC_SUSPEND _IO('A', 2)     /* put system into suspend */
-#define        APM_IOC_GETPOWER _IOR('A', 3, struct apm_power_info) /* fetch battery state */
+#define        OAPM_IOC_GETPOWER _IOR('A', 3, struct apm_power_info) /* fetch battery state */
+#define        APM_IOC_GETPOWER _IOWR('A', 3, struct apm_power_info) /* fetch battery state */
 #define        APM_IOC_NEXTEVENT _IOR('A', 4, struct apm_event_info) /* fetch event */
 #define        APM_IOC_DEV_CTL _IOW('A', 5, struct apm_ctl) /* put device into mode */
 
+
 struct apm_attach_args {
        char *aaa_busname;
 };



Home | Main Index | Thread Index | Old Index