Module Name:    src
Committed By:   uwe
Date:           Fri Apr  3 04:13:18 UTC 2009

Modified Files:
        src/sys/arch/zaurus/dev: zapm.c
        src/sys/dev/hpc: hpcapm.c
        src/sys/dev/hpc/apm: apmdev.c apmvar.h

Log Message:
Switch apmdev to use apm(4) structures from dev/apm/apmvar.h.
Add batteryid argument to aa_get_powstat method implementations.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/zaurus/dev/zapm.c
cvs rdiff -u -r1.14 -r1.15 src/sys/dev/hpc/hpcapm.c
cvs rdiff -u -r1.21 -r1.22 src/sys/dev/hpc/apm/apmdev.c
cvs rdiff -u -r1.4 -r1.5 src/sys/dev/hpc/apm/apmvar.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/zaurus/dev/zapm.c
diff -u src/sys/arch/zaurus/dev/zapm.c:1.5 src/sys/arch/zaurus/dev/zapm.c:1.6
--- src/sys/arch/zaurus/dev/zapm.c:1.5	Wed Mar 11 09:04:31 2009
+++ src/sys/arch/zaurus/dev/zapm.c	Fri Apr  3 04:13:17 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: zapm.c,v 1.5 2009/03/11 09:04:31 nonaka Exp $	*/
+/*	$NetBSD: zapm.c,v 1.6 2009/04/03 04:13:17 uwe Exp $	*/
 /*	$OpenBSD: zaurus_apm.c,v 1.13 2006/12/12 23:14:28 dim Exp $	*/
 
 /*
@@ -18,12 +18,13 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: zapm.c,v 1.5 2009/03/11 09:04:31 nonaka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: zapm.c,v 1.6 2009/04/03 04:13:17 uwe Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
 #include <sys/kernel.h>
 #include <sys/callout.h>
+#include <sys/selinfo.h> /* XXX: for apm_softc that is exposed here */
 
 #include <dev/hpc/apm/apmvar.h>
 
@@ -86,7 +87,7 @@
 static void     zapm_disconnect(void *);
 static void     zapm_enable(void *, int);
 static int      zapm_set_powstate(void *, u_int, u_int);
-static int      zapm_get_powstat(void *, struct apm_power_info *);
+static int      zapm_get_powstat(void *, u_int, struct apm_power_info *);
 static int      zapm_get_event(void *, u_int *, u_int *);
 static void     zapm_cpu_busy(void *);
 static void     zapm_cpu_idle(void *);
@@ -389,7 +390,7 @@
 }
 
 static int
-zapm_get_powstat(void *v, struct apm_power_info *pinfo)
+zapm_get_powstat(void *v, u_int batteryid, struct apm_power_info *pinfo)
 {
 	struct zapm_softc *sc = (struct zapm_softc *)v;
 	int val;

Index: src/sys/dev/hpc/hpcapm.c
diff -u src/sys/dev/hpc/hpcapm.c:1.14 src/sys/dev/hpc/hpcapm.c:1.15
--- src/sys/dev/hpc/hpcapm.c:1.14	Mon Mar 30 06:17:39 2009
+++ src/sys/dev/hpc/hpcapm.c	Fri Apr  3 04:13:17 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: hpcapm.c,v 1.14 2009/03/30 06:17:39 uwe Exp $	*/
+/*	$NetBSD: hpcapm.c,v 1.15 2009/04/03 04:13:17 uwe Exp $	*/
 
 /*
  * Copyright (c) 2000 Takemura Shin
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hpcapm.c,v 1.14 2009/03/30 06:17:39 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpcapm.c,v 1.15 2009/04/03 04:13:17 uwe Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_hpcapm.h"
@@ -39,6 +39,7 @@
 #include <sys/device.h>
 #include <sys/kernel.h>
 #include <sys/systm.h>
+#include <sys/selinfo.h> /* XXX: for apm_softc that is exposed here */
 
 #include <dev/hpc/apm/apmvar.h>
 
@@ -67,7 +68,7 @@
 static void	hpcapm_disconnect(void *);
 static void	hpcapm_enable(void *, int);
 static int	hpcapm_set_powstate(void *, u_int, u_int);
-static int	hpcapm_get_powstat(void *, struct apm_power_info *);
+static int	hpcapm_get_powstat(void *, u_int, struct apm_power_info *);
 static int	hpcapm_get_event(void *, u_int *, u_int *);
 static void	hpcapm_cpu_busy(void *);
 static void	hpcapm_cpu_idle(void *);
@@ -367,7 +368,7 @@
 }
 
 static int
