Use pmf(9) instead of powerhook_*.

This commit is contained in:
nonaka 2009-01-29 16:00:33 +00:00
parent 59393ffeff
commit 664df27b21
4 changed files with 78 additions and 89 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: zaudio.c,v 1.6 2009/01/29 12:28:15 nonaka Exp $ */
/* $NetBSD: zaudio.c,v 1.7 2009/01/29 16:00:33 nonaka Exp $ */
/* $OpenBSD: zaurus_audio.c,v 1.8 2005/08/18 13:23:02 robert Exp $ */
/*
@ -60,8 +60,8 @@ __KERNEL_RCSID(0, "$NetBSD");
static int zaudio_match(device_t, cfdata_t, void *);
static void zaudio_attach(device_t, device_t, void *);
static int zaudio_detach(device_t, int);
static void zaudio_power(int, void *);
static bool zaudio_suspend(device_t dv PMF_FN_ARGS);
static bool zaudio_resume(device_t dv PMF_FN_ARGS);
#define ZAUDIO_OP_SPKR 0
#define ZAUDIO_OP_HP 1
@ -89,7 +89,6 @@ struct zaudio_softc {
/* i2c device softc */
struct pxa2x0_i2c_softc sc_i2c;
void *sc_powerhook;
int sc_playing;
struct zaudio_volume sc_volume[2];
@ -101,7 +100,7 @@ struct zaudio_softc {
};
CFATTACH_DECL_NEW(zaudio, sizeof(struct zaudio_softc),
zaudio_match, zaudio_attach, zaudio_detach, NULL);
zaudio_match, zaudio_attach, NULL, NULL);
static struct audio_device wm8750_device = {
"WM8750",
@ -221,12 +220,9 @@ zaudio_attach(device_t parent, device_t self, void *aux)
aprint_normal(": I2C, I2S, WM8750 Audio\n");
aprint_naive("\n");
sc->sc_powerhook = powerhook_establish(device_xname(sc->sc_dev),
zaudio_power, sc);
if (sc->sc_powerhook == NULL) {
aprint_error_dev(sc->sc_dev, "unable to establish powerhook\n");
return;
}
if (!pmf_device_register(sc->sc_dev, zaudio_suspend, zaudio_resume))
aprint_error_dev(sc->sc_dev,
"couldn't establish power handler\n");
sc->sc_i2s.sc_iot = pxa->pxa_iot;
sc->sc_i2s.sc_dmat = pxa->pxa_dmat;
@ -247,7 +243,6 @@ zaudio_attach(device_t parent, device_t self, void *aux)
pxa2x0_i2c_open(&sc->sc_i2c);
rv = wm8750_write(sc, RESET_REG, 0);
pxa2x0_i2c_close(&sc->sc_i2c);
if (rv) {
aprint_error_dev(sc->sc_dev, "codec failed to respond\n");
goto fail_probe;
@ -279,43 +274,30 @@ fail_probe:
fail_i2c:
pxa2x0_i2s_detach_sub(&sc->sc_i2s);
fail_i2s:
powerhook_disestablish(sc->sc_powerhook);
pmf_device_deregister(self);
}
static int
zaudio_detach(device_t self, int flags)
static bool
zaudio_suspend(device_t dv PMF_FN_ARGS)
{
struct zaudio_softc *sc = device_private(self);
struct zaudio_softc *sc = device_private(dv);
if (sc->sc_powerhook != NULL) {
powerhook_disestablish(sc->sc_powerhook);
sc->sc_powerhook = NULL;
}
callout_stop(&sc->sc_to);
zaudio_standby(sc);
pxa2x0_i2c_detach_sub(&sc->sc_i2c);
pxa2x0_i2s_detach_sub(&sc->sc_i2s);
return 0;
return true;
}
static void
zaudio_power(int why, void *arg)
static bool
zaudio_resume(device_t dv PMF_FN_ARGS)
{
struct zaudio_softc *sc = arg;
struct zaudio_softc *sc = device_private(dv);
switch (why) {
case PWR_STANDBY:
case PWR_SUSPEND:
callout_stop(&sc->sc_to);
zaudio_standby(sc);
break;
pxa2x0_i2s_init(&sc->sc_i2s);
pxa2x0_i2c_init(&sc->sc_i2c);
zaudio_init(sc);
case PWR_RESUME:
pxa2x0_i2s_init(&sc->sc_i2s);
pxa2x0_i2c_init(&sc->sc_i2c);
zaudio_init(sc);
break;
}
return true;
}
void
@ -345,7 +327,6 @@ zaudio_init(struct zaudio_softc *sc)
/* Assume that the jack state has changed. */
zaudio_jack(sc);
}
static int

