Switch apmdev to use apm(4) structures from dev/apm/apmvar.h.
Add batteryid argument to aa_get_powstat method implementations.
This commit is contained in:
parent
7cbde2c0d5
commit
9a25b0cb7f
@ -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 int zapm_hook(void *, int, long, void *);
|
||||
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 @@ zapm_set_powstate(void *v, u_int devid, u_int powstat)
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -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 @@ int apmdebug = 0;
|
||||
#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 @@ struct apm_softc {
|
||||
#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 @@ apm_event_handle(struct apm_softc *sc, u_int event_code, u_int event_info)
|
||||
|
||||
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 @@ apm_event_handle(struct apm_softc *sc, u_int event_code, u_int event_info)
|
||||
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 @@ apm_attach(struct apm_softc *sc)
|
||||
*/
|
||||
(*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 @@ apmdevioctl(dev_t dev, u_long cmd, void *data, int flag,
|
||||
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;
|
||||
|
@ -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;
|
||||
|
@ -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 @@ __KERNEL_RCSID(0, "$NetBSD: hpcapm.c,v 1.14 2009/03/30 06:17:39 uwe Exp $");
|
||||
#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 int hpcapm_hook(void *, int, long, void *);
|
||||
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 @@ hpcapm_set_powstate(void *scx, u_int devid, u_int powstat)
|
||||
}
|
||||
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user