-hpcapm_get_powstat(void *scx, struct apm_power_info *pinfo)
+hpcapm_get_powstat(void *scx, u_int batteryid, struct apm_power_info *pinfo)
 {
 	struct apmhpc_softc *sc;
 	int val;

Index: src/sys/dev/hpc/apm/apmdev.c
diff -u src/sys/dev/hpc/apm/apmdev.c:1.21 src/sys/dev/hpc/apm/apmdev.c:1.22
--- src/sys/dev/hpc/apm/apmdev.c:1.21	Fri Apr  3 02:08:38 2009
+++ src/sys/dev/hpc/apm/apmdev.c	Fri Apr  3 04:13:17 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: apmdev.c,v 1.21 2009/04/03 02:08:38 uwe Exp $ */
+/*	$NetBSD: apmdev.c,v 1.22 2009/04/03 04:13:17 uwe Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: apmdev.c,v 1.21 2009/04/03 02:08:38 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: apmdev.c,v 1.22 2009/04/03 04:13:17 uwe Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_apmdev.h"
@@ -80,24 +80,6 @@
 #define	DPRINTF(f, x)		/**/
 #endif /* APMDEBUG */
 
-#define APM_NEVENTS 16
-
-struct apm_softc {
-	device_t sc_dev;
-	struct selinfo sc_rsel;
-	struct selinfo sc_xsel;
-	int	sc_flags;
-	int	sc_event_count;
-	int	sc_event_ptr;
-	int	sc_power_state;
-	lwp_t	*sc_thread;
-	kmutex_t sc_lock;
-	struct apm_event_info sc_event_list[APM_NEVENTS];
-	struct apm_accessops *sc_ops;
-	int	sc_vers;
-	int	sc_detail;
-	void *sc_cookie;
-};
 #define	SCFLAG_OREAD	0x0000001
 #define	SCFLAG_OWRITE	0x0000002
 #define	SCFLAG_OPEN	(SCFLAG_OREAD|SCFLAG_OWRITE)
@@ -118,11 +100,6 @@
 #define	APM_UNLOCK(apmsc)						\
 	(void) mutex_exit(&(apmsc)->sc_lock)
 
-/* in real dev/apm/apmvar.h */
-static int apm_match(void);
-static void apm_attach(struct apm_softc *);
-static const char *apm_strerror(int);
-
 static void	apmdevattach(device_t, device_t, void *);
 static int	apmdevmatch(device_t, cfdata_t, void *);
 
@@ -495,7 +472,7 @@
 
 	case APM_POWER_CHANGE:
 		DPRINTF(APMDEBUG_EVENTS, ("apmev: power status change\n"));
-		error = (*sc->sc_ops->aa_get_powstat)(sc->sc_cookie, &pi);
+		error = (*sc->sc_ops->aa_get_powstat)(sc->sc_cookie, 0, &pi);
 #ifdef APM_POWER_PRINT
 		/* only print if nobody is catching events. */
 		if (error == 0 &&
@@ -545,7 +522,7 @@
 			u_int numbatts, capflags;
 			(*sc->sc_ops->aa_get_capabilities)(sc->sc_cookie,
 			    &numbatts, &capflags);
-			(*sc->sc_ops->aa_get_powstat)(sc->sc_cookie, &pi);
+			(*sc->sc_ops->aa_get_powstat)(sc->sc_cookie, 0, &pi);
 		}
 		break;
 
@@ -718,7 +695,7 @@
 	 */
 	(*sc->sc_ops->aa_enable)(sc->sc_cookie, 1);
 
-	error = (*sc->sc_ops->aa_get_powstat)(sc->sc_cookie, &pinfo);
+	error = (*sc->sc_ops->aa_get_powstat)(sc->sc_cookie, 0, &pinfo);
 	if (error == 0) {
 #ifdef APM_POWER_PRINT
 		apm_power_print(sc, &pinfo);
@@ -895,7 +872,7 @@
 	case OAPM_IOC_GETPOWER:
 	case APM_IOC_GETPOWER:
 		powerp = (struct apm_power_info *)data;
-		if ((error = (*sc->sc_ops->aa_get_powstat)(sc->sc_cookie,
+		if ((error = (*sc->sc_ops->aa_get_powstat)(sc->sc_cookie, 0,
 		    powerp)) != 0) {
 			apm_perror("ioctl get power status", error);
 			error = EIO;

Index: src/sys/dev/hpc/apm/apmvar.h
diff -u src/sys/dev/hpc/apm/apmvar.h:1.4 src/sys/dev/hpc/apm/apmvar.h:1.5
--- src/sys/dev/hpc/apm/apmvar.h:1.4	Mon Mar 30 06:22:25 2009
+++ src/sys/dev/hpc/apm/apmvar.h	Fri Apr  3 04:13:17 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: apmvar.h,v 1.4 2009/03/30 06:22:25 uwe Exp $	*/
+/*	$NetBSD: apmvar.h,v 1.5 2009/04/03 04:13:17 uwe Exp $	*/
 /*-
  * Copyright (c) 2001, 2002 The NetBSD Foundation, Inc.
  * All rights reserved.
@@ -30,19 +30,7 @@
 #ifndef __DEV_APM_APMVAR_H__
 #define __DEV_APM_APMVAR_H__
 
-#include <dev/apm/apmbios.h>
-#include <dev/apm/apmio.h>
-
-struct apm_accessops {
-	void	(*aa_disconnect)(void *);
-	void	(*aa_enable)(void *, int);
-	int	(*aa_set_powstate)(void *, u_int, u_int);
-	int	(*aa_get_powstat)(void *, struct apm_power_info *);
-	int	(*aa_get_event)(void *, u_int *, u_int *);
-	void	(*aa_cpu_busy)(void *);
-	void	(*aa_cpu_idle)(void *);
-	void	(*aa_get_capabilities)(void *, u_int *, u_int *);
-};
+#include <dev/apm/apmvar.h>
 
 struct apmdev_attach_args {
 	struct apm_accessops *accessops;

Reply via email to