View File

@ -1,4 +1,4 @@
/* $NetBSD: zkbd.c,v 1.8 2009/01/29 12:28:15 nonaka Exp $ */
/* $NetBSD: zkbd.c,v 1.9 2009/01/29 16:00:33 nonaka Exp $ */
/* $OpenBSD: zaurus_kbd.c,v 1.28 2005/12/21 20:36:03 deraadt Exp $ */
/*
@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: zkbd.c,v 1.8 2009/01/29 12:28:15 nonaka Exp $");
__KERNEL_RCSID(0, "$NetBSD: zkbd.c,v 1.9 2009/01/29 16:00:33 nonaka Exp $");
#include "opt_wsdisplay_compat.h"
#include "lcd.h"
@ -116,7 +116,6 @@ struct zkbd_softc {
char sc_rep[MAXKEYS];
int sc_nrep;
#endif
void *sc_powerhook;
};
static struct zkbd_softc *zkbd_sc;
@ -132,7 +131,7 @@ static void zkbd_poll(void *v);
static int zkbd_on(void *v);
static int zkbd_sync(void *v);
static int zkbd_hinge(void *v);
static void zkbd_power(int why, void *arg);
static bool zkbd_resume(device_t dv PMF_FN_ARGS);
int zkbd_modstate;
@ -215,12 +214,9 @@ zkbd_attach(device_t parent, device_t self, void *aux)
return;
}
sc->sc_powerhook = powerhook_establish(device_xname(sc->sc_dev),
zkbd_power, sc);
if (sc->sc_powerhook == NULL) {
aprint_error_dev(sc->sc_dev, "unable to establish powerhook\n");
return;
}
if (!pmf_device_register(sc->sc_dev, NULL, zkbd_resume))
aprint_error_dev(sc->sc_dev,
"couldn't establish power handler\n");
sc->sc_okeystate = malloc(sc->sc_nsense * sc->sc_nstrobe,
M_DEVBUF, M_NOWAIT);
@ -597,9 +593,12 @@ zkbd_cnpollc(void *v, int on)
{
}
static void
zkbd_power(int why, void *arg)
static bool
zkbd_resume(device_t dv PMF_FN_ARGS)
{
struct zkbd_softc *sc = device_private(dv);
zkbd_hinge(arg);
zkbd_hinge(sc);
return true;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: zlcd.c,v 1.8 2009/01/29 12:28:15 nonaka Exp $ */
/* $NetBSD: zlcd.c,v 1.9 2009/01/29 16:00:33 nonaka Exp $ */
/* $OpenBSD: zaurus_lcd.c,v 1.20 2006/06/02 20:50:14 miod Exp $ */
/* NetBSD: lubbock_lcd.c,v 1.1 2003/08/09 19:38:53 bsh Exp */
@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: zlcd.c,v 1.8 2009/01/29 12:28:15 nonaka Exp $");
__KERNEL_RCSID(0, "$NetBSD: zlcd.c,v 1.9 2009/01/29 16:00:33 nonaka Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -154,6 +154,9 @@ static void lcd_attach(device_t, device_t, void *);
CFATTACH_DECL_NEW(zlcd, sizeof(struct pxa2x0_lcd_softc),
lcd_match, lcd_attach, NULL, NULL);
static bool lcd_suspend(device_t dv PMF_FN_ARGS);
static bool lcd_resume(device_t dv PMF_FN_ARGS);
void lcd_cnattach(void);
int lcd_max_brightness(void);
int lcd_get_brightness(void);
@ -162,7 +165,6 @@ void lcd_set_brightness_internal(int);
int lcd_get_backlight(void);
void lcd_set_backlight(int);
void lcd_blank(int);
void lcd_power(int, void *);
static int
lcd_match(device_t parent, cfdata_t cf, void *aux)
@ -191,7 +193,8 @@ lcd_attach(device_t parent, device_t self, void *aux)
/* Start with approximately 40% of full brightness. */
lcd_set_brightness(3);
(void) powerhook_establish(device_xname(sc->dev), lcd_power, sc);
if (!pmf_device_register(sc->dev, lcd_suspend, lcd_resume))
aprint_error_dev(sc->dev, "couldn't establish power handler\n");
}
void
@ -201,6 +204,31 @@ lcd_cnattach(void)
pxa2x0_lcd_cnattach(&lcd_std_screen, CURRENT_DISPLAY);
}
/*
* power management
*/
static bool
lcd_suspend(device_t dv PMF_FN_ARGS)
{
struct pxa2x0_lcd_softc *sc = device_private(dv);
lcd_set_brightness(0);
pxa2x0_lcd_suspend(sc);
return true;
}
static bool
lcd_resume(device_t dv PMF_FN_ARGS)
{
struct pxa2x0_lcd_softc *sc = device_private(dv);
pxa2x0_lcd_resume(sc);
lcd_set_brightness(lcd_get_brightness());
return true;
}
/*
* wsdisplay accessops overrides
*/
@ -493,21 +521,3 @@ lcd_blank(int blank)
lcd_set_brightness(lcd_get_brightness());
}
}
void
lcd_power(int why, void *v)
{
switch (why) {
case PWR_SUSPEND:
case PWR_STANDBY:
lcd_set_brightness(0);
pxa2x0_lcd_power(why, v);
break;
case PWR_RESUME:
pxa2x0_lcd_power(why, v);
lcd_set_brightness(lcd_get_brightness());
break;
}
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: zssp.c,v 1.5 2009/01/29 12:51:15 nonaka Exp $ */
/* $NetBSD: zssp.c,v 1.6 2009/01/29 16:00:33 nonaka Exp $ */
/* $OpenBSD: zaurus_ssp.c,v 1.6 2005/04/08 21:58:49 uwe Exp $ */
/*
@ -18,7 +18,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: zssp.c,v 1.5 2009/01/29 12:51:15 nonaka Exp $");
__KERNEL_RCSID(0, "$NetBSD: zssp.c,v 1.6 2009/01/29 16:00:33 nonaka Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@ -54,7 +54,7 @@ CFATTACH_DECL_NEW(zssp, sizeof(struct zssp_softc),
zssp_match, zssp_attach, NULL, NULL);
static void zssp_init(void);
static void zssp_powerhook(int, void *);
static bool zssp_resume(device_t dv PMF_FN_ARGS);
static struct zssp_softc *zssp_sc;
@ -86,10 +86,9 @@ zssp_attach(device_t parent, device_t self, void *aux)
return;
}
if (powerhook_establish(device_xname(sc->sc_dev), zssp_powerhook, sc)
== NULL) {
aprint_error_dev(sc->sc_dev, "can't establish power hook\n");
}
if (!pmf_device_register(sc->sc_dev, NULL, zssp_resume))
aprint_error_dev(sc->sc_dev,
"couldn't establish power handler\n");
zssp_init();
}
@ -116,16 +115,16 @@ zssp_init(void)
pxa2x0_gpio_set_function(GPIO_TG_CS_C3000, GPIO_OUT|GPIO_SET);
}
static void
zssp_powerhook(int why, void *arg)
static bool
zssp_resume(device_t dv PMF_FN_ARGS)
{
int s;
if (why == PWR_RESUME) {
s = splhigh();
zssp_init();
splx(s);
}
s = splhigh();
zssp_init();
splx(s);
return true;
}
/*